This page explains the potential formatting of rules in GGL-II.
Number of Players determined by number of player roles:
(role random) ;always included (role player1) (role player2) (role player3) (role player4)Player Teams determined by init states:
(init (Player1 team 1)) (init (player2 team 2)) (init (player3 team 1)) (init (player4 team 2))Team Membership Logic Checking to determine if a move is legal when directed at a team member or non-team member
(true (?player team ?x)) ;set player team variable (true (?target team ?y)) ;set target team variable (distinct ?x ?y) ;must be different teams (not (distinct ?x ?y)) ;must be same teamUnique Player Classes determined by init states (each class may have different rules they follow):
(init (class 1)) (init (class 2)) (init (Player1 class 1)) (init (player2 class 1)) (init (player3 class 2)) (init (player4 class 2))Class Checking Logic to determine if a move is legal for a player of a certain class
(true (?player class ?x)) ;creates variables (not (distinct ?x 1)) ;makes sure player is class 1
Decks determined by init states (discard piles count as decks), also determines ownership:
(init (deck main 1)) ;primary deck (init (deck main 2)) ;secondary deck (init (deck discard 1)) ;primary discard pile (init (deck player1 1)) ;Primary deck for player 1Max Size of Decks determined by init states:
(init (maxDeckSize deck main 1 10)) ;low numbers restrict deck sizes (init (maxDeckSize deck discard 1 500)) ;huge numbers mean there is no real limit (good for discard piles)Current Deck Card Count to keep track of how many cards in a deck:
(init (deckSize deck main 1 52)) ;sets the initial deck size at the start of the game (must match number of initial cards in deck!)Deck Checking Logic to determine if the move is legal on a deck:
(true (deck ?owner ?d)) ;sets deck variable (not (distinct ?d 2)) ;makes sure the deck is deck 2 (not (distinct ?owner ?player)) ;makes sure player performing action owns deck
Hand Ownership including hand number if multiple are used:
(init (hand player1 1)) ;Primary hand of player 1 (init (hand player1 2)) ;Secondary hand of player 1Max Hand Size determined by init states:
(init (maxHandSize player1 1 7) ;sets primary hand for player 1 to a max of 7 cardsCurrent Hand Size to keep track of the number of cards in a hand:
(init (handSize player1 1 0)) ;sets the initial hand size at the start of the game (must match number of initial cards in hand!)Hand Check Logic to determine if a move on a hand is legal:
(true (hand ?owner ?x)) ;set variables for owner and which hand (not (distinct ?player ?owner)) ;Make sure the player is the owner (not (distinct 1 ?x)) ;make sure the hand is the primary handHand Persistence to enable the current hand to continue between states
(<= (next (hand ?player ?h))(true (hand ?player ?h)))
Incrementors and Decrimentors to change numeric values because arithmetic is not allowed in GDL
(++ 0 1) (++ 1 2) (++ 2 3) (++ 3 4) (++ 4 5) ;states that enable change in values by 1, add as needed (<= (next (?x))(true (?y))(++ ?x ?y)) ;decrements y to x, eg: y=4, then to make true, x=3, so next stage, the value x refers to will be 3. (<= (next (?x))(true (?y))(++ ?y ?x)) ;increments y to x, eg: y=3, then to make true, x=4, so next stage, the value x refers to will be 4. (+5 0 5) ;can add larger increments/decrementsGreater Than or Less Than for numeric comparisons, requires incrementors/decrementors
(<= (greater_than_equals ?x ?x) (++ ?x ?y)) ;?x and ?y are equal, remove this to make strictly greater than (<= (greater_than_equals ?x ?y) (++ ?y ?x)) ;?y is greater than ?x, swap inputs to do less than (<= (greater_than_equals ?x ?y) (++ ?z ?x) (greater_than_equals ?z ?y)) ;recursion in the case they are more than 1 value different (greater_than_equals ?x ?y) ;?x must be greater than ?y (greater_than_equals ?y ?x) ;?y must be greater than ?xAdding enables the adding of two values, requires incrementors/decrementors
(<= (add 0 ?prev ?prev) (++ ?prev ?x)) ;base case for adding 0 (<= (add 1 ?y ?z) (++ ?y ?z)) ;base case for adding 1, just uses increment (<= (add ?x ?y ?z) (++ ?littlex ?x) (add ?littlex ?y ?littlez) (++ ?littlez ?z)) ;recursion to add numbers greater than 1, x=add y=current z=output