<?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%3Anpit006</id>
	<title>SE250:lab-X:npit006 - 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%3Anpit006"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-X:npit006&amp;action=history"/>
	<updated>2026-04-13T11:49:34Z</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:npit006&amp;diff=9068&amp;oldid=prev</id>
		<title>Mark: 23 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-X:npit006&amp;diff=9068&amp;oldid=prev"/>
		<updated>2008-11-03T05:20:47Z</updated>

		<summary type="html">&lt;p&gt;23 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Preliminary Code Fixing==&lt;br /&gt;
I was only able to compile and run search.exe and graph.exe 40 minutes into the lab. These are the changes required.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static char* DOT_CMD = &amp;quot;\&amp;quot;C:/Program Files/ATT/Graphviz/bin/dot.exe\&amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
//static char* DOT_CMD = &amp;quot;dot&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//  init_State( &amp;amp;start, &amp;quot;.123456789abcdef&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
//  init_State( &amp;amp;goal,  &amp;quot;123456789abcdef.&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    init_State( &amp;amp;start, &amp;quot;.12345678&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
    init_State( &amp;amp;goal,  &amp;quot;12345678.&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Task 1==&lt;br /&gt;
In the 8 piece puzzle, there are 9 possible different values for each position. Therefore, the total number of states is 9! = 362880.&lt;br /&gt;
&lt;br /&gt;
Calculating the number of edges in the total state space is a bit more difficult. Each state has a certain number of edges depending on whereabouts the blank space is... there are 9 possible positions for the blank space... summary:&lt;br /&gt;
&lt;br /&gt;
4/9 positions are corners which have 2 edges&lt;br /&gt;
4/9 positions are edges which have 3 edges&lt;br /&gt;
1 position is a middle one which has 4 edges.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With 362880 possible states categorised by where the blank space is, I think:&lt;br /&gt;
* 161280 of these states are corners and yield 322560 edges&lt;br /&gt;
* 161280 of these states are edges and yield 483840 edges&lt;br /&gt;
* 40320 of these states are middles and yield 161280 edges&lt;br /&gt;
&lt;br /&gt;
Total number of edges =  967680&lt;br /&gt;
&lt;br /&gt;
Have to divide by 2 since an edge is bidirectional... edges = 483840&lt;br /&gt;
&lt;br /&gt;
==Task 2==&lt;br /&gt;
Judging from the sparsely commented wall of code that is search.c, I think I&amp;#039;ll skip this task for now. Other tasks are probably more important/useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Task 3==&lt;br /&gt;
I drew the state space enclosed within 2 moves of the initial state and it was correct. There were 7 states included.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Tasks 4 &amp;amp; 5==&lt;br /&gt;
Task 4 involved inserting a print_state call at some point in the program - I tried including it in various positions in search.c. In order to insert it in a sensible position, I attempted to understand search.c (this is Task 2 all over again!). Shown below is the output from a regular search followed by the output from a search with a print_state call. I&amp;#039;ve also included the print_state call which I added in after pop command in search.c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 E:\lab10&amp;gt;search&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 .78&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 7.8&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 78.&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 Visited 5 states &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
 ***&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 .78&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ***&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 7.8&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ***&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 78.&lt;br /&gt;
 &lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 .78&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 7.8&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 123&lt;br /&gt;
 456&lt;br /&gt;
 78.&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 Visited 5 states&lt;br /&gt;
 &lt;br /&gt;
 E:\lab10&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 CODE:&lt;br /&gt;
 printf(&amp;quot;\n***\n&amp;quot;);&lt;br /&gt;
 print_state( &amp;amp;s); &lt;br /&gt;
 printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Given the initial state, there were 2 possible routes from there (2 children). Judging from the output (5 nodes visited), the depth-first search chose the correct path for the first movement, but then the wrong one for the second and had to backtrack... this makes sense.&lt;br /&gt;
&lt;br /&gt;
I think my code is in the wrong place though.&lt;br /&gt;
&lt;br /&gt;
==Task 6 - Change from Depth First to Breadth First==&lt;br /&gt;
I have no idea which line to change in order to alter the search strategy - it might help if I had been to lectures recently. From what I understand, using a queue is natural for a breadth-first search and using a stack is natural for a depth-first search. Though I&amp;#039;m pretty sure that has nothing to do with the one line change required here.&lt;br /&gt;
&lt;br /&gt;
Perhaps if in looking for children, we only add one child at a time per search, that might alter how it works. I don&amp;#039;t really have any real idea of what to do here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Again, it is annoying that the prepared code has problems because that only wastes time. The lab itself was fairly difficult mainly because I&amp;#039;ve missed a critical lecture or two. I could have been better prepared by reading over last year&amp;#039;s HTTB section on state-space searching, but this week has been far too busy. Still, all things considered, I think I accomplished a reasonable amount.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>