sumedhghaisas / libgdl

C++ General Game Playing library
Other
4 stars 1 forks source link

A GGP game #8

Open Bonkebo opened 9 years ago

Bonkebo commented 9 years ago

Hi,I have a question about a GGP game.Can you help me? Thanks!

Here is a very ancient game originated from China: Tiger vs Dogs. In the above 4X4 board(5 rows,5columns), there are one tiger (represented by a white stone in the center) and 16 dogs (represented by black stones in the perimeter). The tiger is controlled by the tiger player and the dogs are controlled by the dog player. The tiger player goes rst and then they take turns. Each player can go one step along the line to an adjacent position that is not occupied. When the tiger enters a position such that the following condition hold \two dogs are adjacent to this position such that they three are in the same line, and also these two dogs have no adjacent dogs in the same line", then these two dogs are killed by the tiger. If 6 dogs are killed, then the tiger player wins and the dog player loses. When the dogs surrounded the tiger such that there is no unoccupied adjacent position for the tiger to move, then the tiger player loses and the dog player wins.

Write a game description in GDL (KIF form) for this game.

sumedhghaisas commented 9 years ago

Hey, Sure I will definitely try. Just have couple of doubts (I tried to google this game but didn't find it so couldn't find the answers I was looking for.)

1) How do you define adjacent when you are making a move?? I mean is diagonal move allowed? 2) (Assuming diagonal moves are not allowed) What happens when the tiger is surrounded by 3 dogs in adjacent cells? Do the two dogs in the same line still die?

Bonkebo commented 9 years ago

hi,thank you for reply 1) diagonal move is not allowed. 2) when the tiger is surrounded by 3 dogs in adjacent cells , the tiger just has only on cell to move. when two dogs and the tiger in the same line(for example a row),and these two dog have no adjacent dogs in another line(for example dogXs column, dogYs column ).

sumedhghaisas commented 9 years ago

Okay I have understood following things confirm if they are right...

1) The game is played on the standard Alquerque board 2) Its a typical tiger hunt game which has many versions. (I am unable to find this version, if you have some specific name to this game then tell me) 3) The initial position is this... (H represents blank cell, W is tiger and B is Dog)

B B B B B B H H H B B H W H B B H H H B B B B B B

4) Tiger player and dog player takes chances alternatively. 5) ADJACENT cell is defined without diagonal cells. 6) Each move consist of moving in adjacent cell. 7) Its an infinite game as in it can go on forever thus we need to add some step count termination in GDL 8) For dog player to win tiger has to die. The situation in which a tiger dies is this... B B W B B

9) For the tiger player to win 6 dogs have to die. Various situations in which dogs die are...

Sorry for the inconvenience but I am little bit confused about how the dogs are killed... Tell me if my understanding is correct and if there are more cases add them.

Bonkebo commented 9 years ago

