Any updates for Project 3 will be posted here. *********************************************** How to run the sample executable. 1. Download the file (collapse_game.out) 2. If necessary, copy collapse_game.out to your project 3 directory. 3. Do these commands to update the permissions (with chmod) so you can run it (change directory names to match what you really use): cd ic210 cd project3 chmod u+x collapse_game.out 4. You only have the above steps once. Now you can run it anytime like this: ./collapse_game.out ********************************************* STEP 3 ********************************************* Date: Tue, 13 Nov 2012 10:10:50 -0500 Subject: IC210 project Fwd: Step 3 questions From: Luke McDowell To: IC210.ALL@usna.edu > Sir, > > In the directions for step 3 it asks us to modify our main so that it > repeatedly draws the board, gets input, then displays it but the example > below that does not repeatedly display the board. Do you want us to > repeatedly display the board or just keep asking for input? > The text about repeatedly drawing the board is a mistake (Obviously, there is no reason to redraw the board until you finish Step 4!) So for step 3, just follow the example shown in the screenshot (draw the board once, the repeatedly get an input from the user and then display whether or not it is a legal move. -LKM ********************************************* Practice problems ********************************************* Date: Wed, 14 Nov 2012 14:12:59 -0500 Subject: IC210 project and the "project practice problems" From: Luke McDowell To: IC210.ALL@usna.edu On the calendar there are some "practice problems" related to the project. Depending on your section, you may also have gotten a printed version of these. Someone asked: can I talk to other students about these problems? Answer part 1: Thanks for asking. If unclear, asking for clarification is always good. Answer part 2: Yes, you may talk to other students about the practice problems. In general, you can always ask another student about general course concepts (how do I create an array? what is pass by reference), and that is also fine for those practice problems. BUT -- be careful of course not to let the conversation slip into "how do I then translate this into the project?" For the problems of the project itself, it needs to be only your work, plus any interaction with your instructor. -LKM ********************************************* Using the "gdb" debugger ********************************************* 1. Compile your program as you normally do, but include the "-g" option. For instance, if your file is project3.cpp, do this: g++ -g -Wall -Wextra project3.cpp (this produces a.out as usual, but the file will have some extra debugging information it it) 2. Run the "gdb" program on your executable like this. gdb a.out (if your executable is called something else, use that filename instead of a.out here) 3. The debugger gdb starts up and prints a bunch of messages, then waits for a command from you. It should look something like this: GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /export/home/lmcdowel/ic210temp/a.out...done. (gdb) 4. gdb is waiting for a command from you. Type "run" and hit return. 5. Your program starts running. Start playing the game as usual until it crashes. When it does, you should see an error message. The message will tell you something like this: Program received signal SIGSEGV, Segmentation fault. 0x08048660 in printBoard (board=0x3c2ff4) at proj3.cpp:48 48 cout << board[i][i]; 6. Look at the error message. Yours will be different, but the message above is telling me that the segmentation fault occurred at line 48 of proj3.cpp (inside the function printBoard). 7. Important notes: -The error message tells you where the crash occurred. It does not tell you where the PROBLEM is -- could be at this same line, or it could be that you did something wrong earlier (e.g., forgot to create the array). -This may be helpful for you, but you'll probably still want to use "cout" statements to print out the values of variables, to see how many times things happen, etc. 8. There are other useful commands you can use at this point: -"where" will show you the call stack (e.g. if you are in a function right now, what function called that function and from what line number in your code?) -"print" will print out the value of some variables, so you can do things like this: -"print i" (might be helpful to see if array[i] is problematic because 'i' is too large or negative) -"print array[0]" -"print array[1] 9. NOTE: you must enter "quit" and hit return to get out of gdb. 10. gdb has many more features. Type "help" to find out more. 11. You can also see this tutorial on gdb: http://beej.us/guide/bggdb/ This tutorial describes some different modes that more directly show you your program as it runs, and describes how to "step through" the program.