//general cd to be included in classic/csp version of the game


package gen;

import edu.neu.ccs.demeterf.demfgen.lib.*;


nogen List(X) : Cons(X) | Empty(X).
nogen Cons(X) = <first> X <rest> List(X).
nogen Empty(X) = .

nogen Option(X): Some(X) | None(X).
nogen Some(X) = <just> X.
nogen None(X) = .

Pair(A,B) = *s <a> A *s <b> B *s.

Variable = <v> String.
Weight = <val> int.
Price = <val> double.
Quality = <val> double.
PlayerID = <id> int.
Relation = <num> int.
Pos = "+".
Neg = "-".





Constraint = *s <weight>Weight *s <relation>Relation *s <variables>List(Variable) *s.
Assignment = "assign""["<literals>List(Literal)"]".
Literal = *s <sign> Sign *s <var> Variable *s.
Sign: Pos|Neg.


Player = "player" *s <id>PlayerID *s <name>String.

Type = "type" "[" <instances> List(TypeInstance) "]".
Derivative = "deriv" "[" <name>String *s <seller>PlayerID *s <optbuyer>Option(PlayerID) *s <price>Price *s <type>Type *s <optraw>Option(RawMaterial) *s <optfinished>Option(FinishedProduct)"]".
RawMaterial = "rm""["<instance>RawMaterialInstance"]".
FinishedProduct =  "finish""["<ip>IntermediateProduct *s <quality>Quality"]".


History = "history""["<rounds>List(Round)"]".
Round = "round" *s<num> int *s "["<ptransactions>List(PlayerTransaction)"]".
PlayerTransaction = "ptrans""["<player>Player *s <transactions>List(Transaction)"]".
Transaction = "trans""["<ttype>TransactionType *s <deriv>Derivative"]".
TransactionType: Buy|Create|Reoffer|Deliver|Finish.

Buy = "BUY".
Create = "CREATE".
Reoffer = "REOFFER".
Deliver = "DELIVER".
Finish = "FINISH".

Players = "players""["<players>List(Player)"]".

Accounts = "accounts""["<accounts>List(Pair(PlayerID,Double))"]".

Store = "store""["<stores>List(Pair(PlayerID,PlayerStore))"]".
PlayerStore = "pstore" *s "forsale" *s <forSale>List(Derivative) *s "bought" *s <bought>List(Derivative).

Config = <init>double *s <maxRounds>int *s <timeslot>int *s <mindec>double.