Implement an interpreter for algebraic chess notation

Assignment Help Computer Engineering
Reference no: EM131207882

Programming Assignment #1: ChessMoves

Abstract

In this programming assignment, you will implement an interpreter for algebraic chess notation, which is a system used to describe the moves made over the course of a chess game. In order to finish this program, you will need to learn a bit about chess: how pieces can move on the game board, as well as how those moves are denoted with algebraic chess notation.

By completing this assignment, you will gain experience manipulating strings, 2D arrays, structs, and struct pointers in C. You will also gain experience working with dynamic memory allocation and squashing memory leaks. On the software engineering side of things, you will learn to construct programs that use multiple source files and custom header (.h) files. This assignment will also help you hone your ability to read technical specifications and implement a reasonably lengthy, non-trivial project with interconnected pieces.

1. Overview

There are a few different notation systems used to denote the moves made in a game of chess. One of those systems is called "algebraic chess notation." With algebraic chess notation, a sequence of moves made in a chess game is recorded as a series of strings that look something like this:1

1. e4 e5
2. Nf3 Nc6
3. Bb5 a6
4. Ba4 Nf6 5. 0-0 Be7

For this assignment, you will write a program that parses through a series of algebraic chess notation strings and prints out what the chess board looks like with each move that is made. To do this, you will first have to learn (or brush up on) how chess pieces move (see Appendix A in this document) and how algebraic chess notation works (see Appendix B).

A complete list of the functions you must implement, including their functional prototypes, is given below in Section 5, "Function Requirements". You will submit a single source file, named ChessMoves.c, that contains all required function definitions, as well as any auxiliary functions you deem necessary. In ChessMoves.c, you will have to #include any header files necessary for your functions to work, including the custom ChessMoves.h file we have distributed with this assignment (see Section 4, "ChessMoves.h").

2. Important Note: Test Case Files Look Wonky in Notepad
Included with this assignment are several test cases, along with output files showing exactly what your output should look like when you run those test cases. You will have to refer to those as the gold standard for how your output should be formatted. Please note that if you open those files in Notepad, they will appear to be one long line of text. That's because Notepad handles end-of-line characters differently from Linux and Unix-based systems. One solution is to view those files in an IDE (like CodeBlocks), or you could use a different text editor (like Atom or Sublime).

A Guide for the Overwhelmed
Okay, so, this might all be overwhelming, and you might be thinking, "Where do I even start with this assignment?! I'm in way over my head!"

Don't panic! There are plenty of TA office hours where you can get help, and here's my general advice on starting the assignment:

1. First and foremost, start working on this assignment early. Nothing will be more frustrating than running into unexpected errors or not being able to figure out what the assignment is asking you to do on the day that it is due.

2. Secondly, glance through this entire PDF to get a general overview of what the assignment is asking you to do, even if you don't fully understand each section right away.

3. Thirdly, before you even start programming, read through Appendices A and B to familiarize yourself with the game of chess and the algebraic chess notation you'll be parsing in this assignment.

4. Once you have an idea of how algebraic chess notation works, open up the test cases and sample output files included with this assignment and trace through a few of them to be sure you have an accurate understanding of how chess notation works.

5. Once you're ready to begin coding, start by creating a skeleton ChessMoves.c file. Add a header comment, add some standard #include directives, and be sure to #include "ChessMoves.h" from your source file. Then copy and paste each functional prototype from ChessMoves.h into ChessMoves.c, and set up all those functions return dummy values (either NULL or nothing at all, as appropriate).

6. Test that your ChessMoves.c source file compiles. If you're at the command line on a Mac or in Linux, your source file will need to be in the same directory as ChessMoves.h, and you can test compilation like so:

Alternatively, you can try compiling it with one of the test case source files, like so:

For more details, see Section 7, "Compilation and Testing (Linux/Mac Command Line)."

If you're using an IDE (i.e., you're coding with something other than a plain text editor and the command line), open up your IDE and start a project using the instructions above in Section 6, "Compilation and Testing (CodeBlocks)". Import ChessMoves.h, testcase01.c, and your new ChessMoves.c source file, and get the program compiling and running before you move forward. (Note that CodeBlocks is the only IDE we officially support in this class.)

