CS102A Fall 2019 Project:

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

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或 微信:codehelp

原文地址:https://www.cnblogs.com/bizhui/p/12020213.html

时间: 2024-12-21 21:41:41

CS102A Fall 2019 Project:的相关文章

22C4400 – Database Systems Project

22C4400 – Database Systems Project – Initial 1/28/2019Project ScopeRaman Aravamudhan RSA-22C4400-S19-PROJECT-SCOPEDepartment of Computer Science Page 1 of 5 Version 1.1Note: This document is intentionally incomplete and is in non-standardformat; as p

CS 100 Project Five

CS 100 Project Five – Spring 2019Project Overview: In this project, you will write a program to solve a simple word search puzzle. The puzzle willbe saved in a file, and the filename will be provided as a command-line argument to the program. The pro

STAT 385 Fall

STAT 385 Fall 2019 - Homework Assignment 03Due by 12:00 PM 10/13/2019The Homework ProblemsBelow you will find problems for you to complete as an individual. It is fine to discuss the homework problems with classmates, but cheating is prohibited and w

COMPSCI 671D Fall

COMPSCI 671D Fall 2019Homework 41 EM Algorithm for Topic Modeling (35 points)In this question we will try to design an algorithm for discovering the abstract topics that occur in aset of documents. In the problem, we have a set of M abstract document

CS300 P02 Matching Game

P02 Matching GameProgramming II (CS300) Fall 2019Pair Programming: ALLOWEDDue: 9:59PM on September 18thP02 Matching GameOverviewThis assignment involves developing a graphical application that represents a simple matchinggame with cards. Our game is

STAT 415 and STAT 515

STAT 415 and STAT 515 Project 1 Fall 2019 Page 1Instructions:• Follow the instructions indicated in this project carefully.• This project should be considered to be an exam. That means that you should do your own work.• You should not speak about thi

IE 6200 Midterm

IE 6200 Midterm 2 Project190 pointsFall 2019For your final project you will find a dataset online and complete an extensive statisticalanalysis. The material relevant to this final project will be covered through the December2nd lecture but I recomme

CS174A Fundamentals of Database

CS174A Fundamentals of Database Systems Fall 2019COURSE PROJECT 1 INTRODUCTIONYou have been hired to develop a prototype account management system for Debts Rus State Bank. Thesystem is to manage all savings, checking, and pocket accounts at the bank

Math 309 Extra-Credit

Math 309 Extra-Credit Project 4 Fall, 2019The amount of extra-credit will depend on the overall quality of your work. Youmust submit a formal Report to show your work. The Report must be typedand if possible prepare the Report with RMarkdown and subm