To design a pool game AI, is it possible to clone the whole table outside of camera view, shoot the ball from certain angle, get results very quickly, then keep repeating above steps from other angles in order to get the angle to shoot from?
I am not sure what you mean but timeScale if = 1 runs at normal time. TimeScale = 0, game paused. So why not make timeScale 300 000?
Thanks. I will give it a try.
How do people usually code those type of AI anyway?
Pool/snooker ai is very simple (I have done it before with complete success*):
- gather a list of balls you can hit with your cueball successfully
- starting with the highest scoring ball, simulate. That means run a parallel simulation to see if reached the pocket or not. This isn’t as many frames as you think, and typically used to take around 400-500 loops to complete which was trivial for a pentium 2 at the time.
There’s no magic to it - they don’t predict, they simulate behind the scenes. Difficulty can be adjusted by adding errors to the angle or strength.
To simulate in unity, you need to adjust the fixedupdate rate I would suspect along with timescale. I’m not sure if just changing timescale will work since the simulation would advance quicker, but not with the same definition. So multiplying timescale and fixedupdate frequency by the same value should work. Untested.
- with my own code, which used the formulas found here: http://freespace.virgin.net/hugo.elias/models/m_snokr.htm
Thanks.
Time.timeScale must be between 1 and 100.