Transcript Checkers

Checkers
A Matlab Project by
Spenser Davison, Edward Dyakiw,
Justin Pezzi, and Scott Wu
Checkers - Defined



Alternating turns, move
your piece
Jump over opponents
piece if there is space
Reaching the end of the
board grants kings


Kings can move in any
direction
Remove all of your
opponents pieces to win
Checkers – Problems




It isn’t as simple as that when coding.
One must design everything from the ground
up.
Assume the player doesn’t know how to play.
Translating the rules was our toughest
challenge.
Checkers – Tasks

Draw the board



Construct a logical
sequence of events


Fill in spaces
Place checkers
For each player
Checking for human
errors

Based on rules we defined
Checkers - Solutions

Drawing board



Plotted horizontal and
vertical lines
Filled in black in
appropriate boxes
Made a checker



Drew a circle
Filled it either black or red
Each having a unique
handle
Checkers - Solutions

Sequence of events



Draw the checkerboard
Give instructions
Prompt a player to move

Check if that move is legal





Checks if king or not
Change the invisible board
based on new information
Visually make the checker
move/jump
Check for a winner
Ask to play again?

Repeat or End program
Checkers - Solutions

Checking for human
errors








Moving out of bounds
Moving horizontally
Moving vertically
Moving on top of another
piece
Selecting incorrect piece
Moving in wrong diagonal
direction
Moving too many spaces at
one time
Not moving at all
Artificial Intelligence


Objective: Create a computer
player for single player games.
Major Tasks:
 Locate
all available pieces.
 Identify free pieces for use.
 Execute required moves (jumps).
 Assign scores for different moves.
 Select best move and execute.
 Prevent invalid moves.
Artificial Intelligence

Solutions:





Cycle through board and
append an array with location
of AI’s pieces.
Cycle through array of
locations and eliminate all
pieces without available
moves.
Cycle through all pieces and
executes any possible jumps
from piece.
Cycle through remaining
pieces and assign separate
scores for left and right.
Cycle through list of scores
and execute move with largest
score.
Return
Best
Move
Receive
Board
Variable
Assign
Scores
Find All
Pieces
Check
Moves
for a
Jump
Find
Pieces
with
Moves
Checkers Program Basic Flowchart
Display
Instruction
s
Setup
Board
How many
Players?
1
Who goes
First?
2
Reset Board
Computer
Who’s turn is it?
Terminate
Program
Is there a
winner?
Player
Yes
Get AI Move
No
Yes
Get Move
Play
Again?
Yes
Valid Move?
Print Winner