C# RushHour Puzzlehttp://rushhour.codeplex.com/project/feeds/rssRushHour Project uses the A* algorithm to solve instances of the Rush Hour puzzle. This involved implementing a graph-search version of A*, along with three heuristics, and testing the implementation on several Rush Hour puzzlesUpdated Wiki: Homehttp://rushhour.codeplex.com/wikipage?version=6<div class="wikidoc">
<p><strong>C# implementation for Rush Hour puzzle</strong></p>
<p><strong> </strong><br>
This project focuses on Rush Hour puzzle such as the following:<br>
<br>
<img src="http://img600.imageshack.us/img600/4189/13030194.png" alt=""><br>
<br>
In Rush Hour puzzle, the red car is stuck in traffic and is trying to escape. Cars can be moved up and down or left and right. They are allowed to move more than one square in a single move, but cannot move over or through other cars. The goal is to clear a
path so that the red car can escape past the yellow arrow. <br>
<br>
<strong>A* and heuristics for Rush Hour</strong><br>
<br>
One of the main parts of this project is implementing A* and three heuristics for solving Rush Hour puzzles. Our implementation of A* should check to be sure that it is not re-exploring parts of the search space that have already been explored. The goal of
the search is to solve the puzzle in the fewest moves possible, so the cost of a search path should simply be the number of legal moves made.<br>
Here are the three heuristics that we should implement and test A* on:<br>
<br>
1. The trivial zero heuristic whose value is equal to zero in all states. Note that using A* with this heuristic is equivalent to breadth-first search.</p>
<p><br>
2. The blocking heuristic which is equal to zero at any goal state, and is equal to one plus the number of cars blocking the path to the exit in all other states. For instance, in the state above, there are two cars (namely, the two green ones) on the path
between the red car and the exit. Therefore, in this state, the blocking heuristic would be equal to three.</p>
<p><br>
3. A third, advanced heuristic of our own choosing and invention. We should aim for a heuristic that will be at least as effective as the blocking heuristic. A trivial heuristic, comparable to the zero heuristic in triviality, would not be appropriate.</p>
<p>Note that every car is constrained to only move horizontally or vertically. Therefore, each car has one dimension along which it is fixed, and another dimension along which it can be moved.
<br>
Our A* implementation will take as input a heuristic (1-3) and a string representing the names of the text file containing the initial state.</p>
<p>The output should contain:</p>
<p>1. the solution as a sequence of operations; for example:<br>
Move car # 3 down 3 squares<br>
Move car # 1 down 1 square<br>
…<br>
2. The depth of the goal state found<br>
3. The number of nodes expanded<br>
4. The branching factor<br>
5. The cost of the solution found<br>
<br>
Locations on the grid of a Rush Hour puzzle are identified by their (x, y) coordinates, where the upper left corner is square (0,0). For instance, in the puzzle above, the red car occupies squares (1,2) and (2,2). The goal is to move the red car so that it
occupies squares (5,2) and (6,2).<br>
The goal car (the one we are trying to move to the exit) is always assigned index 0. The remaining cars are indexed 1,2,4, …<br>
Puzzles should be read from a file into memory and they must be encoded as in the following example representing the puzzle above:<br>
<br>
6<br>
0 1 2 h 2<br>
1 2 0 v 2<br>
2 4 0 h 2<br>
3 3 1 v 3<br>
4 4 1 v 2<br>
5 4 3 h 2</p>
<p><br>
The first line "6", gives the size of the grid, i.e., this puzzle is defined on a 6x6 grid. The next line, "0 1 2 h 2", gives a description of the red car. The first number is the car ID. The second two numbers (1,2) give the (x, y) coordinates of the upper
left corner of the car. The "h" indicates that the car is horizontally oriented ("v" would have indicated vertical orientation). The last number "2" indicates that the car has size (i.e., length) 2. The next line, "1 2 0 v 2" describes the pink car, and so
on.</p>
<p><br>
For this Project , we can assume that the puzzle is a 6x6 grid, that the goal car always horizontally oriented.<br>
We may notice that the results we achieve for the number of nodes searched are different, and frequently better, than the sample ones above. The number of nodes searched can vary pretty widely, even among "correct" implementations, due to slight variations
involving the handling of nodes in the fringe that have the same cost. The results above were achieved for an implementation in which such ties are broken in a FIFO order, i.e., the node that was placed in the OPEN earliest is removed first, an approach that
actually appears to be suboptimal. In any case, any way we choose to handle ties is acceptable and the potential variation in results will be taken into account when grading our project. (However, see the note below under "debugging tips".)</p>
<p> </p>
<p>Abed El-Azeem Bukhari</p>
<p>abedbukhari[at]hotmail[dot]com</p>
</div><div class="ClearBoth"></div>AbedBukhariSat, 16 Mar 2013 18:51:23 GMTUpdated Wiki: Home 20130316065123PSource code checked in, #18482http://rushhour.codeplex.com/SourceControl/changeset/changes/18482Upgrade: New Version of LabDefaultTemplate.xaml. To upgrade your build definitions, please visit the following link: http://go.microsoft.com/fwlink/?LinkId=254563Project Collection Service AccountsMon, 01 Oct 2012 20:29:34 GMTSource code checked in, #18482 20121001082934PSource code checked in, #18481http://rushhour.codeplex.com/SourceControl/changeset/changes/18481Checked in by server upgradeProject Collection Service AccountsMon, 01 Oct 2012 20:27:42 GMTSource code checked in, #18481 20121001082742PNew Post: Examplehttp://rushhour.codeplex.com/discussions/349350<div style="line-height: normal;"><p>Solution:</p>
<p>C:\trash.txt:</p>
<p> </p>
<p>
<hr />
22...3<br />8..4.3<br />8XX4.3<br />8..4..<br />7...55<br />7.666.</p>
<hr />
<p> </p>
<p>In MainClass: Board board = new Board(boardStr<strong>2</strong>);</p>
<p>In Board.cs, comment the Debug.Assert on line 16.</p>
<p>Now we bypass the algorithEncoder, but this baby is working!! =D</p></div>maarten03Tue, 20 Mar 2012 16:56:17 GMTNew Post: Example 20120320045617PNew Post: Examplehttp://rushhour.codeplex.com/discussions/349350<div style="line-height: normal;">
<p>I really love your project. But I'm getting an indexoutofrangeexception on "if (s[6] == 'v')" in the AlgorithmEncoder.</p>
<p>Could you give an example of a working c:\trash.txt file?</p>
<p>I have:<br>
220003<br>
800403<br>
811403<br>
800400<br>
700055<br>
706660</p>
<p>Thanks in advance!</p>
</div>maarten03Tue, 20 Mar 2012 16:05:27 GMTNew Post: Example 20120320040527PUpdated Wiki: Homehttp://rushhour.codeplex.com/wikipage?version=5<div class="wikidoc">
<p><strong>C# implementation for Rush Hour puzzle</strong></p>
<p><strong> </strong><br>
This project focuses on Rush Hour puzzle such as the following:<br>
<br>
<img src="http://img600.imageshack.us/img600/4189/13030194.png" alt=""><br>
<br>
In Rush Hour puzzle, the red car is stuck in traffic and is trying to escape. Cars can be moved up and down or left and right. They are allowed to move more than one square in a single move, but cannot move over or through other cars. The goal is to clear a
path so that the red car can escape past the yellow arrow. <br>
<br>
<strong>A* and heuristics for Rush Hour</strong><br>
<br>
One of the main parts of this project is implementing A* and three heuristics for solving Rush Hour puzzles. Our implementation of A* should check to be sure that it is not re-exploring parts of the search space that have already been explored. The goal of
the search is to solve the puzzle in the fewest moves possible, so the cost of a search path should simply be the number of legal moves made.<br>
Here are the three heuristics that we should implement and test A* on:<br>
<br>
1. The trivial zero heuristic whose value is equal to zero in all states. Note that using A* with this heuristic is equivalent to breadth-first search.</p>
<p><br>
2. The blocking heuristic which is equal to zero at any goal state, and is equal to one plus the number of cars blocking the path to the exit in all other states. For instance, in the state above, there are two cars (namely, the two green ones) on the path
between the red car and the exit. Therefore, in this state, the blocking heuristic would be equal to three.</p>
<p><br>
3. A third, advanced heuristic of our own choosing and invention. We should aim for a heuristic that will be at least as effective as the blocking heuristic. A trivial heuristic, comparable to the zero heuristic in triviality, would not be appropriate.</p>
<p>Note that every car is constrained to only move horizontally or vertically. Therefore, each car has one dimension along which it is fixed, and another dimension along which it can be moved.
<br>
Our A* implementation will take as input a heuristic (1-3) and a string representing the names of the text file containing the initial state.</p>
<p>The output should contain:</p>
<p>1. the solution as a sequence of operations; for example:<br>
Move car # 3 down 3 squares<br>
Move car # 1 down 1 square<br>
…<br>
2. The depth of the goal state found<br>
3. The number of nodes expanded<br>
4. The branching factor<br>
5. The cost of the solution found<br>
<br>
Locations on the grid of a Rush Hour puzzle are identified by their (x, y) coordinates, where the upper left corner is square (0,0). For instance, in the puzzle above, the red car occupies squares (1,2) and (2,2). The goal is to move the red car so that it
occupies squares (5,2) and (6,2).<br>
The goal car (the one we are trying to move to the exit) is always assigned index 0. The remaining cars are indexed 1,2,4, …<br>
Puzzles should be read from a file into memory and they must be encoded as in the following example representing the puzzle above:<br>
<br>
6<br>
0 1 2 h 2<br>
1 2 0 v 2<br>
2 4 0 h 2<br>
3 3 1 v 3<br>
4 4 1 v 2<br>
5 4 3 h 2</p>
<p><br>
The first line "6", gives the size of the grid, i.e., this puzzle is defined on a 6x6 grid. The next line, "0 1 2 h 2", gives a description of the red car. The first number is the car ID. The second two numbers (1,2) give the (x, y) coordinates of the upper
left corner of the car. The "h" indicates that the car is horizontally oriented ("v" would have indicated vertical orientation). The last number "2" indicates that the car has size (i.e., length) 2. The next line, "1 2 0 v 2" describes the pink car, and so
on.</p>
<p><br>
For this Project , we can assume that the puzzle is a 6x6 grid, that the goal car always horizontally oriented.<br>
We may notice that the results we achieve for the number of nodes searched are different, and frequently better, than the sample ones above. The number of nodes searched can vary pretty widely, even among "correct" implementations, due to slight variations
involving the handling of nodes in the fringe that have the same cost. The results above were achieved for an implementation in which such ties are broken in a FIFO order, i.e., the node that was placed in the OPEN earliest is removed first, an approach that
actually appears to be suboptimal. In any case, any way we choose to handle ties is acceptable and the potential variation in results will be taken into account when grading our project. (However, see the note below under "debugging tips".)</p>
<p> </p>
<p>Abed El-Azeem Bukhari</p>
<p>abedbukhari@hotmail.com</p>
</div><div class="ClearBoth"></div>AbedBukhariThu, 20 Jan 2011 15:41:11 GMTUpdated Wiki: Home 20110120034111PUpdated Wiki: Homehttp://rushhour.codeplex.com/wikipage?version=4<div class="wikidoc">
<p><strong>C# implementation for Rush Hour puzzle</strong></p>
<p><strong> </strong><br>
This project focuses on Rush Hour puzzle such as the following:<br>
<br>
<img src="http://img600.imageshack.us/img600/4189/13030194.png" alt=""><br>
<br>
In Rush Hour puzzle, the red car is stuck in traffic and is trying to escape. Cars can be moved up and down or left and right. They are allowed to move more than one square in a single move, but cannot move over or through other cars. The goal is to clear a
path so that the red car can escape past the yellow arrow. <br>
<br>
<strong>A* and heuristics for Rush Hour</strong><br>
<br>
One of the main parts of this project is implementing A* and three heuristics for solving Rush Hour puzzles. Our implementation of A* should check to be sure that it is not re-exploring parts of the search space that have already been explored. The goal of
the search is to solve the puzzle in the fewest moves possible, so the cost of a search path should simply be the number of legal moves made.<br>
Here are the three heuristics that we should implement and test A* on:<br>
<br>
1. The trivial zero heuristic whose value is equal to zero in all states. Note that using A* with this heuristic is equivalent to breadth-first search.</p>
<p><br>
2. The blocking heuristic which is equal to zero at any goal state, and is equal to one plus the number of cars blocking the path to the exit in all other states. For instance, in the state above, there are two cars (namely, the two green ones) on the path
between the red car and the exit. Therefore, in this state, the blocking heuristic would be equal to three.</p>
<p><br>
3. A third, advanced heuristic of our own choosing and invention. We should aim for a heuristic that will be at least as effective as the blocking heuristic. A trivial heuristic, comparable to the zero heuristic in triviality, would not be appropriate.<br>
We should submitt an additional written report, we should include a clear and precise description of the advanced heuristic that we chose to implement. We also should include a brief but convincing argument of why both the blocking heuristic and our advanced
heuristic are consistent, and therefore appropriate for use with A* search.</p>
<p><br>
Note that every car is constrained to only move horizontally or vertically. Therefore, each car has one dimension along which it is fixed, and another dimension along which it can be moved.
<br>
Our A* implementation will take as input a heuristic (1-3) and a string representing the names of the text file containing the initial state.</p>
<p>The output should contain:</p>
<p>1. the solution as a sequence of operations; for example:<br>
Move car # 3 down 3 squares<br>
Move car # 1 down 1 square<br>
…<br>
2. The depth of the goal state found<br>
3. The number of nodes expanded<br>
4. The branching factor<br>
5. The cost of the solution found<br>
<br>
Locations on the grid of a Rush Hour puzzle are identified by their (x, y) coordinates, where the upper left corner is square (0,0). For instance, in the puzzle above, the red car occupies squares (1,2) and (2,2). The goal is to move the red car so that it
occupies squares (5,2) and (6,2).<br>
The goal car (the one we are trying to move to the exit) is always assigned index 0. The remaining cars are indexed 1,2,4, …<br>
Puzzles should be read from a file into memory and they must be encoded as in the following example representing the puzzle above:<br>
<br>
6<br>
0 1 2 h 2<br>
1 2 0 v 2<br>
2 4 0 h 2<br>
3 3 1 v 3<br>
4 4 1 v 2<br>
5 4 3 h 2</p>
<p><br>
The first line "6", gives the size of the grid, i.e., this puzzle is defined on a 6x6 grid. The next line, "0 1 2 h 2", gives a description of the red car. The first number is the car ID. The second two numbers (1,2) give the (x, y) coordinates of the upper
left corner of the car. The "h" indicates that the car is horizontally oriented ("v" would have indicated vertical orientation). The last number "2" indicates that the car has size (i.e., length) 2. The next line, "1 2 0 v 2" describes the pink car, and so
on.</p>
<p><br>
For this Project , we can assume that the puzzle is a 6x6 grid, that the goal car always horizontally oriented.<br>
We may notice that the results we achieve for the number of nodes searched are different, and frequently better, than the sample ones above. The number of nodes searched can vary pretty widely, even among "correct" implementations, due to slight variations
involving the handling of nodes in the fringe that have the same cost. The results above were achieved for an implementation in which such ties are broken in a FIFO order, i.e., the node that was placed in the OPEN earliest is removed first, an approach that
actually appears to be suboptimal. In any case, any way we choose to handle ties is acceptable and the potential variation in results will be taken into account when grading our project. (However, see the note below under "debugging tips".)</p>
<p> </p>
<p>Abed El-Azeem Bukhari</p>
<p>abedbukhari@hotmail.com</p>
</div><div class="ClearBoth"></div>AbedBukhariThu, 20 Jan 2011 15:29:12 GMTUpdated Wiki: Home 20110120032912PCreated Release: rushHourV1.0http://rushhour.codeplex.com/releases?ReleaseId=59491<div class="wikidoc">First version of RushHour Puzzle implementation using C#</div><div class="ClearBoth"></div>AbedBukhariThu, 20 Jan 2011 15:15:30 GMTCreated Release: rushHourV1.0 20110120031530P