-
Notifications
You must be signed in to change notification settings - Fork 0
Improve MCTS #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve MCTS #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff!
We could also look into trying GRAVE or other algorithms instead of UCT, if we want to try to improve it further.
loafs around
| var minTurnTillWin = rootNode.getChildren().stream().map(Node::getTurnsTillWin).min(Integer::compare).orElse(Integer.MAX_VALUE); | ||
| var bestChild = rootNode.getChildren().stream().filter(x -> x.getTurnsTillWin() <= minTurnTillWin) | ||
| .max((a,b) -> Float.compare(a.getReward(), b.getReward())).orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, this choosing method has a fatal flaw. Consider the following scenario:
MCTS has two monsters and the opponent has two monsters.
Let's say that MCTS's active monster can win in 6 turns by doing continuous small amounts of damage, and MCTS's non-active monster has a move that will cause MCTS to win first turn it's used.. And let's say the opponent's active monster can't really deal much damage to MCTS's active monster, but would deal massive damage to MCTS's non-active monster.
In this case, this new method will be flawed.
MCTS will have the following options:
- Keep attacking with current monster (win in 6 turns, reward=10)
- Change to other monster (win in 2 turns, reward=0)
If you expand the "change into other monster", you'll see the following scenarios:
- The opponent uses the deadly move and MCTS loses (reward -100, win in turns=MAX_INT)
- The opponent switches to it's other monster (reward : +100, win in turns=1)
This would be a terrible choice, because of course the opponent isn't just going to give you a free win. It will try to kill you immediately.
Even through random playthroughs, it'll probably figure out that going down this path is pretty stupid as it looses in most of the time. but since this new system prioritizes "win_in_turns", it will choose this path anyway. So if you purely looked at rewards it would (in this case) do the right thing. But that dons't go for other cases like two gods on a single team.
Back to the drawing boards for new ideas I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverts commit d63dc5a.
Improvements include:
Infinityif the move is too goodKin the custom-battle screen to randomize your monsterWow! That's a lot. And even without dirty hacks to make it work™.