Curling up with others pseudocode is fine but please

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: ike the below (albeit pseudorandom), but we leave it to you to implement your own vision. 15 14 13 12 11 10 9 8 7 6 5 4 3 1 2 _ Incidentally, recall that the positions of tiles numbered 1 and 2 should only be swapped (as they are in the 4 × 4 example above) if the board has an odd number of tiles (as does the 4 × 4 example above). If the board has an even number of tiles, those positions should not be swapped. Consider, for instance, the 3 × 3 example below: 8 7 6 5 4 3 2 1 _ Feel free to tweak the appropriate argument to usleep to speed up animation. In fact, you’re welcome to alter the aesthetics of the game. For (optional) fun with “ANSI escape sequences,” including color, take a look at our implementation of clear and check out the URL below for more tricks. http://isthe.com/chongo/tech/comp/ansi_escapes.html You’re welcome to write your own functions and even change the prototypes of functions we wrote. But we ask that you not alter the flow of logic in main so that we can automate some tests of your program. If in doubt as to whether some design decision of yours might run counter to the staff’s wishes, simply contact your teaching fellow. If you’d like to play with the staff’s own implementation of fifteen on cloud.cs50.net, including God Mode, you may execute the below. ~cs50/pub/solutions/hacker3/fifteen Speaking of God Mode, where to begin? Well, first read up on this Game of Fifteen. Wikipedia is probably a good starting point: http://en.wikipedia.org/wiki/N-puzzle Then dive a bit deeper, perhaps reading up on an algorithm called A*. http://en.wikipedia.org/wiki/A*_search_algorithm 10 < 13 This is CS50. Harvard College Fall 2010 Consider using “Manhattan distance” (aka “city ­block distance”) as your implementation’s heuristic. If you find that A* takes up too much memory (particularly for d ≥ 4), though, you might want to take a look at...
View Full Document

This note was uploaded on 03/22/2013 for the course COMP SCI CS-50 taught by Professor Malan during the Spring '10 term at Harvard.

Ask a homework question - tutors are online