It`s amazing! Your understanding is right! Tips: H H B H H H B W B H --- tiger lose H H B H H Because "When the dogs surrounded the tiger such that there is no unoccupied adjacent position for the tiger to move, then the tiger player loses and the dog player wins." And The tiger player goes first.

sumedhghaisas commented 9 years ago

Ahh yes... I meant the same scenario in tiger lose. I forgot that the markdown nullifies the blacks. :P I will try writing the game in GDL with given knowledge...

Bonkebo commented 9 years ago

OK!

sumedhghaisas commented 9 years ago

(role Tiger) (role Dog)

( <= (base (piece ?x ?y ?z)) (board_number ?x) (board_number ?y) (piece_type ?z))

( <= (base (control ?x)) (role ?x)) ( <= (base (double_dog_count ?x)) (double_dog_count_n ?x)) ( <= (base (step ?x)) (successor ?x ?y))

( <= (input Tiger (move ?x ?y)) (board_number ?x) (board_number ?y))

( <= (input Dog (move ?x ?y ?a ?b)) (board_number ?x) (board_number ?y) (board_number ?a) (board_number ?b))

( <= (input ?x noop) (role ?x))

(init (piece 1 1 D)) (init (piece 1 2 D)) (init (piece 1 3 D)) (init (piece 1 4 D)) (init (piece 1 5 D)) (init (piece 2 1 D))

(init (piece 2 5 D)) (init (piece 3 1 D)) (init (piece 3 3 T)) (init (piece 3 5 D)) (init (piece 4 1 D)) (init (piece 4 5 D)) (init (piece 5 1 D)) (init (piece 5 5 D)) (init (double_dog_count 8)) (init (control Tiger)) (init (step 1))

( <= (legal Tiger (move ?x ?y)) (true (control Tiger)) (true (piece ?a ?y T)) (adj_num ?x ?a) (not (true (piece ?x ?y ?z))))

( <= (legal Tiger (move ?x ?y)) (true (control Tiger)) (true (piece ?x ?b T)) (adj_num ?y ?b) (not (true (piece ?x ?y ?z))))

( <= (legal Dog (move ?x ?y ?a ?y)) (true (control Dog)) (true (piece ?x ?y D)) (adj_num ?x ?a) (not (true (piece ?a ?y ?z))))

( <= (legal Dog (move ?x ?y ?x ?b)) (true (control Dog)) (true (piece ?x ?y D)) (adj_num ?y ?b)) (not (true (piece ?x ?b ?z))))

( <= (legal ?x noop) (not (true (control ?x)))

( <= (next (piece ?x ?y T)) (does Tiger (move ?x ?y)))

( <= (next (piece ?x ?y D)) (true (piece ?x ?y D)) (not (does Dog (move ?x ?y ?a ?b))) (not (kill_dog ?x ?y)))

( <= (next (piece ?x ?y D)) (does Dog (move ?a ?b ?x ?y)))

( <= (next (step ?x)) (true (step ?y)) (successor ?y ?x))

( <= (kill_dog ?x ?y) (kill_dogs ?x ?y ?a ?b)) ( <= (kill_dog ?x ?y) (kill_dogs ?a ?b ?x ?y))

( <= (kill_dogs ?x ?y ?a ?y) (does Tiger (move ?c ?y)) (successor ?x ?c) (successor ?c ?a) (true (piece ?x ?y D)) (true (piece ?a ?y D))) (not (h_adj ?x ?y D)) (not (h_adj ?a ?y D)))

( <= (kill_dogs ?x ?y ?x ?b) (does Tiger (move ?x ?c)) (successor ?y ?c) (successor ?c ?b) (true (piece ?x ?y D)) (true (piece ?x ?b D)) (not (v_adj ?x ?y D)) (not (v_adj ?x ?b D)))

( <= (h_adj ?x ?y ?z) (adj_num ?a ?x) (true (piece ?a ?y ?z)))

( <= (v_adj ?x ?y ?z) (adj_num ?y ?b) (true (piece ?x ?b ?z)))

( <= kill_tiger (true (piece ?x ?y T)) (true (piece ?a ?y D)) (true (piece ?x ?b D)) (true (piece ?c ?y D)) (true (piece ?x ?d D)) (successor ?a ?x) (successor ?x ?c) (successor ?b ?y) (successor ?y ?d))

( <= terminal kill_tiger) ( <= terminal (step 15))

( <= (goal Tiger 0) (not (double_dog_count 3))) ( <= (goal Tiger 50) (step XXX) (not (double_dog_count 3)) (not kill_tiger)) ( <= (goal Tiger 100) (double_dog_count 3))

( <= (goal Dog 0) (not kill_tiger)) ( <= (goal Dog 50) (step XXX) (not (double_dog_count 3)) (not kill_tiger)) ( <= (goal Dog 100) kill_tiger)

( <= (adj_num ?x ?y) (or (successor ?x ?y) (successor ?y ?x)))

(piece_type T) (piece_type D)

(board_number 1) (board_number 2) (board_number 3) (board_number 4) (board_number 5)

(double_dog_count_n 1) (double_dog_count_n 2) (double_dog_count_n 3) (double_dog_count_n 4) (double_dog_count_n 5) (double_dog_count_n 6) (double_dog_count_n 7) (double_dog_count_n 8)

(successor 1 2) (successor 2 3) (successor 3 4) (successor 4 5) (successor 5 6) (successor 6 7) (successor 7 8) (successor 8 9) (successor 9 10) (successor 10 11) (successor 11 12) (successor 12 13) (successor 13 14) (successor 14 15)

sumedhghaisas commented 9 years ago

Check if its right...

Bonkebo commented 9 years ago

Greate! I will run it tomorrow. Thank you !

Bonkebo commented 9 years ago

image Do you known about GameController,I run the code witch you provide.

Bonkebo commented 9 years ago

I pasted the code to tigerDog.gdl .

Bonkebo commented 9 years ago

I am terribly sorry to bother you again for this question. my teacher told me that diagonal move is allowed and gave me the examples: 1 2 3 4

sumedhghaisas commented 9 years ago

Hey... I am sorry for the late response... I was actually on a summer vacation and did not have stable internet connection. I see you are getting some errors while parsing the code. I will look into it and try to change the game with new rules.

Bonkebo commented 9 years ago

thank you,you are a good man.

sumedhghaisas commented 9 years ago

Hey... So I had couple of problems while writing the game..

1) In above examples... in first example... The dog directly above and below should die because they are not supported by any dogs... Basically when Tiger moved in that position those 2 dogs must have died... so this position is not possible

2) secondly there can be situation where 2 pair of dogs can die... like in that same first example 2 pairs of dogs are dying... the diagonal ones and vertical ones... what happens in such situations??

Bonkebo commented 9 years ago

I think Judging the dogs or tiger died is after they moving. so in the first example is the situation of "When the dogs surrounded the tiger such that there is no unoccupied adjacent position for the tiger to move, then the tiger player loses and the dog player wins."

the gamecontroller is there https://drive.google.com/file/d/0BxnyuaOSdSDqNVNfamIzM1pyMlk/view?usp=sharing the description is : _20150916094415

sumedhghaisas commented 9 years ago

Yes I am assuming the death of any piece is after the another player moves. Even then I think situation 1 cannot happens -

Lets trace the move sequence after which this situation occurs... To get the tiger in that position the board before Tiger's move should look like this...

D . . .
D1 D2 D3 D4
D5 . T D6
D7 D8 D9 D10

------------->After Left move

D . . . D1 D2 D3 D4 D5 T . D6 D7 D8 D9 D10

Now as soon as Tiger makes his move to left D2 and D8 will die because them have no support. In this case D1 and D9 should also die because even they have no support. This is my second concern. Is it legal for 2 pair of Dogs to die??

I am extremely sorry if I missing something and feel free to point out. But if indeed my concern is true this game looks much biased towards the Tiger player. I am sort of able to prove that there is only handful of move sequences in which Dog player wins.

Bonkebo commented 9 years ago

yes I think you are right,because of the discription "two dogs are adjacent to this position such that they three are in the same line, and also these two dogs have no adjacent dogs in the same line" . D1,D9 and D2,D8 will die.

sumedhghaisas commented 9 years ago

yes... In this case killing the tiger is extremely difficult... I mean think about it... I would recommend to check the rules of this game with your teacher again. Ask him about this issue and what happens in it.

Bonkebo commented 9 years ago

‘two dogs have no adjacent dogs in the same line’ the 'same line' also means another line. as long as the the other dogs and these two dog in the same line. ![Uploading 1890fdc8-5356-11e5-94be-99cbc6f416ef.png…]()

Bonkebo commented 9 years ago

‘two dogs have no adjacent dogs in the same line’ the 'same line' also means another line. as long as the the other dogs and these two dog in the same line. 1890fdc8-5356-11e5-94be-99cbc6f416ef

sumedhghaisas commented 9 years ago

I am not sure if I understood that properly. Can you please elaborate it a little??

I am confused between the 'same line' and 'another line'.

Bonkebo commented 9 years ago

D1 D2 D3 D4 D5 T D6 D7 D8 D9 D10

we thought D1,D9 D2,D9 would die. now , I find it is wrong, because the D5,D1 in the line and D2,D1 in the same line ,so D1 has adjacent dogs in the same line and D1 will not die,how do you think so ?

sumedhghaisas commented 9 years ago

you are saying D5 and D1 in the same line as D2 and D1?? D5 and D1 are in vertical line and D2 and D1 are in horizontal line... and D1, T and D9 are in diagonal line.

So lets take the description given to us ...

"When the tiger enters a position such that the following condition holds - 2 dogs are adjacent to this position such that they are in the same line" This condition holds as D1, T and D9 are in a diagonal line. then the second part "and also these 2 dogs have no adjacent dogs in the same line. " Now you are saying that here the same line does not refer to the same diagonal line right??

Bonkebo commented 9 years ago

yes, I consider that 'same line ' including the vertical line, horizontal line and diagonal line ,so long as the dogs in the line

sumedhghaisas commented 9 years ago

I am sorry but I am still unable to understand the exact rule. Can you please elaborate with more examples?? which shows the application of this rule??

Bonkebo commented 9 years ago

hi, my teacher said it was good which you gave to me . otherwise it is really hard to think about the final result. I give up this problem So I think we need not to george it any more. ^_^

Song-Ji commented 8 years ago

Is there a correct gdl for this game? Bonkebo and sumedhghaisas ?

sumedhghaisas commented 8 years ago

@Song-Ji Depends :) what are the correct rules??

Song-Ji commented 8 years ago

Hi sumdhghaisas

below is the correct rules . and I also give some examples for u to totally understand.

screen shot 2016-05-30 at 23 52 22 screen shot 2016-05-30 at 23 52 09