Prolog Logic games 
Author Message
 Prolog Logic games

Hi everybody

I'm interesting in getting some tips where can I find informations about a
specific prolog program. It has a 8x8 chess board and has to put first 8
queens, then 8 rooks, next 8 bishops, 8 knights and finally 8 kings.
Ofcourse none two the same mens checks. Program has two versions : in first
mens are transparent, in second non-transparent - I'll be happy if I get a
solution to any of them :)

I'm interesting also in other logic games such a you have 2 dishes : 8 l
and 5 l of water and your aim is to get 4 l in the bigger one.

I'll be glad if anybody could help me. Thanks in advance.

--
Greetings from Poland
Grzesiek



Sat, 25 Jun 2005 08:39:51 GMT  
 Prolog Logic games
Look up the following:
- iterative deepening (for the water problem); and
- constraint satisfaction problems (CSP) (for the chess problems),
specifically
   - fail first; and
   - forward checking.

Ralph

Quote:

> Hi everybody

> I'm interesting in getting some tips where can I find informations about a
> specific prolog program. It has a 8x8 chess board and has to put first 8
> queens, then 8 rooks, next 8 bishops, 8 knights and finally 8 kings.
> Ofcourse none two the same mens checks. Program has two versions : in first
> mens are transparent, in second non-transparent - I'll be happy if I get a
> solution to any of them :)

> I'm interesting also in other logic games such a you have 2 dishes : 8 l
> and 5 l of water and your aim is to get 4 l in the bigger one.

> I'll be glad if anybody could help me. Thanks in advance.



Sat, 25 Jun 2005 21:38:33 GMT  
 Prolog Logic games

Quote:

> Look up the following:
> - iterative deepening (for the water problem); and

the water jug problem has a finite (and small) state space, so you are satified with
any solution rather than with the smallest one, you can as well do exhaustive search
while avoiding infinite loops
the state space is so small, that you can even do a findall for retrieving all solutions and
then pick the shortest one

Cheers

Bart Demoen



Sat, 25 Jun 2005 23:16:35 GMT  
 Prolog Logic games
"Grzesiek" wrote :

Quote:
> Hi everybody

> I'm interesting in getting some tips where can I find informations about a
> specific prolog program. It has a 8x8 chess board and has to put first 8
> queens, then 8 rooks, next 8 bishops, 8 knights and finally 8 kings.
> Ofcourse none two the same mens checks. Program has two versions : in
first
> mens are transparent, in second non-transparent - I'll be happy if I get a
> solution to any of them :)

> I'm interesting also in other logic games such a you have 2 dishes : 8 l
> and 5 l of water and your aim is to get 4 l in the bigger one.

> I'll be glad if anybody could help me. Thanks in advance.

> --
> Greetings from Poland
> Grzesiek

About the chess problem...
Start by solving the "8-queens" problem.

Then add 8 rooks to the board, then 8 bishops, etc.

We discussed the 8-queens problem in this newsgroup before.
I don't know if we wrote anything useful to you ;
I don't think we wrote how to solve it.
But you can have a look at what we wrote here :

http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=queens&meta...
3Dcomp.lang.prolog

Hint : You don't need to use lists to solve the 8-queens problem.
You can do it with simple basic prolog.

--
Martin Sondergaard,
London.



Sun, 26 Jun 2005 22:54:34 GMT  
 Prolog Logic games

Quote:
> the water jug problem has a finite (and small) state space, so you are satified with
> any solution rather than with the smallest one, you can as well do exhaustive search

thx - I found this problem in a book 'Logic Programming and Prolog' and
it's simple now :>

--
Greetings from Poland
Grzesiek



Mon, 27 Jun 2005 07:04:47 GMT  
 Prolog Logic games

Quote:
> About the chess problem...
> Start by solving the "8-queens" problem.

> Then add 8 rooks to the board, then 8 bishops, etc.

OK. Thx for advices. Frankly speaking I thought about this strategy. The
main problem now is to check if place is empty. But I'm sure I can find
more infos in the I-net :>

Once again - thanks for anybody :)

P.S.
Sorry for next problem, but anyone can help ?
I've a program for N-queens problem. It looks like this :

queens(N,Qs) :- gen_list(N,Qs),place_queens(N,Qs,_,_).

gen_list(0,[]).
gen_list(N,[_|L]) :- N>0, M is N-1, gen_list(M,L).

place_queen(I,[I|_],[I|_],[I|_]).
place_queen(I,[_|Cs],[_|Us],[_|Ds]) :- place_queen(I,Cs,Us,Ds).

place_queens(0,_,_,_).
place_queens(I,Cs,Us,[_|Ds]) :- I>0, J is I-1,  
                         place_queens(J,Cs,[_|Us],Ds),
                         place_queen(I,Cs,Us,Ds).

It works fine, but I cannot execute sth like this:
?- queens(N,[_,8,3,_,N|_]).

Any ideas how to correct/write another one program ?

--
Greetings from Poland
Grzesiek



Mon, 27 Jun 2005 07:34:27 GMT  
 Prolog Logic games

Quote:

> queens(N,Qs) :- gen_list(N,Qs),place_queens(N,Qs,_,_).

> gen_list(0,[]).
> gen_list(N,[_|L]) :- N>0, M is N-1, gen_list(M,L).
> It works fine, but I cannot execute sth like this:
> ?- queens(N,[_,8,3,_,N|_]).

> Any ideas how to correct/write another one program ?

What exactly is it you want to compute: values for N such that the NxN queens problem
has a solution with a queen on position (N,5) and also on (8,2) and (3,3)?
Since gen_list needs its first argument instantiated, you better generate values for N
before you call queens(N,[_,8,3,_,N|_]).
As in

    ?- gen(N), queens(N,[_,8,3,_,N|_]).

Cheers

Bart Demoen



Mon, 27 Jun 2005 16:35:34 GMT  
 Prolog Logic games

Quote:
> What exactly is it you want to compute: values for N such that the NxN queens problem
> has a solution with a queen on position (N,5) and also on (8,2) and (3,3)?

I have to find the maximum N in 5 minutes time....

--
Greetings from Poland
Grzesiek



Wed, 29 Jun 2005 05:19:41 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. game theoretic semantics, dialogic logic & dialogue games

2. AI Game Logic

3. game programming + functional/logic languages

4. game programming + functional/logic languages

5. game programming + functional/logic languages

6. I need 10*10 Checkers game source code in prolog

7. Life game in prolog - need urgent help!!!!

8. hi searching othello game in prolog Please help !!

9. Prolog games...

10. games sources in prolog

11. Othello game in prolog

12. Reversi game with prolog

 

 
Powered by phpBB® Forum Software