Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Topics

  1. Classes
  2. Methods
  3. Data Collections: Lists, Tuples, and Dictionaries
  4. String Manipulation

Chess

Objective: practicing with classes, instance methods, data collections, loops, if and elif statements, and string methods

Description

In this assignment you will write a program that shows the valid moves of chess pieces. Your program will draw a board with 64 squares using the traditional layout, next ask the user to choose a move, and then, depending on the user's choice, redraw the board with the selected chess piece and its valid moves. Please see the examples of valid moves of chess pieces and the traditional chess board layout below:

At the beginning, your program should draw an empty chess board and prompt the user to enter a move:

Welcome to the Chess Game!
a b c d e f g h
+---+---+---+---+---+---+---+---+
8| | | | | | | | |8
+---+---+---+---+---+---+---+---+
7| | | | | | | | |7
+---+---+---+---+---+---+---+---+
6| | | | | | | | |6
+---+---+---+---+---+---+---+---+
5| | | | | | | | |5
+---+---+---+---+---+---+---+---+
4| | | | | | | | |4
+---+---+---+---+---+---+---+---+
3| | | | | | | | |3
+---+---+---+---+---+---+---+---+
2| | | | | | | | |2
+---+---+---+---+---+---+---+---+
1| | | | | | | | |1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Enter a chess piece and its position or type X to exit:

A move is represented as a three-letter string where the first letter corresponds to a chess piece initial: K stands for king, Q - queen, B - bishop, N - knight, and R - rook (a chariot). Pawns do not have initials, and you will not be tested on their implementation. The next letter in the move is the position on the board that corresponds to one of eight columns (called files). The columns (files) are labeled as a, b, c, d, e, f, g, h. The third symbol is a digit that corresponds to one of eight rows (called ranks). The rows (ranks) are labeled as 1, 2, 3, 4, 5, 6, 7, 8. For example, if the user enters Re6, your program should generate the following output where R is the initial for a rook, and all possible moves of the rook are marked by x:

a b c d e f g h
+---+---+---+---+---+---+---+---+
8| | | | | x | | | |8
+---+---+---+---+---+---+---+---+
7| | | | | x | | | |7
+---+---+---+---+---+---+---+---+
6| x | x | x | x | R | x | x | x |6
+---+---+---+---+---+---+---+---+
5| | | | | x | | | |5
+---+---+---+---+---+---+---+---+
4| | | | | x | | | |4
+---+---+---+---+---+---+---+---+
3| | | | | x | | | |3
+---+---+---+---+---+---+---+---+
2| | | | | x | | | |2
+---+---+---+---+---+---+---+---+
1| | | | | x | | | |1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Enter a chess piece and its position or type X to exit:

If the user enters Kd5, your program should produce the following output where K is the initial for the king, and all squares where the king can move are marked with x:

a b c d e f g h
+---+---+---+---+---+---+---+---+
8| | | | | | | | |8
+---+---+---+---+---+---+---+---+
7| | | | | | | | |7
+---+---+---+---+---+---+---+---+
6| | | x | x | x | | | |6
+---+---+---+---+---+---+---+---+
5| | | x | K | x | | | |5
+---+---+---+---+---+---+---+---+
4| | | x | x | x | | | |4
+---+---+---+---+---+---+---+---+
3| | | | | | | | |3
+---+---+---+---+---+---+---+---+
2| | | | | | | | |2
+---+---+---+---+---+---+---+---+
1| | | | | | | | |1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Enter a chess piece and its position or type X to exit:

If the user does not enter a valid move that is included in all possible combinations of chess piece initials (K, Q, B, N, R), files (a, b, c, d, e, f, g, h), and ranks (1, 2, 3, 4, 5, 6, 7, 8), then the program should reprint the prompt:

Enter a chess piece and its position or type X to exit:

If the user enters X (or x), then the program should print 'Goodbye!' and terminate:

Goodbye!

NOTE: The user can use either upper or lowercase letters, for example X or x should result in the termination of the program, Ke3, KE3, kE3, or ke3 means the same move.

Transcribed Image Text:Please see the examples of valid moves of chess pieces and the traditional chess board layout below: 7 65432 1 8765 N Moves of the king a b c d e f g h a b c d e f g h Moves of a queen a b c d e f g h abcdefgh 8 7 3 2 1 7768 3 1 8 7 9 3 2 09 8 7 65 432 1 a Moves of a rook b c d e f g h a b c d e f g h a Moves of a knight b c d e f g h abcdefgh 00 7 65 3 2 00 8 7 65 3 2 1 8 7 S 4 3 N 1 8 7 6 5 4 3 1 Moves of a bishop abcdefgh abcdefgh a Moves of a pawn b c d e f g X 8 X X X h a b c d e f g h 8 6 5 3 2 21 8 7 6 3 2 1 At the beginning, your program should draw an empty chess board and prompt the user to enter a move:
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY