首页 » C语言代写 » C语言代写|APS 105 Lab #8: Reversi Game-Playing Program

C语言代写|APS 105 Lab #8: Reversi Game-Playing Program

这是一个加拿大的C语言棋牌游戏开发作业代写

Objective: Complete the Implementation for a Reversi Game

In Lab #7, you developed a program that represents the board of a Reversi game, and that computes,
for a given board state, the possible moves for the Black and White player. Your solution also
accepts a move as input and flips the tiles accordingly. In this lab, you will build upon your work
to create a Reversi game where a human can play against the computer, with the computer making
intelligent decisions about where to place its tiles.

Recap: The Rules of Reversi

The rules of the game were presented in the Lab #7 handout, and are briefly repeated here. Reversi
is played on a board that has dimensions n × n, where n is even and ranges from 4 to 26. In the
picture below n = 4. The game uses tiles that are white on one side, and black on the other side
(they can be “flipped” over to change their colour). One player plays white; the other player plays
black. The picture below shows the initial board configuration, which has two white and two black
tiles pre-placed in the centre. Observe that rows and columns are labelled with letters.
terial necessary for this lab can be found in the Carter text up to the end of Chapter 6.

Objective – Part of the Code for a Reversi Game

The goal of this lab is to write a program that will be used (in Lab 7) as part of a Reversi
game, as well as a little bit of the ’thinking’ code that will be used in that lab to have the
computer play against a human opponent.

Here is a brief description of the full Reversi game. Reversi is played on a board (like a
chess board or a checkers board) that has dimensions n⇥n, where n is even. In the picture
below n = 4. The game uses tiles that are white on one side, and black on the other side
(they can be “flipped” over to change their colour). One player plays white; the other
player plays black. The picture below shows the initial board configuration, which has
two white and two black tiles pre-placed in the centre. Observe that rows and columns are
labelled with letters

A “turn” consists of a player laying a tile of his/her own colour on a candidate empty
board position, subject to the following two rules:

1. There must be a continuous straight line of tile(s) of the opponent’s colour in at least
one of the eight directions from the candidate empty position (North, South, East,
West, and diagonals).

2. In the position immediately following the continuous straight line mentioned in #1
above, a tile of the player’s colour must already be placed.

After playing a tile at a position that meets the above critera, all of the lines of the oppo
nent’s tiles that meet the criteria above are flipped to the player’s colour.

In the picture below, all of the candidate positions for White’s next move are shown shaded

The turns alternate between the players, unless one player has no available move, in which case the
only player with an available move is allowed to continue to make moves until a move becomes
available for the opponent. At this point, the opponent is allowed to take a turn and the alternating
turns between the players resume. The game ends when either: (1) the entire board is full, or (2)
neither player has an available move. The winner of the game is the one with more pieces on the
board.

The Game Flow and Prescribed Algorithm

Your program must first ask the user for the board dimensions. Then, the program asks the user
if the computer is to be the Black or White player. For this lab, we will assume that the Black
player always gets the first move. So, if the computer is black, then the computer should make the
first move; otherwise, the program prompts the human player to make the first move. The board is
printed after every move.

Once the first move is out of the way, the turns proceed as described above, alternating between
Black and White unless one of the players has no move to make, which case your program should
print a message “W player has no valid move.” (i.e. for the case of the White player) and should
prompt the Black player for another move. After each turn, your program must print the board, and
must detect whether the game has been won, or whether there is a draw. If your program detects the
game is over (i.e. a win or a draw), a message is printed and the program terminates. The specific
messages to print are: “W player wins.”, “B player wins.” or “Draw!”. If the human player
makes an illegal move, your program must detect this, print an error message, and end the game,
declaring the winner (with the corresponding message above).


程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


blank

本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipnxx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank