联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

您当前位置:首页 >> 代写Assignment代写Assignment

日期:2019-12-08 07:38

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.

1

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.

2

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 卒/兵

3

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.

4

? 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.

5


版权所有:留学生作业网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。