4/4/10
Rule implementation (3)
So far, basic game rules have been completed. I used word "basic" which means two players actually can play the game together now. For example making a piece move one by one, changing game options, etc. I expect these rules work well. If it's necessary(maybe exist few logical bugs somewhere), I'll modify or add some rules later.
3/29/10
Game option & rule implementation (2)
An option item is added to game menu. The option dialog will be set visible when player click the option menu item. There are three game options:- Show move hint - when player pick a piece, the board shows circles that indicate possible moves for the piece.
- Rotate board - in order to give player a clear view, the board automatically rotates on y-axis with π angle after each move. This option is only valid when two players play the game.
- Play sound - after player made a move, an action sound is played.
So far, rules for horse and chariot are done.
3/21/10
Limited undo & rule implementation (1)
As mentioned few days ago, it's not a good idea that allow players to undo each move they made. Since Java doesn't support infinite memory allocation neither other languages. Thus, I modified a piece of code, then each player only can undo 10 previous moves from now on.
Here is a link to Wikipedia page that talked about Xiangqi including its rule. I need to make a statement about rule of General. The original text is:
The general starts the game at the midpoint of the back edge (within the palace). The general may move one point either vertically or horizontally, but not diagonally. A general cannot move into a file which is occupied by the enemy general unless there is at least one piece positioned between the generals in the file. The general may not leave the palace.
In fact, in Chinese version of the rule, two generals may face to face. But, in such case, one general can leave the palace and attack another general directly. In other word, a general can move into a file which is occupied by the enemy general. In this case, the enemy general can attack your general directly. So, when you try to make a general move, be careful this case. In my implementation, I'll follow Chinese version of the rule for generals.
Above figure shows possible moves of red general. Since both right and left sides of the red general are red guards. Thus, its possible moves are one point forward and the black general's position.At this point, rules for general, guard and elephant are done.