7. Once you have your project compiling, go back to the list of required functions (Section 5, "Function Requirements"), and try to implement one function at a time. Always stop to compile and test your code before moving on to another function!

8. You'll probably want to start with the createChessBoard() function.

As you work on createChessBoard(), write your own main() function that calls createChessBoard() and then checks the results. For example, you'll want to ensure that createChessBoard() is returning a non-NULL pointer to begin with, and that each index in the array it returns is non-NULL as well. Then try printing out the board. Finally, look through the text cases provided with this assignment to find one that calls createChessBoard() explicitly. Run it and check that your output is correct. If not, go through your code (as well as the test case code) line-by-line, and see if you can find out why your output isn't matching.

9. After writing createChessBoard(), I would probably work on the destroyChessBoard() and printChessBoard() functions, because they're so closely related. This might require that you spend some time reviewing the course notes on 2D array allocation.

10. Next, I would work on the parseStringNotation() function. This one will be quite lengthy. Start by writing your own main() that passes simple strings to parseStringNotation(). Check that the results it produces are correct. Then start passing more complex strings. If you need guidance on how to call this function and determine whether it's producing the correct results, look for a test case that calls parseStringNotation(), and check whether your program produces the correct output with that test case. If not, trace through it by hand.

11. If you get stuck while working on this assignment, draw diagrams on paper or a whiteboard. Make boxes for all the variables in your program. If you're dynamically allocating memory, diagram them out and make up addresses for all your variables. Trace through your code carefully using these diagrams.

12. With so many pointers, you're bound to encounter errors in your code at some point. Use printf() statements liberally to verify that your code is producing the results you think it should be producing (rather than making assumptions that certain components are working as intended). You should get in the habit of being immensely skeptical of your own code and using printf() to provide yourself with evidence that your code does what you think it does.

13. When looking for a segmentation fault, you should always be able to use printf() and
fflush() to track down the exact line you're crashing on.

14. You'll need to examine a lot of debugging output. You might want to set up a function that prints debugging strings only when you #define a DEBUG value to be something other than zero, so you can easily flip debugging output on and off. (Just be sure to remove your debugging statements before you submit your assignment, so your code is nice and clean and easy for us to read.)

15. When you find a bug, or if your program is crashing on a huge test case, don't trace through hundreds of lines of code to track down the error. Instead, try to cook up a new main() function with a very small test case (as few lines as possible) that directly calls the function that's crashing. The less code you have to trace through, the easier your debugging tasks will be.

Submit a single source file, named ChessMoves.c, via Webcourses. The source file should contain definitions for all the required functions (listed above), as well as any auxiliary functions you need to make them work.

Your source file must not contain a main() function. Do not submit additional source files, and do not submit a modified ChessMoves.h header file. Your source file (without a main() function) should compile at the command line using the following command:

It must also compile at the command line if you place it in a directory with ChessMoves.h and a test case file (for example, testcase01.c) and compile like so:

Be sure to include your name and NID as a comment at the top of your source file.

Attachment:- chessmoves.zip

Reference no: EM131207882

Questions Cloud

Have they ever been convicted of a felony : The assignment is to make a pie chart showing the current earning vs. a pie chart the shows the future earnings once goals are meet and include the employee's salary at max of $400.00 weekly. Part 2 of the assignment is to draw up an application ..
Law develops via adjudication of cases : 1. Articulate how the law develops via adjudication of cases. 2. Differentiate between subject matter jurisdiction and personal jurisdiction. 3. List the types of controversies over which federal courts have subject matter jurisdiction.
View the concept of whistleblowing : Why is it important not to view the concept of "whistleblowing" as "tattling" or "ratting" on another employee?
Legislation or pharmaceutical salespersons : In 100 word, discuss bribery. Would actions, such as politicians adding earmarks in legislation or pharmaceutical salespersons giving away drugs to physicians, constitute bribery? Identify three business activities that would constitute bribery an..
Implement an interpreter for algebraic chess notation : Implement an interpreter for algebraic chess notation, which is a system used to describe the moves made over the course of a chess game. In order to finish this program, you will need to learn a bit about chess: how pieces can move on the game bo..
Write an essay describing the use of an olap data cube : Write a 2 to 3 page essay describing the use of an OLAP Data Cube. Your essay should also describe the operations of Drill Down, Roll Up, Slice, and Dice.
Financial accounting standards board : For restating financial statements to convert to constant dollars, what index is required by the Financial Accounting Standards Board?
Financial accounting standards board : For restating financial statements to convert to constant dollars, what index is required by the Financial Accounting Standards Board?
Describe the role of leadership-management-organizational : Describe the role of leadership, management, organizational structure, and the culture of the organization and the departments that shows how it failed and succeeded for the blockbuster organization?

