VDB Chinese Chess for Unix
Version 1.0 Revison 11
2. Getting involved
7. Basic rules of chess
8. Rules of Chinese Chess
9. Interface guide
10. Technical explanation of the program
Chinese Chess is a popular Chinese game that has rules similar to ordinary chess.
If you want to get involved in the further development of this program, send me an EMail. EMail address is given at the end of this side
You can download this program using the URL: http://www.vdb1.de/software/cchess1.0.11.tar.gz
Step 1: Make sure that all necessary components are installed!
This program needs:
1. g++: Gnu c++ support including header files
2. xaw3d: 3D-extension for the Athena Widget Set
if you cannot find it you can change xaw3d by xaw in
src/Makefile.in but the program will not look so nicely
3. Standard Template Library
Actually this program will use only one header file
for the function max(), that
returns the maximum of two values. You can implement that yourself.
4. xpm: this is a library for icons in x-
all board pieces are implemented with this library,
this library is very common under X, so it should be
included in your distribution
5. pthread: this is used for multithreading,
sometimes also called pthreads, you might have to change this
in your src/Makefile.in
Step 2:download this program and unzip it in the directory you want to run it.
There is NO separate installation directory!
tar xfz cchess.tar.gz
Step 3: cd cchess_dist/cchess
To start the program you need to type the following:
You can also start the program without "make install"
You cannot install the game
Make sure you have installed all necessary components like
g++, 3D-Athena Widget Set-Library, pthread-library,
development-headers for X-Window programming,
the Standard Template Library.
If you do not have the Standard Template Library you can
define the functions min(int,int) and max(int,int) manually.
If you cannot run the make file successfully you might
have to adjust the path for libraries and headers.
Use the g++-options -Iheaderpath and -Llibrarypath for this.
On some systems the library pthread is called pthreads, so you
might have to change the makefile.
You can install the game but cannot start it
Look at first if you have done everything mentioned under 3.
Start the program from the console because you see any error
messages the program prints before exiting.
Two players play against each other.
There exists pieces in two different colors, in Chess white and black, in Chinese Chess
red and black.
The pieces are standing at the board in specified positions.
The player with the white (red) pieces begins to move a piece.
After him the player with the black pieces moves, then
again the player with the white pieces and so on.
If there is a piece of a different color on the field you want to
move you can remove this piece from the board.
But you cannot strike you own pieces neither can you move
in a way that makes it possible for your opponent to capture your
There are differences how you can move with a piece.
Pieces that have a lot of possibilities to move are more valuable than
pieces with few possibilities.
There are several special situations:
Indeed, Chinese Chess is very similar to Chess but there are some differences according
how to move your pieces on the board and the following:
1. Stalemate: No matter how you move, your king can be beaten in the next move, but if you
would not move at all (what is not possible of course) than your king could not be beaten
2. Check mate: No matter how you move, your king can be beaten in the next move, also if you
would not move at all (what is not possible of course).
The player who is check mate loses.
But there are differences about the effect of stalemate in the games Chess and Chinese Chess.
In Chess, if you are stalemate, nobody wins, it is a draw.
In Chinese Chess you lose.
1. You cannot exchange the pawn against some other piece if you reach the end of the board
2. There is no rochade and moving "en passant"
3. You lose the game also if you are stalemate
4. If both kings are on the same column there must be one piece between them
5. If there is three times the same position because of the same moves you must move different next time
6. The pieces are not black and white but red and black. Red moves first.
There are the following important locations:
The two palaces, each consists of nine fields marked by two diagonal lines.
The river: The area in the middle of the board, that is not interrupted by lines
The pieces on the board move the following way:
King: Can only move one field forward or to the side, not diagonal. Has to stay inside the palace
Pawn: Moves one field forward. If he is beyond the river he can also moves side wards
Rock: Moves one or more fields to the side, forward, backward but not diagonal
Cannon: Moves one or more fields to the side, forward, backward but not diagonal. Must always
jump over one piece!
Horse: Moves one field straight, one field diagonal, cannot move over another piece.
Elephant: Moves exactly 2 fields diagonal, cannot move over the river
Mandarin: Has to stay inside the palace. Moves one field diagonal.
Most of the interface is self-explanatory.
But there are some points that should be explained.
If you play against the computer and want to take back your last move,
it is easier to chose "Move - Last own". This
returns to your last own move.
This program supports "Lazy drag and drop".
If you press the middle button of your mouse,
the icon is glued to the mouse pointer.
You drop the icon with another click on the middle mouse button.
This game is developed with xlib, X Toolkit Intrinsics, Athena Widget Set,
pthread and xpm.
I use also a file selector widget that was not written by myself (FileNom.c).
The pieces on the board are designed as C++-classes.
If you move a piece to the field x,y, you have to call the appropriate piece that it is
supposed to move to the field.
The piece will eventually delete another piece that is located on this position.
For this functionality the class CCounter defines an abstract base class CPlayfield that defines
the methods to draw and delete an icon on the board.
The class CPlayfield is implemented by CBoardview which uses the class CIcon to support drag
and drop and to draw icon on the screen.
The class CBoardview defines an abstract class CGame with
the methods to draw an empty board and to convert a piece value to an icon.
The class CBoardview is derived from this class and implements this methods.
CBoardview may be uses for all board games. It is application-independent.
It defines methods for drag and drop, new drawing of the board, resizing and so on.
The class Ccchess is derived from CGame and is the real application class for this game.
Ccchess contains variables and functions that are important for the game itself not so much
for the graphical interface. Those functions are defined in the file cchess.cpp.
The program starts initially a second thread that calculates the computer moves.
The communication with the main thread is done with pipes.
All files in the directory c++comps/X/extern are not written my myself and
are published with the licence described there!
All other files are distributed under the Gnu General Public License Version 2 (GPL).
Hereby I encourage all people to develop free software since I think
this is a great idea and for the benefit of every person.
Tim vor der Brueck