SE250:lab-X:hbar055

From Marks Wiki
Revision as of 05:20, 3 November 2008 by Mark (Sọ̀rọ̀ | contribs) (2 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Task 1

There are 9 places you could put the first piece. Having picked one of those places, 8 places remained where the second piece could be. therefore we use a factorial of 9 e.g. 9! = 362880

I need to do is figure out how many states have the hole in the middle, multiply that by 4, and multiply the rest by 2. I guess there are about 8! states with the hole in the middle. So that's: 4*8!+2*(9!-8!)=806400

Task 2

Here is a summary of what i did:

-Add the initial state to the ordered state list and the visited set -While there are states in the ordered state list -Pop a state off the list and look at it -If the state is the goal state, stop searching -Otherwise, go through the states children -If the child is not in the visited set -Add it to the visited set -Add it to the ordered state list

Task 3

I did it and thankfully i got it right

Task 4

It seems to have a priority associated with moving each direction. If it can move the empty square left, it will. Failing that it will move it down. Up is next, followed by right. If it can't do anything it will skip to a previous state which it hasn't fully explored.

Task 5

I had it solving the same problem my graph applied to. 2 moves, 5 states visited.

Task 6

Reading through piles of code to find this 1 line change I found it actually IS best first. It's using the Manhattan distance to prioritize. I guess the 1 line change (not in search.c mind) is to break the closer_state function.

Task 7

Task 8

Task 9

Task 10