how does magarena generate a hash for the game state?
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
how does magarena generate a hash for the game state?
by mtgrares » 14 Oct 2011, 16:00
Generating a hash for a Magic game is very complicated and I was wondering how Magarena creates that hash? Which class is the hash code in? What guidelines did you use? Because I know that hash generation can be a deep topic.
Is score caching the same as a transposition table? Sometimes different game states create the same hash but it isn't a big problem.
(From your wiki.)
Is score caching the same as a transposition table? Sometimes different game states create the same hash but it isn't a big problem.
(From your wiki.)
Score Caching
This is a simple but very effective technique. During the evaluation, at the end of certain phases (First Main, End of Combat and Cleanup), a 64 bits game identifier is calculated which reflects the game state at that time. Then a score cache is checked if this state already occurred during a previous evaluation and when it is found the best score for that state is obtained from the cache and must no longer be searched. This technique has however a drawback, namely that different game states can map to the same identifier. During testing the speed benefit was however so significant that this drawback is overshadowed. The score cache is shared between all threads.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: how does magarena generate a hash for the game state?
by melvin » 15 Oct 2011, 02:02
There are two methods of computing the game state hash in Magarena. It turns out that for the minimax AI, it is ok for different game states to have the same hash since the method simply returns the score for game states that have been hashed.
This relaxed game hash is computed in src/magic/model/MagicGame.java getGameId(int) method. Using a combination of the turn no, phase, game score, and hash of each player.
For the monte-carlo tree search, the game hash is used as a key to cache parts of the game tree computed in the previous round. Therefore, it is important that the series of moves from the game state much match the game tree exactly, so two different game states that have the same hash must admit the exact same set of future moves.
This more complete game hash is computed in src/magic/model/MagicGame.java getGameId() method and it makes use of all possible information about the game state that would affect future moves.
This relaxed game hash is computed in src/magic/model/MagicGame.java getGameId(int) method. Using a combination of the turn no, phase, game score, and hash of each player.
For the monte-carlo tree search, the game hash is used as a key to cache parts of the game tree computed in the previous round. Therefore, it is important that the series of moves from the game state much match the game tree exactly, so two different game states that have the same hash must admit the exact same set of future moves.
This more complete game hash is computed in src/magic/model/MagicGame.java getGameId() method and it makes use of all possible information about the game state that would affect future moves.
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: how does magarena generate a hash for the game state?
by mtgrares » 20 Oct 2011, 19:07
Thanks alot.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests