4.) Problem Solving Essay [____ / 25 Points]

Part 4 requires you to demonstrate your understanding of problem solving by discussing the design, coding, and testing of a program. Keep your answers concise and to the point. If you wish, you may list or outline the significant points you wish to make rather than writing long winded paragraphs in an essay form. For each part several questions are provided to stimulate your thoughts but they are not necessarily all that you should write about.

Mancala is an ancient African two player game that is played by moving stones to different pits on a board. The board consists of two rows of six pits capped on both ends with two larger pits called mancalas as illustrated below:
The pits on the bottom row and the mancala on the right belong to player 0 and the pits on top row and the mancala on the left belong to player 1. The board contains 48 stones (black dots above). Initially the stones are arranged with four stones per pit and the mancalas are empty as shown. The object of the game is to capture more stones than your opponent. The following four simple rules describe the game and are written assuming you are a player:

a.) [____ / 10 points] Design: Describe your design of a program that allows two players to play Mancala on a computer. In your description address concepts of program design such as problem decomposition using top down design and modularity. Show your program's algorithm including sufficient but not excessive detail (i.e. what does your program need to know and do and in what order?)
 
The following algorithm is mainly written in the main function, however
most subtasks are implemented in seperate functions.  To use top-down
design, we would write the basic steps in to main, and implement the functions
as stubs.  Completely the program would involve fully implementing the stubs.

1) Create Board
2) Explain Game to User(s)
3) Player 0 moves
        3a) Prompt & get move
        3b) Check for legal move (a function), if illgal goto 3a
        3c) move peices (a function)
        3d) check for extra move (a function), if true, goto step 3
        3e) check for capturing other players stones (a function), if true, 
                update Player 0's mancala & opposite pit
4) Is the game over?  (a function) Goto step 7
        4a) if all Player 0's pits are empty
5) Player 1 moves
        5a) (same steps as player 0)
6) Is the game over?  goto Step 7
        6a) if all player 1's pits are empty
7) End Game, declare winner
        7a) Move all leftover stones into winners mancala
        7b) the player with the most stones wins.

b.) [____ / 8 points] Coding: Discuss the implementation of your design. How would you represent the various aspects of the game? What coding constructs would you use in your implementation? What are some of the coding details that would be most challenging to implement?
 
Board would be a 1D or 2d array of integers.

Do-While/While loop for parts 2 -> 6.   (2 points)
Functions for:
         Player movement               
         movement of peices
         checking for legal moves
         checking for end of game
         
The most challenging section of writing the code would be the movement.
        Why? Because:
        Which mancala to skip when moving peices around the board?
        How to go "around" the board? 
        How to detect for extra move?
        How to detect capturing?

c.) [____ / 7 points] Testing: Describe the issues of testing your program. What tests would you use to verify that your implementation works as specified? How would you organize the work of testing your program? What specific potential problems could you foresee and how would you test your program to insure that they don't occur in your code?
 
In general, use drivers to test seperate functions.

Start with movement, and check that all possibilities work. 
        - Given several different boards, use a driver to feed the movement function
          many possible moves in an attempt to break it.  This is 
          probably the toughest part.
        - Should reject illegal moves

Next, add on checking functions
        - check if capture occurs
        - check if player gets another turn

Next, set up program for "interactive mode"
        - must also check for player ending game

Lastly, test the ending game function.