[SOLVED] CS scheme Homework 7

$25

File Name: CS_scheme_Homework_7.zip
File Size: 188.4 KB

5/5 - (1 vote)

Homework 7
Submit Assignment
Due No Due Date Points 100 Submitting a file upload
Chessboard status
For this exercise, youll write a program that evaluates the status of a chess board to determine whether the king is in check or in checkmate, or if the game is in regular play.
Download the starter code (https://course.ccs.neu.edu/cs5400sp20-seattle/secure/ChessCheckStarter.zip) . The predicate you will be implementing is game_state/3 , a stub of which can be found in the
chess_check.pl . Look at the test file, chess_check_test.pl to see more detail about how this predicate is used. When you implement the game_state predicate correctly, you should be able to consult the test file, query test/0 and have it succeed with the following printed output:
?- [chess_check_test].
true.
?- test.
#1 should be in_play: in_play
#2 should be in_play: in_play
#3 should be check: check
#4 should be check: check
#5 should be check: check
#6 should be check: check
#7 should be checkmate: checkmate
#8 should be checkmate: checkmate
#9 should be checkmate: checkmate
#10 should be checkmate: checkmate
true.
Represenng the board
We use a scheme based on algebraic notation
represent positions on the board, with rows numbered and columns lettered as shown:
(https://en.wikipedia.org/wiki/Algebraic_notation_(chess) ) to

@
Color-
Piece@Column-Row
black-
rook@g-3
:- op(700, xfx, @). chess_check.pl @
check checkmate
black
white
game_state
in_play
A current board state is represented by a list of structures representing pieces on squares. We use the
and the characters as delimiters in the structure, so the structures have the form:
. For example, the black rook on G3 would be represented by the atomic structure
. (The line at the top of defines as an operator. You dont
need to modify this).
Querying the program
The predicate takes three arguments: a list of piece/position structures, a color ( or ) representing which side is currently to play, and an atomic value , , or
. We will query the predicate with the first two arguments instantiated, and the program will tell us what
state the game is in.

Write your code to deal with the movements of bishops, rooks, queens, and kings. No other pieces need to be represented. There are no pawn or knight positions in any of the test cases.
You do not need to include any sanity checks or verification that the board state is possible. All you need to determine is whether the king is under attack and if so, whether he can escape.
In fact, none of the test cases are strictly possible, as they all omit the inclusion of the opponents king. Write two more test cases, one in which the opponents king plays a role in a checkmate, and one in which the opponents king is present but is not involved in checkmating. Add those test cases to test and make sure that your predicate passes them all.
Your program does not need to recognize stalemate situations.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS scheme Homework 7
$25