首页 > > 详细

CS102A留学生讲解、program辅导、Java,Python,C++编程语言辅导讲解留学生Prolog|辅导留学生Prolog

CS102A Fall 2019 Project: Xiangqi (, Chinese
Chess)
Figure 1: Board of Xiangqi
Introduction
Xiangqi is a strategy board game for two players. It is one of the most popular
board games in China. The game represents a battle between two armies, with
the object of capturing the enemy’s general (/).
The introduction of this game below is heavily adopted from the wiki page.
Board
Xiangqi is played on a board nine lines wide and ten lines long. Centred at the
first to third and eighth to tenth rows of the board are two zones, each three
points by three points, demarcated by two diagonal lines connecting opposite
corners and intersecting at the centre point. Each of these areas is known as
palace (). Dividing the two opposing sides, between the fifth and sixth rows,
is river ().
Rules
The pieces start in the position shown in the diagram above. Each player in
turn moves one piece from the point it occupies, to another point. Pieces are
generally not permitted to move through a point occupied by another piece. A
piece can be moved onto a point occupied by an enemy piece, in which case the
enemy piece is captured and removed from the board. A player cannot capture
one of his own pieces. The game ends when one player captures the other’s
general.
Pieces
Each player controls an army of 16 pieces; the armies are usually coloured red
and black.
General /
The general starts the game at the midpoint of the back edge, within the palace.
The general may move and capture one point orthogonally and may not leave
the palace. The two generals may not face each other along the same file with
no intervening pieces. If that happens, the flying general () move may
be executed, in which the general to move may cross the board to capture the
enemy general.
Advisor /
The advisors start on either side of the general. They move and capture one
point diagonally and may not leave the palace, which confines them to five
points on the board.
Elephant /
The elephants are located next to the advisors. These pieces move and capture
exactly two points diagonally and may not jump over intervening pieces; the
move is described as being like the character . Elephants may not cross the
river.
Figure 2: Move of horse
Horse /
Horses begin the game next to the elephants, on their outside flanks. A horse
moves and captures one point orthogonally and then one point diagonally away
from its former position, a move which is traditionally described as being like the
character . The horse can be blocked by a piece located one point horizontally
or vertically adjacent to it.
Chariot /
The chariot moves and captures any distance orthogonally, but may not jump
over intervening pieces. The chariots begin the game on the points at the corners
of the board.
Cannon /
Each player has two cannons, which start on the row behind the soldiers, two
points in front of the horses. Cannons move like chariots, any distance orthogonally
without jumping, but can only capture by jumping a single piece, friend
or foe, along the path of attack.
Soldier /
Each side starts with five soldiers. Soldiers begin the game located on every
other point one row back from the edge of the river. They move and capture by
advancing one point. Once they have crossed the river, they may also move and
capture one point horizontally. Soldiers cannot move backward, and therefore
cannot retreat.
Project Requirement
You are required to form groups of two. Please design and implement a Java
program to simulate the Xiangqi game for two players. Note that the only
programming language you can use in this project is Java. (Scala and Kotlin
can also be accepted)
There are four tasks below to accomplish, each of which has several points
towards the final mark of a group. A framework/skeleton of the game will be
release shortly to facilitate your programming.
Task 1: Initialize the Chess Game (10 points)
• Your program should be able to initialize a new chess game, which includes
all lines and all chess components with correct position in your chess board.
• Your program should can able to display the status of the game (In
Progress, Black Turn or Red Turn).
Task 2: Load and save a Chess game (15 points)
• Your program should be able to load an existing Chess game from a text
file with a pre-defined format by clicking button. After loading, all pieces
should be placed at their positions given in the text file.
• Your program should be able to perform error check, e.g., there must exist
a general for each player, no more than two elephants, etc.
• Your program should be able to save the current Xiangqi game to a text
file. Only the position of pieces and turn of player need to be recorded.
Task 3: Play the Xiangqi game (35 points)
• Your program should let the player to move all chess pieces following their
own movement rules described above.
• Your program should allow pieces to capture other pieces.
• Your program should be able to load an expected moving steps from a text
file (according to the test case) by clicking button. After loading, it can
process the game in background automatically, and in the chess board,
only display the final result is enough.
• Your program should detect the winning status of either player, and end
the game when the winner is determined.
Task 4: Graphical User Interface (20 points)
• Your program should have a graphical user interface using Java Swing.
(FX can also be accepted)
Bonus (20 points)
If your program satisfies all the above basic requirements, you will get 80 points.
The remaining 20 points will be given as bonus. You are highly encouraged to go
beyond our requirements. Below are some possible ways to get bonus. Compare
to the bonus points, the basic points are easier to get. Here you need to rely
on your own ability to present your programming charm!
• Design Human vs. Machine Mode, and make the machine player smarter.
• Design a platform for your game, such as adding multi-user, multi-loading,
ranking list, adding start menu for selecting the game modes. etc.
• Make your game looks nicer, such as change the theme, adding sound
effect, adding background music, adding more prompt label when the
game is in process.
• Show possible moves when a chess is selected.
• Show a check warning when the kings are threatened in the next move.
• Play animations of chess movements from one place to another, play the
process of moving chesses after loading the “moving steps file”, playback
the process of the battle.
• Undo operation.
• Support on-line mode in Local Area Network.And more.

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!