8 9 13 this is cs50 harvard college fall 2010 any

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ble.7 Navigate your way to ~/hacker3/fifteen/, and take a look at fifteen.c with Nano. Within this file is the entire framework for The Game of Fifteen (and variants thereof). Implement God Mode for this game. First implement init in such a way that the board is initialized to a pseudorandom but solvable configuration.8 Then complete the implementation of draw, move, and won so that a human can actually play the game. But embed in the game a cheat, whereby, rather than typing an integer betwen 1 and d 2 – 1, where d is the board’s height and width, the human can also type GOD to compel “the computer” to take control of the game and solve it (using any strategy, optimal or non ­optimal), making, say, only four moves per second so that the human can actually watch. Presumably, you’ll need to swap out GetInt for something more versatile. It’s fine if your implementation of God Mode only works (bearably fast) for d ≤ 4; you need not worry about testing God Mode for d > 4. Oh and you can’t implement God Mode by remembering how init initialized the board (as by remembering the sequence of moves that got your program to some pseudorandom but solvable state). That’d be, um, cheating. At cheating. To test your implementation, you can certainly try playing it yourself, with or without God Mode enabled. (Know that you can quit your program by hitting ctrl ­c.) Be sure that you (and we) cannot crash your program, as by providing bogus tile numbers. And know that, much like you automated input into find, so can you automate execution of this game via input redirection if you store in some file a winning sequence of moves for some configuration. 7 Figure adapted from http://en.wikipedia.org/wiki/Fifteen_puzzle. To be clear, whereas the standard edition of this problem set requires that the board be initialized to a specific configuration, this Hacker Edition requires that it be initialized to a pseudorandom but still solvable configuration. 8 9 < 13 This is CS50. Harvard College Fall 2010 Any design decisions not explicitly prescribed herein (e.g., how much space you should leave between numbers when printing the board) are intentionally left to you. Presumably the board, when printed, should look something l...
View Full Document

Ask a homework question - tutors are online