gdl/meier.gdl @ 3c9facf27dea

Clean up next-iset computation API
author Steve Losh <steve@stevelosh.com>
date Sat, 25 Feb 2017 16:17:01 +0000
parents 61661613f7b8
children (none)
(role random)

(role p1)
(role p2)


(init (rolling_for p1))
(init (previous_claimed_values 0 0))
; 00: artificial first value, lower than any other




; rolling phase

(<= (legal random (roll ?p ?x ?y))
	(true (rolling_for ?p))
	(number ?x)
	(number ?y)
)

(<= (legal ?p noop)
	(role ?p)
	(distinct ?p random)
	(true (rolling_for ?q))
)

(<= (next (has_dice ?p ?x ?y))
	(does random (roll ?p ?x1 ?y1))
	(sort ?x1 ?y1 ?x ?y)
)

(<= (sort ?x ?y ?x ?y)
	(leq ?y ?x)
)

(<= (sort ?y ?x ?x ?y)
	(leq ?y ?x)
)

(<= (sees ?p (my_dice ?x ?y))
	(does random (roll ?p ?x ?y))
)

(<= (next (claiming ?p)) ; transition
	(true (rolling_for ?p))
)


; claiming phase (bluff or not)

(<= (legal ?p (claim ?x ?y))
	(true (claiming ?p))
	(true (previous_claimed_values ?mx ?my))
	(better_values ?mx ?my   ?x ?y)
)

(<= (legal ?q noop)
	(role ?q)
	(true (claiming ?p))
	(distinct ?q ?p)
)

(<= (sees ?q (does ?p ?m))
	(role ?q)
	(does ?p ?m)
	(distinct ?p random)
	; (distinct ?q ?p)
	; (distinct ?q random)
)

(<= (next (guessing ?q))
	(does ?p (claim ?x ?y))
	(next_player ?p ?q)
)

(<= (next (previous_claimed_values ?x ?y))
	(does ?p (claim ?x ?y))
)


; guessing phase

(<= (legal ?p you_bluff)
	(true (guessing ?p))
)

(<= (legal ?p ask_roll)
	(true (guessing ?p))
	(not (true (previous_claimed_values 2 1)) )
)

(<= (legal ?q noop)
	(role ?q)
	(true (guessing ?p))
	(distinct ?q ?p)
)

(<= (next (rolling_for ?p))
	(does ?p ask_roll)
)

(<= (next (game_over ?p) )
	(does ?p you_bluff)
)


; game over

(<= terminal
	(true (game_over ?p))
)

(<= (goal ?q 100)
	(true (game_over ?q))
	(next_player ?p ?q)
	(true (has_dice ?p ?x ?y))
	(not (true (previous_claimed_values ?x ?y)) )
)

(<= (goal ?p 100)
	(true (game_over ?q))
	(next_player ?p ?q)
	(true (has_dice ?p ?x ?y))
	(true (previous_claimed_values ?x ?y))
)

(<= (goal ?q 0)
	(true (game_over ?q))
	(next_player ?p ?q)
	(true (has_dice ?p ?x ?y))
	(true (previous_claimed_values ?x ?y))
)

(<= (goal ?p 0)
	(true (game_over ?q))
	(next_player ?p ?q)
	(true (has_dice ?p ?x ?y))
	(not (true (previous_claimed_values ?x ?y)) )
)

(goal random 100)




; conservation rule

(<= (next (previous_claimed_values ?x ?y))
	(true (previous_claimed_values ?x ?y))
	(not claims_any)
)

(<= claims_any
	(does ?p (claim ?x ?y))
)

(<= (next (has_dice ?p ?x ?y))
	(true (has_dice ?p ?x ?y)) ; stays true until some other dice are rolled
	(not any_roll)
)

(<= any_roll
	(role ?p)
	(number ?x)
	(number ?y)
	(does random (roll ?p ?x ?y))
)





(number 1)
(number 2)
(number 3)
(number 4)
(number 5)
(number 6)

(succ 1 2)
(succ 2 3)
(succ 3 4)
(succ 4 5)
(succ 5 6)


(<= (leq ?x ?x)
	(number ?x)
)

(<= (leq ?x ?y)
	(succ ?x ?i)
	(leq ?i ?y)
)



(succ_values 0 0   3 1)

(succ_values 3 1   3 2)
(succ_values 3 2   4 1)

(succ_values 4 1   4 2)
(succ_values 4 2   4 3)
(succ_values 4 3   5 1)

(succ_values 5 1   5 2)
(succ_values 5 2   5 3)
(succ_values 5 3   5 4)
(succ_values 5 4   6 1)

(succ_values 6 1   6 2)
(succ_values 6 2   6 3)
(succ_values 6 3   6 4)
(succ_values 6 4   6 5)
(succ_values 6 5   1 1)

(succ_values 1 1   2 2)
(succ_values 2 2   3 3)
(succ_values 3 3   4 4)
(succ_values 4 4   5 5)
(succ_values 5 5   6 6)
(succ_values 6 6   2 1)



(<= (better_values ?mx ?my  ?x ?y)
	(succ_values ?mx ?my  ?x ?y)
)

(<= (better_values ?mx ?my  ?x ?y)
	(succ_values ?mx ?my  ?ix ?iy)
	(better_values ?ix ?iy  ?x ?y)
)



(next_player p1 p2)
(next_player p2 p1)