Tree Data Structures & Minimax Algorithm for Games

AI Thread Summary
The discussion centers on using tree data structures and the minimax algorithm to analyze a game involving sticks, where the objective is to avoid being the player who removes the last stick. It is noted that if both players play optimally, the game can only end in a win for Player 2 when starting with multiples of 5. The misunderstanding about the game ending in a draw is clarified, emphasizing that the player who removes the last stick wins, except in specific scenarios. The analysis suggests that players should aim to leave their opponent with a number of sticks that is a multiple of 5. The conversation highlights the importance of backward analysis in determining winning strategies in such games.
wololo
Messages
27
Reaction score
0

Homework Statement


Capture.PNG


Homework Equations


Tree data structures.
I think it might also have something to do with minimax algorithm, but it was only mentioned once and never discussed extensively in class so I doubt it is required.

The Attempt at a Solution


[/B]
If both players play as well as they can, the game will end in a draw. Player 1 will always have the option of choosing to draw rather than lose.
Capture.PNG

However I can't find a function that given n sticks will tell me who will win. For 5, 10 and other multiples of 5, player 2 necessarily wins but what about the other cases? How can I find a single formula that will necessarily tell me who will win, given that they play well?
 
Physics news on Phys.org
Misunderstanding: you can't end in a draw.
 
BvU said:
Misunderstanding: you can't end in a draw.
"The player who removes the last match wins, except if there is only one match left, in which case the game is a draw." All the paths that end in 1 in the game tree are draws.
 
Oops, sloppy reading... o:)
I remember something about analyzing games like this: start from the end situation and work backwards...
Your "multiples of 5" points that way. So player 2 will always work towards multiples of 5. So will 1. That way you have pinned down "playing well". Apparently you really want the other to start when playing this game, unless n is a multiple of 5 plus 2 or 3.
 
Back
Top