Project Help Wanted
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherProject Help Wanted

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 26th, 2003, 03:31 AM
TrustNo1 TrustNo1 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 TrustNo1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow prolog easy program.. Easy $$

Hi,
anyone can figure this problem.

It is a 3x3 number puzzle. We start with for example,

+------+------+------+
| 1 | 2 | x |
+------+------+------+
| 4 | 5 | 3 |
+------+------+------+
| 7 | 8 | 6 |
+------+------+------+

uses 'x' to indicate where the empty position currently is in one state. we want to end up with the below shape at the final state:

+------+------+------+
| 1 | 2 | 3 |
+------+------+------+
| 4 | 5 | 6 |
+------+------+------+
| 7 | 8 | x |
+------+------+------+

we are given this code and only need the code for move:

solution(Row1,Row2,Row3,History) :-
move(Row1,Row2,Row3,NewRow1,NewRow2,NewRow3),
\+ member(state(NewRow1,NewRow2,NewRow3),History),
solution(NewRow1,NewRow2,NewRow3,[state(Row1,Row2,Row3)|History]).

The first three arguments are representations of each of the three rows in the puzzle. The fourth argument 'History' is a list of previous states that we have traveled through.

Anyways, calling
?- solution([1,2,x],[4,5,3],[7,8,6],[]).

should solve the puzzle.

This should be easy for any prolog programmer, I just don't know prolog so any takers, please reply or e-mail me at URL
Thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherProject Help Wanted > prolog easy program.. Easy $$


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway