<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-X%3Atlou006</id>
	<title>SE250:lab-X:tlou006 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-X%3Atlou006"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-X:tlou006&amp;action=history"/>
	<updated>2026-04-29T01:15:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-X:tlou006&amp;diff=9179&amp;oldid=prev</id>
		<title>Mark: 13 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-X:tlou006&amp;diff=9179&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:49Z</updated>

		<summary type="html">&lt;p&gt;13 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Q1 ==&lt;br /&gt;
&lt;br /&gt;
Number of states is 9 factorial&lt;br /&gt;
&lt;br /&gt;
9! = 362880&lt;br /&gt;
&lt;br /&gt;
The edges represent the number of states which branch off a certain state.&lt;br /&gt;
&lt;br /&gt;
If the empty space is at a corner, for each of those 4 states there are 2 possible &amp;quot;next&amp;quot; states.&lt;br /&gt;
&lt;br /&gt;
If the empty space is at one of the sides, for each of those 4 states there are 3 possible &amp;quot;next&amp;quot; states.&lt;br /&gt;
&lt;br /&gt;
If the empty space is in the middle, for that single state there are 4 possible &amp;quot;next&amp;quot; states. &lt;br /&gt;
&lt;br /&gt;
The average number of &amp;quot;next&amp;quot; states for any state is &lt;br /&gt;
&amp;lt;Pre&amp;gt; 4/9 * 2 + 4/9 * 3 + 1/9 * 4  =  2.67&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking 2.67 * 9! and dividing by 2 because each edge is being counted from both sides(states)&lt;br /&gt;
&lt;br /&gt;
number of edges = 483840&lt;br /&gt;
== Q2 ==&lt;br /&gt;
&lt;br /&gt;
- Start and finish states are initialised&lt;br /&gt;
&lt;br /&gt;
- Initialise a StateList containing the solution??&lt;br /&gt;
&lt;br /&gt;
- Run the search function, if successful then print out the StateList solution, otherwise print out &amp;quot;Cannot solve&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- Print out the number of &amp;quot;moves made&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- Free the memory used by StateList&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Q3 ==&lt;br /&gt;
&lt;br /&gt;
Wasn&amp;#039;t sure if states could go back to a previous state. ie. have two edges leading to the same state&lt;br /&gt;
&lt;br /&gt;
Asked Mark, he said I was dumb and the edges would override eachother.&lt;br /&gt;
&lt;br /&gt;
The first state will have 2 edges, as the empty space is in the corner.&lt;br /&gt;
&lt;br /&gt;
I tried the graph.c but it gave an error. Then I used rwan064&amp;#039;s fix from lab 8&lt;br /&gt;
&lt;br /&gt;
The graph drawn was a huge tree &lt;br /&gt;
&lt;br /&gt;
I changed the code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;graph_state( &amp;amp;s, 7, &amp;quot;x.jpg&amp;quot; ); &lt;br /&gt;
  init_State( &amp;amp;s, &amp;quot;12345678.&amp;quot; );&amp;lt;/Pre&amp;gt; &lt;br /&gt;
to&lt;br /&gt;
&amp;lt;Pre&amp;gt;  init_State( &amp;amp;s, &amp;quot;123456.78&amp;quot; );&lt;br /&gt;
  graph_state( &amp;amp;s, 2, &amp;quot;x.jpg&amp;quot; );&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;img src=&amp;quot;http://studwww.cs.auckland.ac.nz/~tlou006/x.jpg&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot; alt=&amp;quot;Tom&amp;#039;s Task 3 Image&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Q4 ==&lt;br /&gt;
&lt;br /&gt;
== Q5 ==&lt;br /&gt;
&lt;br /&gt;
== Q6 ==&lt;br /&gt;
&lt;br /&gt;
What i understood from the question, we want to search through the entire length(height) of a branch before starting on the next branch beside it??&lt;br /&gt;
&lt;br /&gt;
in the search function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;int i, n_children;&lt;br /&gt;
      State* cs = get_children( &amp;amp;s, &amp;amp;n_children );&lt;br /&gt;
      for( i = 0; i &amp;lt; n_children; i++ )&lt;br /&gt;
	if( add_to_StateSet( &amp;amp;visited, &amp;amp;cs[ i ] ) ) {&lt;br /&gt;
	  /* we have not yet seen this state */&lt;br /&gt;
	  put_StateMap( &amp;amp;path_map, &amp;amp;cs[ i ], &amp;amp;s );&lt;br /&gt;
	  add_to_OrderedStateList( &amp;amp;open, &amp;amp;cs[ i ] );&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take the last state off the list and read it.&lt;br /&gt;
&lt;br /&gt;
Set that state as the current state, for each of the current state&amp;#039;s children, if we have not visited this children state then add it to the StateList.&lt;br /&gt;
&lt;br /&gt;
For each of the &amp;quot;current state&amp;quot;&amp;#039;s children we want to add each of the children&amp;#039;s children to the list BEFORE adding the next children to the list and reading the next &amp;quot;current state&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That made no sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;int i, n_children;&lt;br /&gt;
      State* cs = get_children( &amp;amp;s, &amp;amp;n_children );&lt;br /&gt;
      for( i = 0; i &amp;lt; n_children; i++ )&lt;br /&gt;
	if( add_to_StateSet( &amp;amp;visited, &amp;amp;cs[ i ] ) ) {&lt;br /&gt;
	  /* we have not yet seen this state */&lt;br /&gt;
	  put_StateMap( &amp;amp;path_map, &amp;amp;cs[ i ], &amp;amp;s );&lt;br /&gt;
	  add_to_OrderedStateList( &amp;amp;open, &amp;amp;cs[ i ] );&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I think we need to repeat the for loop but setting State* cs = to &amp;amp;cs[ i ]&lt;br /&gt;
&lt;br /&gt;
ie. the ith child of the &amp;quot;current state&amp;quot; we are looking at&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We want to do this before i increments??&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Q7 ==&lt;br /&gt;
&lt;br /&gt;
== Q8 ==&lt;br /&gt;
&lt;br /&gt;
== Q9 ==&lt;br /&gt;
&lt;br /&gt;
== Q10 ==&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>