Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91963889
  • Price:- $110

Guranteed 48 Hours Delivery, In Price:- $110

Have any Question?


Related Questions in Computer Engineering

The literature on honeypots or so called fake networks to

The literature on honeypots or so called "fake networks" to attract hackers and attackers frequently mentions "entrapment" as one of the legal issues that must be considered. How of a concern is entrapment? What are some ...

Decision support systems dss what sorts of dss tools do you

Decision support systems (DSS). What sorts of DSS tools do you use at your work - e.g., what-if analysis, sensitivity analysis, scenario analysis, goal-seeking analysis, optimization analysis, etc.? Even if you don't use ...

Select one of the discussion topics and respond begin your

Select one of the discussion topics and respond. Begin your response by indicating which question you chose. Discussion topics: Section 1 Can we distinguish between knowing someone in the sense of knowing the habits or t ...

Question how is inventory management helpful in the scope

Question: How is inventory management helpful in the scope and structure of operations management? Note: Given paragraphs are for reference purpose. Structure and Scope of Operation There are three aspects of operations ...

At steady-state the output of a pid controller is 10ma when

At steady-state, the output of a PID controller is 10mA. When the process is upset, the set-point signal increases at a rate of 0.4 mA/min. If the controller gain, reset time, and derivative time are 3, 2 min, and 0.4 mi ...

Discuss the importance of metadata and some of the various

Discuss the importance of metadata and some of the various ways (Microsoft) SQL Server allows you to expose that information. References welcomed to learn where to find obscure IT information (books, articles, websites)

The business model for jpmorgan chase was change in 2008

The business model for JPMorgan Chase was change in 2008. Could the upside of the strategy have been achieved without exposing JPMorgan Chase the bank?

Identify economic decision that is driven by a behavioral

Identify economic decision that is driven by a behavioral bias rather than by pure rational behavior. why are they differ today?

You run a small pizza shop named pizza hat initially you

You run a small pizza shop named Pizza Hat. Initially you sold pizzas for $8 and every week you sold around 3000 pizzas. Each pizza costs you $3 to make. One day you decided to o¤er discounts to customers to see if you c ...

This is in reference to cshort answer questions1 what is

This is in reference to C++ Short Answer Questions: 1) What is the definition of Big-O? What do we use Big-O notation to show? 2) Define recursion. Can every recursive algorithm be written as an iterative algorithm? 3) H ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As