Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Rush Hour Project
Author Message
Panphobia

Posted: Sat Dec 15, 2012 6:12 pm   Post subject: Re: Rush Hour Project

Currently, I have a grid/graph that i could read from in a text file,
 code: * * * * * * * * * 2 2 . . . 7 * * 1 . . 5 . 7 * * 1 0 0 5 . 7 A * 1 . . 5 . . * * 3 . . . 4 4 * * 3 . 6 6 6 . * * * * * * * * *
If the number modulo 2 not 1 than it moves vertically, else moves horizontally, and 0 is start car, now what I am thinking to do is to go through all the possible ways to solve the game, and then keep getting the minimum amount of moves, this algorithm should not be too hard BUT, it might run infinitely, any suggestions?
Sponsor
Sponsor

Insectoid

Posted: Sat Dec 15, 2012 6:47 pm   Post subject: RE:Rush Hour Project

There's a finite number of moves and states. If it reaches a state you've been to before, don't go any further down that branch. Alternatively, you can set a limit on depth. If you're a hundred moves deep, don't go further down that branch.
Panphobia

Posted: Sat Dec 15, 2012 6:51 pm   Post subject: RE:Rush Hour Project

So how would I map something that has already happened, is there a function for that?
Insectoid

Posted: Sat Dec 15, 2012 7:20 pm   Post subject: RE:Rush Hour Project

There is no such function. However, you can save the map states as you progress. It's probably easier to just add a depth limitation though. Saving each map can take up a lot of RAM, and Rush Hour hasn't doesn't take up that many moves to win. a 100-move limit is very reasonable.
Panphobia

Posted: Sat Dec 15, 2012 7:45 pm   Post subject: RE:Rush Hour Project

ahhh yeaa considering the most advanced rush hour game only has 93 moves, i should make a limit to 93, thanks
Panphobia

Posted: Sat Dec 15, 2012 9:01 pm   Post subject: RE:Rush Hour Project

by the way, how can you keep a certain car from not moving backwards and forwards until the limit and then restarting over and over again infinitely, is there a way to stop this? also is there a good way to save an incorrect solution in a type of variable to not repeat it again
Panphobia

Posted: Sun Dec 16, 2012 4:54 pm   Post subject: RE:Rush Hour Project

is there any function that saves previous moves that are proved to not help a solution, so the program does not loop over these moves infinitely?
Insectoid

Posted: Sun Dec 16, 2012 5:18 pm   Post subject: RE:Rush Hour Project

No. You'll have to write that function yourself.
Sponsor
Sponsor

 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 2  [ 23 Posts ]
Goto page Previous  1, 2
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: