I'm not sure if I will able to put it in a sensible way.
I'm trying to write an easy non-graphical game. User will play a dice game against the computer.
(To be more specific, this game: The object of the jeopardy dice game Pig is to be the first player to reach 100 points. Each player’s turn consists of repeatedly rolling a die. After each roll, the player is faced with two choices: roll again, or hold (decline to roll again).
- If the player rolls a 1, the player scores nothing and it becomes the opponent’s turn.
- If the player rolls a number other than 1, the number is added to the player’s turn total and the player’s turn continues.
- If the player holds, the turn total, the sum of the rolls during the turn, is added to the player’s score, and it becomes the opponent’s turn.)
I wrote the program but now I want to do it in object-oriented way. This is my problem:
I have an abstract Player class. Human_player class and Computer_player class extend the Player class. Another class, called Game_Controller, controls the flow the game. Say that Computer_Player has a certain strategy, that unless the "initial total" is less than 20, he keeps rolling the dice (which means that he is in a certain loop). On the other hand, the Game_Controller keeps rolling the dice for the Computer_Player as long as he wishes and as long as he can (which means that that part of the program is in a certain loop). So when Computer_Player rolls "1", Game_Controller gives the turn to Human_Player. How do I make the Compter_Player end his loop?
Moreover, I'm having difficulty at implementing the Computer_Player as a concrete player (because I'm new at programming, and I'm especially new at this kind of interaction). What's the proper way of handling this?---That is, the Game-Controller class interacts with Computer_Player class and Computer_Player class interacts with Game_Controller class.
Thanks for sparing your time.
Edit 1: Is there good source (website, book) on this type of stuff? I'm not looking for those advanced game-programming sources, just easy and fundamental stuff.