Explore BrainMass

Chess game in C

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Create table game characters 8x8, where will store THE POSITION OF Figure each
time on this chessboard. The creation of the list must be made with commitment memory. In addition
create structure (struct move) to be used for the registration movements with the elements:
CHAR OVER, char prevpos[2], char nexpos[2], move *next, move *prev. The program, with the
start-up phase, shows the screen menu the following options:

[N] Start New Game Thema 2
[S] Score Thema 3
[U] Undo Thema 4
[E] End Program
Selection (N, S, U, E):

The program will goes only in the case given valid choice (one of the above mentioned letters),
in any other case will again expects to one new selection. After the execution of a selection
return in the mainly menu. TERMINATES WHEN given E.

Choice N Starts a new game. Firstly make a double connected list Moves with nodes move, where it will be stored in sequence of
moves.Create two stacks black and white, where will be maintained file of pieces of figures that
wins every player. The list black (white) corresponds in the player with black (white) pieces
and are stored the white (blacks) Figures. Afterwards the game begins and the computer asks the
sequence of movements with the way as it is descriped in subjects 3 and 4 at the first work project. You Can use or
your own corresponding code or the proposed solutions of first work where
shape suitably.

For each valid movement, you supplement suitably the elements of one node move and
add in the double connected list, and inform proportionally the table game. If in
final square of movement exists rival piece, it is eaten and removed from the dash (game),
it is registered in stack the player (white or black) and is added node with nexPos= ` - - `. If
piece Figure is the King of opponent, then is not placed in no list and we consider that the player
that makes the movement it Wins: is printed suitable message in the screen and the game terminates. If
exists his own piece Figure, the movement is cancelled and is required to give a valid move. The process is repeated up to
the user types instead of movement the symbol baluster (#), therefore will return in
main Menu.

Choice S will evaluate the existing situation and will elect the winner for the case
that the game terminates without winner (for example when has been agreed concrete biggest duration
game). In order to becomes this, from each stack are removed the Figure pieces, are printed message
description in the screen and are registered the points in the corresponding player, according to the values
that appear in table 1. The player with most points, is the winner and
it is announced in the screen. If there is equal total points, is printed message of draw.

Subject 4: Undo of movements
When is given the choice U in the main Menu, the program asks the player how much movements it wants
it reverses. The figure that is given concerns successive movements, independent player, beginning from
the last one. For the recantation is used the double connected list, from where a-one
movements are described in the screen and are informed suitably the table. Proportionally they become also
changes in the two stacks. Obviously, it should it is recognized in who belongs the movement when
` is eaten' figure piece.

© BrainMass Inc. brainmass.com December 20, 2018, 8:07 am ad1c9bdddf


Solution Preview

Attached is the compete solution C-source code file. There are plenty of comments. The main menu looks ...

Solution Summary

The solution contains a basic immitation of a chess game. The chess board is displayed with letters standing for figures. Movements are not restricted in any direction, but you cannot step on to your own piece. After each move an update board is displayed. There is also an Undo operation available.