P2 Eng
P2 Eng
Project report:
the apple chess
program
P2
The Objective
7.) If no legal move is available for a player, that player must pass the game
to the other opponent.
8.) Game ends in either condition:
i.) If no legal move is available for both players, it is a draw game.
ii.) All positions are occupied.
A B C D E F G H
1
2
3 *
4 O X
5 X O
6
7
8
Using this system, the program will prompt the user for moves
using this index. For instance, if the user would like to place a
disc on the * position, the user can enter D3.
P2
Implementation
Choosing the Right Language
To realize the design, I must choose a media and a
programming language that is suitable for this project. Here is
the list of some possible solutions.
User input
A B C D E F G H
1 0
2 1
3 * 2
4 O X 3
5 X O 4
6 5
7 6
8 7
0 1 2 3 4 5 6 7
Array Indexes
The Flipping
At first glance, the flipping business may seem to be simple, but
it turns out that it is somewhat complicated.
The program will check for all 8 directions, each direction has its
own function, these functions will check:
Program Starts
Collect user
information
Game Starts
No
User is black
Yes Yes
Place the disc
on the board
Check Flipping
Switch User
Compilation:
Linux
In Shell, execute the following command:
# gcc othello.c –o othello
(if gcc is not installed, please read the linux distribution’s
manual.)
Windows
Obtain any C/C++ compiler from the internet, and follow the
instructions.
Installation:
No installation is required.
Windows
In MS-DOS, MS-DOS mode (Windows 95/98/ME), or command
prompt (Windows 2000/XP).
Type :
C:\theDirectoryYouStoredIt>othello.exe
P2
Playing the game
Please enter two names at the beginning of the game.
Player 1 will take the black discs, player 2 will take the white
ones.
Pass
This is a situation where player 1 doesn’t have any valid move and
he needs to pass this game to his opponent, player 2.
As you can see, the program successfully passes the game when a
player runs out of moves.
P2
Draw
This is a situation where both players possess the same number of
discs at the end of the game.
Win
There is always a winner in a game. So after each game ends, the
program must determine which player is the winner. It would count
both players’ discs on the chess board to see which of them got
most discs.
Discussion
After all, I admit that this program is a very immature one. It
has no A.I. capabilities, no network capabilities, not much of a
friendly user interface. Here are some features that I could have
done to enhance user experience and improves the program in
general.
A 1-player game
After all, it is quite pointless for two people to sit behind the same
computer to play one chess game. When there is no one around
that you can play the game with, people wouldn’t prefer to play
with themselves since this chess game is sometimes an intellectual
battle between two minds.
So the simple solution is to create a virtual opponent for the user.
We could have had the computer to follow a certain strategies, so
that it would appear to the player that the virtual opponent is a
human player, flesh and blood.
Of course we could have let the player to decide the difficulty of the
game, let them control how tough the virtual opponent would be.
We could also let them to undo there moves or the computer’s
moves, to let them learn from there mistakes. But as I am not
really a Othello master, I cannot set strategies and rules of
engagement for the program to follow.
P2
An Online game
As the internet has become a world full of such diverse culture and
entertainment, why not add this game to the list? We could have
allowed users to connect to other players using IP addresses. We
could even have written a server program to accept a number of
players as a directory service, to provide a place for users to meet
other players. But as I am not quite familiar with networking in
programming, I chose not to write such code.