pr1 - ENEE 150: Intermediate Programming Concepts for...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ENEE 150: Intermediate Programming Concepts for Engineers Spring 2011 Handout #7 Project #1: Chess: Due Feb 23 at 11:59pm In this project, you will build a program that allows two human players to play chess. The program will keep track of the chess board and check that each player’s moves are valid. The program will not support all the possible moves in chess–just the most frequent ones–nor any rules related to capturing kings. Code will be provided that prints the board, and that controls the “outer loop” of the game. Your job will be to write the code that checks the validity of each player’s moves. 1 The Board Before each player’s turn, your program should print the chess board, which is an 8x8 grid of squares upon which the chess pieces are placed. Your program should also print the location of each chess piece on the board. Each chess piece is represented by a 2-character sequence. Here’s what the chess board looks like at the very beginning of the game: |----|----|----|----|----|----|----|----| | | | | | | | | | | WR | WN | WB | WQ | WK | WB | WN | WR | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | WP | WP | WP | WP | WP | WP | WP | WP | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | | | | | | | | | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | | | | | | | | | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | | | | | | | | | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | | | | | | | | | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | BP | BP | BP | BP | BP | BP | BP | BP | | | | | | | | | | |----|----|----|----|----|----|----|----| | | | | | | | | | | BR | BN | BB | BQ | BK | BB | BN | BR | | | | | | | | | | |----|----|----|----|----|----|----|----| In chess, there are 6 diFerent types of pieces: pawn, rook, knight, bishop, queen, and king. Each player starts out with 8 pawns, 2 rooks, 2 knights, 2 bishops, and a single queen and king for a total of 16 pieces. Each player’s pieces are distinguished by their color, white or black. The chess pieces are printed on the chess board using 2 characters to identify the piece. The ±rst character indicates the color, “W” for white and “B” for 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
black. The second character indicates the piece type, “P” for pawn, “R” for rook, “N” for knight, “B” for bishop, “Q” for queen, and “K” for king. For example, a white pawn is indicated by “WP”. The above example chess board shows all 32 chess pieces and their initial placement on the chess board at the beginning of the game. We have provided the code for the board and for printing the chess pieces on the board.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2012 for the course ELECTRICAL ENEE150 taught by Professor D.yeung during the Spring '11 term at Maryland.

Page1 / 6

pr1 - ENEE 150: Intermediate Programming Concepts for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online