Find Jobs
Hire Freelancers

Chessboard Display

$10-30 USD

Completed
Posted over 9 years ago

$10-30 USD

Paid on delivery
Develop a Prolog program to display a chessboard position. Such a task is ordinarily straightforward in most other programming languages, but to implement it in Prolog will require some thought. To be successful in this assignment, you must develop appropriate structures for representation and predicates to perform the various sub-parts of the problem as you have defined it. Unless you are already a proficient Prolog programmer, you will find that Prolog’s trace, debug and spy predicates will be your close friends during your code development. You will also find that simply putting in appropriate output statements in your code, as we do in much software development, will also be useful, although you will probably need to develop a predicate or two to work the formatting. The main entry point for running the program must be a predicate named “show” that takes two arguments. The first argument to the show predicate will be an integer, which will represent the dimension size of the chessboard. Multiple sizes will be tested. All tested sizes will be square. The second will be a list of pieces with their board positions. Each piece will be described using a list containing, in this order: (a) a Prolog constant representing the identifier for the piece, (b) the row in which the piece is located, and (c) the column in which the piece is located. The piece identifiers for White are: wk, wq, wb, wn, wr, and wp. Similarly, for Black, they are: bk, bq, bb, bn, br, and bp. Piece locations will be typical, 1-based matrix notation, with the row index first. For a standard 8 x 8 chessboard, the upper left corner is (1,1), the lower right is (8,8), and the position in the second row, third column is (2,3). Program output must be strictly to the terminal. It should begin with the string “Board Position:” and then should display the contents of every location on the board. If a location is empty, then the program should output two hyphens for the identifier. If a piece is located at a given position, then that piece’s identifier should be displayed. Adjacent location identifiers should be separated by a single space character to enhance readability. Your program will not need to validate the input data. All piece locations in test predicates will be within the bounds of the chessboard, and no two pieces will be assigned to the same board location. Sample run predicate and output ========================== The prolog command: show( 8, [ [ br, 7, 6 ], [ wr, 2, 4 ], [ wk, 2, 3 ], [ bk, 5, 2 ] ] ). Should produce the following output: Board Position: -- -- -- -- -- -- -- -- -- -- wk wr -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- bk -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- br -- -- -- -- -- -- -- -- -- --
Project ID: 6680618

About the project

Remote project
Active 9 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
I have not yet completed projects in this forum, but some of the projects should be first. Maybe it is your project? From the Prolog, of course, familiar. Swi?
$30 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
oviedo, United States
5.0
1
Payment method verified
Member since Nov 3, 2014

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.