CS 340 - Software Design

Machine Problem 5, Spring 2012

Mancala Networked

Due: Thursday, April 26, 2012 at 11:59 pm

For this project, student may work with one other person on this project. Each group should only turn in one version of their project. Be sure to clearly identify all members of the group in a README file.

Mancala - Networked Version

For this project, you are to make a version of the game Mancala that can be played by two people across a network. Each GUI should support one person playing the game and allow connections to join with a second person and allow for interactive game play between the two players.

This project must make use of a menu. Items in the menu must include:

  • An About Menu Item - this will display a window/dialog box with information about the development team and the product.
  • An Exit Menu Item - this will cause the application to terminate.
  • A Help Menu Item - this will display information about how to play mancala and how to use your program.

  • A Top Scores Menu Item - this will display a window/dialog box with information for (at least) the name of the winners of the 5 best scores encountered by the program. When a top score is encountered, prompt the winner for a name to be saved by the program.

  • Game Play Mode Menu Items

    This will include any items needed to make the connection between two players. We will assume that one player will act as the server and the other player will act as the client. Somehow the players know who will be the server and who will be the client. It is assumed that the server is on a "well known ip address and port" so the client just knows what information to use to conntect to the server. The client will be prompted to enter in this information to the program.

    Note: the same program is to be used for both the Client and Server program. By selecting the Server Mode, the program becomes the Server for the application. By selecting the Client Mode, the program become the Client for the application.

Your program should/must include other menu items as needed (Quit, for example!). Your Help menu should be able to give help not only on the game play, but also on how to connect to the network.

Mancala

For this project you are to implement a GUI two person version of the game Mancala (note: I have no idea why the game is on the web site for the AFL-CIO.) Since the game of mancala does seem to have many variations, we will use the information supplied by this web page as the "official rules" for mancala. The rules on that page reflect the most common rules for the game and the discussion of the game below (are intended to) follow those rules.

The game for Mancala consists of 2 "mancalas", 12 cups and 48 stones. Each player has control of 1 mancala and 6 cups. The game board is laid out as follows:

Player 2
Mancala
Player 2
Cup #1
Player 2
Cup #2
Player 2
Cup #3
Player 2
Cup #4
Player 2
Cup #5
Player 2
Cup #6
Player 1
Mancala
Player 1
Cup #6
Player 1
Cup #5
Player 1
Cup #4
Player 1
Cup #3
Player 1
Cup #2
Player 1
Cup #1
The game is started with have 4 "stones" in each of the 12 cups. Thus the board will look as follows when the game starts:
Player 2
Mancala
0 Stones
Player 2
Cup #1
4 Stones
Player 2
Cup #2
4 Stones
Player 2
Cup #3
4 Stones
Player 2
Cup #4
4 Stones
Player 2
Cup #5
4 Stones
Player 2
Cup #6
4 Stones
Player 1
Mancala
0 Stones
Player 1
Cup #6
4 Stones
Player 1
Cup #5
4 Stones
Player 1
Cup #4
4 Stones
Player 1
Cup #3
4 Stones
Player 1
Cup #2
4 Stones
Player 1
Cup #1
4 Stones
The goal of the game is to get more stones into your own mancala than the other player can get into his/her mancala by the end of the game. It is possible to end the game in a tie. This is when both players have 24 stones in their mancalas a the end of the game.

On a player's turn, the player selects one of his cups that has one or more stones in it. All of the stones in that cup are removed and they are placed one-by-one going counter-clockwise around the board into the cups or the players own mancala. A player never places a stone into the other player's mancala.

Assume that a player has 12 stones in cup #3. If the player were to select that cup on his/her turn, the player would then:

  1. place one stone in his/her cup #2
  2. place one stone in his/her cup #1
  3. place one stone in his/her own mancala
  4. place one stone in the oppenent's cup #6
  5. place one stone in the oppenent's cup #5
  6. place one stone in the oppenent's cup #4
  7. place one stone in the oppenent's cup #3
  8. place one stone in the oppenent's cup #2
  9. place one stone in the oppenent's cup #1
  10. place one stone in his/her cup #6
  11. place one stone in his/her cup #5
