468,469 Members | 2,212 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,469 developers. It's quick & easy.

Game Trees for Simple games

Hello, i have a question about game trees. I've been given an assignment in class (highschool) and the assignment is to write a program the simulates The Game Of Eight. The game runs like this:

player gets a choice to go first or second
player picks first
player can choose either 1 2 3
player picks 1
// computer now has 2 choices 2,3
computer picks 2
//player can now pick 1,2 or 3 again
etc.

So the game flow is player picks - computer picks - player - computer - etc. until someone reaches or exceeds the number 8. if the user or computer goes over then the other opponent wins. If someone gets 8 exactly then that player wins. Now the actual question: I want to use a game tree to represent the possible ways the game could go, and then have the computer player use that to decide it's move. The problem, I have no idea how to implement tree's in C++.
Well, i have a little (very little) knowledge of how a minmax type tree works and I know it best suits games where the entire board is known to both players like in chess. Would this be the best choice of tree to use? should I use another approach (different type of tree)? If I should use an alternate approach then what are some resources that I can look at for some guidance? If I should use another approach then can someone explain that method to me in simple terms. I don't want any source but simple written explanations would be very much appreciated. Please let me know if more info is required.

thanks.
Nov 28 '07 #1
1 2036
weaknessforcats
9,207 Expert Mod 8TB
The problem, I have no idea how to implement tree's in C++.
The trees aree already coded if you use the standard containers like map or multimap.
Nov 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by me | last post: by
reply views Thread by Jeff Rush | last post: by
14 posts views Thread by v4vijayakumar | last post: by
6 posts views Thread by pereges | last post: by
7 posts views Thread by Benjamin Vigneaux | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.