| 7.1 | The game of GO is often played online; many users
save their game data for later analysis. The game is played by two players who take turn
placing stones (one player using black the other white stones) on the intersections of a
19x19 board. Create a program a user could use to enter each move of a game and save that
information to file.
|
|
|
| 7.2 | Create a program to read back the information
logged by the program in question (1) to the user. Can you think of a graphical way to
present the information in a text console?
|
|
|
| 7.3 | An .sgf file is the standard way to store GO
games. Several sgf files are provided on the book website. Open these up with a text browser;
try to figure out how information is stored in these; and create a program to read it back
and display the end board of the game to the user.
|
|
|
| 7.4 | A cellular automaton is a discrete model studied
in mathematics and other fields. It consists of a grid of cells, which can have an on or off
state. The cells in the first row are initialized to some initial state. The state of a cell
in the second row is determined by looking at the cell immediately above; the cell above and
to the left and the cell above and to the right. The information about these three cells is
interpreted by some set of rules to give the state of the new cell. Cellular automata are
often represented graphically. A few examples are provided on the book website. Write a
program that creates a visual representation of the following rules and initial conditions
by writing text to a file. (you could use spaces for off states and some symbol for on states).
The new cell is on if one or two of its above neighbors are on, but off if all three or none
are on. The initial condition is one cell set to on. Develop 32 rows of this automaton.
|
|
|
| 7.5 | Write a program that quizzes the user on his
vocabulary. Make the program read a set of words and definitions from a file; display
definitions one at a time, in random order, and prompt for the appropriate word.
|
|
|
| 7.6 | Write a program that will keep track of the
mileage for oil changes for your car.
|
|
|
| 7.7 | Write a program that reads the contents of a file
and outputs it to the screen.
|
|
|
| 7.8 | Write a program that takes input from the user
and saves it to a file.
|
|
|
| 7.9 | Write a program that prompts for an input and
output file and copies the contents from the input file to the output file.
|
|
|
| 7.10 | Write a program that correctly writes this string
to a file: Bob said, "I don't want\need that".
|
|
|
| 7.11 | Write a program that password protects files. To
do this, when a file is being created, use the first line of the file as the password and the
rest of the file is the contents. When creating a file to write to, ask for a password and
then get the text to be written to the file. When opening a file, the user needs to give the
right password, or it doesn't read the file. The password isn't output as part of the file.
|
|
|
| 7.12 | Write a program that works as a simple address book.
|
|
|
| 7.13 | Write a program that reads the coefficients of 2
linear equations (assume they are integers) with two unknowns each from a file and calculates
the determinant for the corresponding matrix.
|
|
|
| 7.14 | Generalize problem (6) to n equations with n
unknowns. You should know that you can express the determinant of a nxn system as the sum of
the determinants of n (n-1)x(n-1) systems using something called Laplace Exponsion. Test your
program with the data file provided on the book website. You should get 44328 as your answer.
|
|
|
| 7.15 | Expand your code for problem (7) and use
something called the Adjugate matrix to find the inverse of the matrix corresponding to the
coefficients provided in a file. Use the same data file as in question 6.
|
|
|