There are two special cases that occur when the last stone from a cup is placed.
  1. If the last stone from a cup gets placed into the player's mancala, the player gets another turn.

  2. If the last stone from a cup gets placed into one of the player's own cups that is empty and the opponent's cup directly across from that empty cup is not empty, the player then captures all of the stones in opponent's cup plus the one stone placed in the player's own cup. All of the captured stones are then placed directly into the player's own mancala.

    For example assume the board is as shown below and it is Player 1's turn:

    Player 2
    Mancala
    18 Stones
    Player 2
    Cup #1
    1 Stones
    Player 2
    Cup #2
    1 Stones
    Player 2
    Cup #3
    0 Stones
    Player 2
    Cup #4
    5 Stones
    Player 2
    Cup #5
    1 Stones
    Player 2
    Cup #6
    0 Stones
    Player 1
    Mancala
    14 Stones
    Player 1
    Cup #6
    3 Stones
    Player 1
    Cup #5
    1 Stones
    Player 1
    Cup #4
    0 Stones
    Player 1
    Cup #3
    0 Stones
    Player 1
    Cup #2
    2 Stones
    Player 1
    Cup #1
    2 Stones
    If Player 1 selected Cup #6, the last stone would end up in his/her Cup #3 (which is empty) and a capture would occur. The 5 stones in Player 2's Cup #4 plus the last stone which ended up in Player 1's Cup #3 would all be placed into Player 1's mancala.

    If Player 1 had selected Cup #5, the last stone would have ended up in his/her Cup #4 (which was empty). A capture would not have occurred since Player 2's Cup #3 was also empty.

    If player 1 had selected Cup #1, the last stone would have ended up in an empty cup, but no capture would occur since it was Player 2's empty cup.

The game is over when all of the cups of one of the two players have no stones in them at the end of the player's turn. Any stones left in the other player's cups are immediately moved to that player's mancala.

Project "Animation"

When a player's stones move around the board, they cups must be updated in a manner that shows animation of the placing of the stones in the various cups. Toward this end there ust be a slight pause between updating of the cups. Thus when moving the stones from cup #6 in the following example, the following steps should occur in this given order:
Player 2
Mancala
18 Stones
Player 2
Cup #1
1 Stones
Player 2
Cup #2
1 Stones
Player 2
Cup #3
0 Stones
Player 2
Cup #4
5 Stones
Player 2
Cup #5
1 Stones
Player 2
Cup #6
0 Stones
Player 1
Mancala
14 Stones
Player 1
Cup #6
3 Stones
Player 1
Cup #5
1 Stones
Player 1
Cup #4
0 Stones
Player 1
Cup #3
0 Stones
Player 1
Cup #2
2 Stones
Player 1
Cup #1
2 Stones
  1. The number of stones shown in Player 1's cup #6 changes to 0
  2. The number of stones shown in Player 1's cup #5 increments by 1
  3. The number of stones shown in Player 1's cup #4 increments by 1
  4. The number of stones shown in Player 1's cup #3 increments by 1
  5. The number of stones shown in Player 1's cup #3 and the number of stones shown in Player 2's cup #4 are both changed to 0
  6. the number of stones shwn on Player 1's Mancala increaments by 6
You can implement this "slight pause" by using the QTimer class in Qt. The exact length of the pause is left up to you, but use a 1/4 of second as a starting point. Note the timing of the pause is fairly important. To short of a pause and the animation won't be visable, to long of a pause and the animation gets annoying.

General Comments

Your program should make sure that only one player can move at a time and that the player's take turns according to the rules of the game. The use of the status bar is a good way to inform the users whose turn it is.

The game needs to determine which player will start first. Also nothing is stated about what to do once a game is over. Ideally, you should ask the players if they wish to play again.

The "Top Scores" can be indicated in any method you like. The two most common ways of doing this would be to see who have the most stones in their Mancala at the end of the game or who won in the fewest number of turns.

Extra Credit

We will allow the following options for extra credit. They are each indpendent of each other. Thus earning the extra credit for one item does not depend on earning extra credit on any other item. In your README file, you must clearly state which extra credit options (if any), your projest is attempting to complete.

For 10 pts extra credit, you can add an additional playing mode to the game. This would be for a single user to play again an AI computer opponent. The computer's AI algorithm needs to be explained in the README file for the project. Also, the AI algorithm must be more than just randomly selecting one of the six cups to use. The AI algorithm should try to make some intelligent choices such as:

  • Making a capture when possible
  • Avoiding being captured
  • Trying to get the last stone into the Mancala to allow for another turn
For 5 points extra credit, you can add an additional playing mode to the game. This would be to allow 2 users to use a single user interface to play the game. Thus you would need to clearly identify which player has the current turn.

For 5 points extra credit, you can add an Undo button to your code that will allow the last move to be un-done. You should allow multiple clicks of the Undo button to undo multiple moves. Note that this button doesn't need to be implemented on all game playing modes. So be sure to inform the TA via the README under which mode(s) the Undo button works.

Comments and Submission for Project 5

Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.

The work you turn in must be 100% developed by your own team. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to any other person outside of your team nor may you look at any other person's written code.

Submit the project via the submission link in Blackboard. Only one submission is to be made per team.

Topic revision: r1 - 2012-04-12 - 03:22:41 - Main.troy
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF