1
\$\begingroup\$

I have been making a turn-based board game in UE4 and have come to the point of making a first pass on the AI. I planned to use Monte Carlo Tree Search but this requires you to make (at least) one copy of the game state for each simulation. I am guessing that I will have to do hundreds of simulations per move.

I am fairly new to UE4 but the problem is that there isn't really a separation between view and logic (at least the way that I have programmed it!). For example I have actors which contain their static meshes, current material etc as well as their logical state. I think in UE4 to create a real deep copy I would have to spawn new actors etc. Obviously in hindsight I have made a big mistake and should have realised this earlier so that I could have switched to a different engine, but too late for that now.

Neither of the ideas that I have come up with are good:

1) Implement a special copy function which sets the static mesh etc to nullptr. I am not sure how Unreal will react to creating all of these actors but not spawning them in the level, my experience up to now suggests not well.

2) Make AI versions of all classes e.g. an AIUnit class which can be constructed from a normal Unit class but only initialises the minimum required data. I think this would work but it would be painfully inelegant with the obvious downside that I will essentially have to maintain two almost identical games and keep the rules in sync.

MCTS with UE4 doesn't seem to have many hits on google so any advice would be appreciated, I am willing to sacrifice some dead time e.g. wait 1 second every turn for AI "thinking" time.

\$\endgroup\$
  • \$\begingroup\$ Haven't messed with unreal much, but couldn't option 2 have the AI classes contain the base logic needed, then the normal classes extend those? \$\endgroup\$ – phflack Jun 26 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.