Reviews

len1207882

9/15/2016 8:37:11 AM

Your program must be submitted via Webcourses, and it must compile and run on Eustis to receive credit. Programs that do not compile will receive an automatic zero. Your grade will be based largely on your program’s ability to compile and produce the exact output expected. Even minor deviations (such as capitalization or punctuation errors) in your output will cause your program’s output to be marked as incorrect, resulting in severe point deductions. The same is true of how you name your functions and their parameters. Please be sure to follow all requirements carefully and test your program throughly. Additional points will be awarded for style (proper commenting and whitespace) and adherence to implementation requirements. For example, the graders might inspect your destroyChessBoard() function to see whether it is properly freeing up memory.

len1207882

9/15/2016 8:37:03 AM

The tentative scoring breakdown (not set in stone) for this programming assignment is: 40% correct output for test cases 35% implementation details (manual inspection of your code) 5% difficultyRating() is implemented correctly 5% hoursSpent() is implemented correctly 5% source file is named correctly (ChessMoves.c); spelling and capitalization count 10% adequate comments and whitespace; source includes student name and NID

len1207882

9/15/2016 8:34:39 AM

we need to upload to schools linux server for testing prior to submitting the assignment actual c file.

Write a Review

Computer Engineering Questions & Answers

  Consider database security from a variety of perspectives

Share experiences have you had in terms of user security in past jobs or as a student? Do you feel the user security was effective in those situations? What will you have done differently in light of what you've learned about data security.

  Requirements analysis is a vital part of any software

requirements analysis is a vital part of any software development effort but the requirements planning for an

  Define the expected benefits of the new system and for

-make a ppt presentation for this each section for about 3-4 slide with a notes carda. select networking hardware and

  Create a 3d graphics scene using opengl

Your task is to create a 3D graphics scene using OpenGL matching the theme described above. Your creation will include a path following a non-linear path on which the game or simulation will occur. There will be a series of camera views.

  Calculate the time needed to perform the computation

Calculate the time needed to perform the computation on the 8 values shown in Fig. 2. Calculate the time needed for the arrangement in Fig.2 to perform the computation on 100 8-value data sets

  What are the main tenets of information theory

Why would one assert that the type of information handled by the Internet is more MTC-bound and that the type of information handled by the Web is more semantic?

  List and explain three common types of spam

List and explain three common types of SPAM. Log onto your Email system (Ex: Gmail, Yahoo, etc.,) and locate SPAM filter functions. Configure SPAM filters to block known senders of SPAM

  Bourne shell and design suitable functions

Bourne shell and design suitable functions

  Show the rbt after the bst-style deletion

Show the RBT after the BST-style deletion but before RB-Delete-Fixup - Identify whether there is a double black identifying the node, corresponding to underflow

  Wan technologies for mobile user-to-office

WAN technologies for each of the Wilke’s three connectivity situations: mobile user-to-office, office to office, and home-to-office.

  Questionhocolate delights candy company manufactures

questionhocolate delights candy company manufactures several types of candy. graph a flowchart or pseudocode for

  Supply getmethods and setmethods for each variable

offer getmethods and setmethods for each variable. This constructor then sets the class variables miles and gas to the respective input parameters, inputmiles and inputgas.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd