I recently submitted Assignment 2. As I previously stated, in this particular assignment we were asked to implement some classes so that we could solve four puzzles: Sudoku, Peg Solitaire, MN Puzzle and Word Ladder. Similarly to assignment 1 the professor provided a starter code and it was my responsibility to complete it.There were many methods that needed to be implemented such as extentions, is_solved , fail_fast and many more.
To tackle this assignment, I first had to understand the rules and purpose of each game. Once I built enough confidence, I thought: How could my program solve these puzzles? The only solution that crossed my mind was if the program explored all of the different possible game moves from a given board. From those possible game moves, the program would then explore the possible moves of these and so on. With this idea, a tree needed to be built. The children for a 'current board' would be all the possible moves that the computer could make from that current board. This would continue until the answer is found. The methods depth search and breadth search especially helped in this area. These searches simply use recursion to search for the solution in the tree. It was very important for me to implement extensions and is_solved correctly for each puzzle. The searches use these methods to access and return the solution in the tree. Method extensions returns a list of children of a given puzzle and is_solved simply returns whether a current board is solved.
Personally, I enjoyed this assignment much better than the first. This is because it dealt with puzzles which I personally enjoy and was less confusing. I was able to see the connections between all methods immediately in the starter code and hence made it much easier to complete.
No comments:
Post a Comment