Skip to main content
GameDev.net gamedev.net
🔒 Locked

is my minmax tree correct?

Started by cignox1 Jul 15, 2004 at 2:00 AM 7 replies 1.8k views
Original Post
cignox1
cignox1
Hi, I've just implemented a minmax tree for a simple game. The game (in italian named "massa critica") behaves as follows: -an initially empty 6x5 board. -in turn, both players put a disc on the board. If at a certain point there are 5 discs in the same cel, then it explodes and the discs are distribuited in the surrounding cels. If one of them is occupied by opponent discs, they are converted into players one. -If the board is occupied by the discs of the same player, then the game ends, and the player wins. My problem is that my minmax tree (depth = 3) always choses the first cel of the board (coords (0,0)). If this is occupied by opponent discs, then the first empty cel in the same column is choosen (0,x) and so on. I don't know if this is the correct behaviour, or if there is an error: how can I check it up? Thank you all and sorry for my bad english
OmniBrain
OmniBrain
Probably this is an issue of your board value function.

probably fields with influence from two players don't get that much bonus as a field just for your own. (So fields occupied by enemy pieces get some malus)

If all moves have the same value (unoccupied fileds), minmax tends to pick the first move (or the last, depends on compare-condition) that your move generator provides. (And I guess your move generator simply iterates through all fields on the board).

You can change this by simply adding a small random number (in chess like 0..1 while a pawns value is 100)

hope this helped some.
-----The scheduled downtime is omitted cause of technical problems.
cignox1
cignox1
Thank you for replying... Yes,the function that estimates a value for a given game state is very simple (read: trivial): I don't know if I can add a random value (it's for a university project...). Now I will change to an alpha-beta version, then I'll try to correct this, even if I really have no idea about what function to use.

>>(So fields occupied by enemy pieces get some malus)

Yeah, sorry, I didn't explained it well: opponent fields cannot be used by the player. A player can choose only from empty fields...

Thank you again
alvaro
alvaro
A random evaluation function is better that no function at all. In this game, it looks like having more pieces of your color is advantageous, so I would use that in the evaluation function too.

How would you play as a human? Try to gain some knowledge of the game and then represent it as terms in the evaluation function.
cignox1
cignox1
Yes, having more pieces is better. And stacks of pieces are also important, since at the critical level they explode 'conquering' sourrounding fields (and enemy pieces, if present). But these are the only strategic relevant informations: it seems to me that having a decision tree that uses a random function to evaluate the leafs is almost useless... (tell me if I'm wrong, I don't know AI).

The important thing is that my minmax tree works.
cignox1
cignox1
Well, I've found an applet that does right this job. I've discovered the english name of the game (critical mass, but there are also other names) and from the source I should be able to figure out how to build this function...

alvaro
alvaro
Having a search tree with a random evaluation function is not completely useless. In particular for the game of losing checkers, I don't know of any better evaluation functions. Even with random evaluation functions, a tree searcher will avoid mates that it can see, it will give mate is possible, and there is some vague dynamic version of mobility that the search with random evaluation funtion captures.

It's a little hard to explain, but think about a position where there are many branches that end in winning the game. You have two moves: A and B. Move A leaves the opponent three moves with which he can avoid mate, while move B leaves the opponent only one move with which he can avoid mate (within the depth searched). The minimax algorithm will select move B most of the time if a random evaluation function is used.

I would suggest that you try to implement minimax yourself for this particular game, get it working and try to improve your evaluation function before you look at anyone else's code. Once your program works, you can look at the code of that applet and you'll probably learn a lot by seeing how other people have solved the same problems that you have solved before. Just my personal opinion, though.
cignox1
cignox1
Hi alvaro, thank you for the explanation...now I understand how can a rondom function be used. Yes, You've right, I should build the function alone, before looking at the code of others... but I have just two days to finish :-(
More than that, building a heuristic function for games like this means a good knowledge about the game itself.
Using the function I've found, my program always wins. A random function is used to select a move in case there are many with the same score.
Thank you again for the help
Best regards,
Alessandro
julesh
julesh
If you're worried about the validity of doing it, breaking ties by choosing a random winner is traditional in AI. It has become a very respected technique over the years. Consider this: which is easier to beat in the long run, a player that always does the same thing in the same situation, or a player that often chooses different moves?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.