Lab 5: Checkers
In this week's lab you must write a C program to display a checkers board using a 1-D array. The board will allow players to move their pieces forward, but does not need to handle jumps and capturing. Pieces will either be 'X' or 'O' depending on side, blank spots on the board will be '.', and spots that can be legally moved to must be '-.'
The execution of the finished program should look like what is shown below. (User input is shown in bold, though in your program it will not be bold.)
Welcome to Checkers.
--------------
Board is:
A B C D E F G H
X . X . X . X . 1
. X . X . X . X 2
X . X . X . X . 3
. - . - . - . - 4
- . - . - . - . 5
. O . O . O . O 6
O . O . O . O . 7
. O . O . o . O 8
Please enter the current position and desired position of the piece to be moved: A3B4
--------------
Board is:
A B C D E F G H
X . X . X . X . 1
. X . X . X . X 2
- . X . X . X . 3
. X . - . - . - 4
- . - . - . - . 5
. O . O . O . O 6
O . O . O . O . 7
. O . O . o . O 8
Please enter the current position and desired position of the piece to be moved: A6C5
Stage 1 (1 point):
Using a 1-D array (Not a 2D array!), represent and print out a 2D checkers board. Have '.'s for empty spaces that players cannot move a piece to, and have '-'s for empty spaces a player could eventually move a piece to. Remember, you can only move diagonally in checkers so every other space (in any direction) should be a '.'. Example:
- . - . - . - .
. - . - . - . -
- . - . - . - .
. - . - . - . -
- . - . - . - .
. - . - . - . -
- . - . - . - .
. - . - . - . -
Stage 2 (1 point):
Add the 'X' and 'O' pieces to the board and allow for movement. You do not need to enforce turn order, nor do you need to make sure the moves are valid. Print out letters and numbers as shown in the first example to help players know what input to give.
Stage 3 (Extra Credit) (1 point):
Validate moves so that no illegal moves are allowed. You still do not need to enforce turn order.
Notes:
Keep in mind that this is a team effort so you should agree with your partner on what you are going to do before you start typing. The partner who is typing is the "driver" and the partner watching is the "navigator." Be sure to switch roles every 10 to 15 minutes, to foster a deep understanding of the code for both partners. The navigator should be watching for syntax errors and verifying the correctness of the code you're writing.
It will speed things up for you if you keep a window open for editing and have a separate window open for compiling and running your program. Remember that windows are resizeable!
Submission:
You should work with a partner for a grade. Only one submission per group is necessary, but be sure to include your name if you work alone, or both people's names if you worked with a partner.
You should submit the lab to the Blackboard at the end of the lab session, by 50 minutes after the hour.