Joh
Member
So I built an AI for a card game, It essentially simulates all possible moves, then simulate opponent for as deep as desired.
Problem is run time of course. Such a kind of simulation is exponential and just very intensive. I would like for it to be seamsless because the environment animates and a freeze is a bad look.
At first I was using a recursion based approach:
So I thought of creating a "manager" that gather all the states and can linearly launch their execution. (scores are recursively propagated up at the end)
Clear advantage is now it doesn't have to fully run in 1 step.
My great disappointment is it still dips framerate/performance.
Now instead of freezing until all recursions are done, it slowly runs slower until all states are done.
The approach is still flexible though, so I was hoping there was a way to minimize impact?
Anyone ever dealth with state tree AI? Anyone has an idea on how to best spread to load?
Thanks
Problem is run time of course. Such a kind of simulation is exponential and just very intensive. I would like for it to be seamsless because the environment animates and a freeze is a bad look.
At first I was using a recursion based approach:
- duplicate state
- perform move
- simulate that new state. (recursion)
So I thought of creating a "manager" that gather all the states and can linearly launch their execution. (scores are recursively propagated up at the end)
Clear advantage is now it doesn't have to fully run in 1 step.
My great disappointment is it still dips framerate/performance.
Now instead of freezing until all recursions are done, it slowly runs slower until all states are done.
The approach is still flexible though, so I was hoping there was a way to minimize impact?
- Iter high: If i make many (1000) states simulation per step, it freezes (becomes like recursive approach)
- Iter low: If I make it 1 state per step, it doesnt freeze but gradually slows down to a crawl.
- spread: I made it so I could spread the steps: (run simulations every X steps) and that limited how slow it could get. but selecting the move takes noticable time.
- steptime: I also have time breaks using current_time, automatically breaks out if simulation ran longer than 100ms in one step. <- is that too much?
- fulltime: I also have a break and play once the total move selection time is too long, but I'd rather it was never needed.
Anyone ever dealth with state tree AI? Anyone has an idea on how to best spread to load?
Thanks