Module Arena

module Arena: sig .. end
Represent the game arena and operate on it.

type label = {
   lb_rule :string;
   time_in :float * float;
   parameters_in :(string * (float * float)) list;
}
A single move consists of applying a rewrite rule for a time from the time_in interval, and parameters from the interval list.
type player_loc = {
   payoff :Formula.real_expr;
   moves :(label * int) list;
   view :Formula.formula * (string * Formula.formula) list;
   heur :float list;
}
A game has locations. In each one, each player has 0 or more possible moves, each with a label, to one of the next locations. We also store the view (see elsewhere) and weights for heuristics. If no moves are possible, everyone gets a payoff. Players are indexed continuously starting from 0.
type game = {
   rules :(string * ContinuousRule.rule) list;
   patterns :Formula.real_expr list;
   graph :(player_loc array * string list) array;
   num_players :int;
   player_names :(string * int) list;
   data :(string * string) list;
   defined_rels :(string * (string list * Formula.formula)) list;
   starting_struc :Structure.structure;
}
The basic type of Arena.
type move = {
   mv_time :float;
   parameters :(string * float) list;
   rule :string;
   next_loc :int;
   matching :(string * string) list;
}
Move - complete basic action data. *
type game_state = {
   struc :Structure.structure;
   time :float;
   cur_loc :int;
   history :(move * float option) list;
}
State of the game.
val empty_state : game * game_state
val equal_state : game_state -> game_state -> bool
val make_move : move -> game * game_state -> game * game_state
Make a move in a game.
val matching_of_names : game * game_state ->
string -> (string * string) list -> (string * int) list
Translate from names to elements to get rule embedding.
val rules_for_player : int -> game -> string list
Rules with which a player with given number can move.
val label_str : label -> string
Print a label as a string.
val move_str : label * int -> string
Print a game as a string.
val str : game -> string
val state_str : game * game_state -> string
Print the whole state: the game, structure, time and aux data.
val equational_def_style : bool Pervasives.ref
Whether to print relation definitions as equations, or using the C syntax. Defaults to true.
val fprint_state_full : ?ext_struct:bool ->
bool -> Format.formatter -> game * game_state -> unit
val fprint_state : Format.formatter -> game * game_state -> unit
val print_state : game * game_state -> unit
val sprint_state : game * game_state -> string
Print the structure in extensive form.
val sprint_state_ext : game * game_state -> string
For the rules of the game, also print their compiled forms.
val sprint_state_full : game * game_state -> string
val sprint_game_move : move * float option -> string
val game_move_str : move -> string
type definition = 
| DefRule of string
* ((string * int) list ->
(string * (string list * Formula.formula)) list ->
string -> ContinuousRule.rule)
(*add a rule*)
| DefLoc of ((string * int) list -> int * (player_loc array * string list)) (*add location to graph*)
| DefPlayers of string list (*add players (fresh numbers)*)
| DefRel of string * string list * Formula.formula (*add a defined relation*)
| DefPattern of Formula.real_expr (*Pattern definition*)
| StartStruc of Structure.structure (*initial structure*)
| CurrentStruc of Structure.structure (*current structure*)
| History of (move * float option) list (*Move history*)
| StateTime of float (*initial/saved time*)
| StateLoc of int (*initial/saved location*)
| StateData of (string * string) list (*saved data*)
The order of following entries matters: DefPlayers adds more players, with consecutive numbers starting from first available; later StartStruc, CurrentStruc, StateTime and StateLoc entries override earlier ones; later DefLoc with already existing location ID replaces the earlier one. The default state is the empty state, default location is 0, default time is 0.0, default data is empty.
exception Arena_definition_error of string
val array_of_players : 'a -> (string * int) list -> (string * 'a) list -> 'a array
val make_move_arena : string -> (string * (float * float)) list -> int -> label * int
val make_location : int ->
(string *
[< `Heurs of float list
| `Moves of (label * int) list
| `Payoff of Formula.real_expr ]
list)
list ->
string list ->
(string * int) list -> int * (player_loc array * string list)
val process_definition : ?extend_state:game * game_state ->
definition list -> game * game_state
Create a game state, possibly by extending an old state, from a list of definitions (usually corresponding to a ".toss" file.)
val map_to_formulas : (Formula.formula -> Formula.formula) -> game -> game
val fold_over_formulas : include_defined_rels:bool ->
(Formula.formula -> 'a -> 'a) -> game -> 'a -> 'a
val map_to_structures : (Structure.structure -> Structure.structure) -> game -> game
val map_to_discrete : (DiscreteRule.rule -> DiscreteRule.rule) -> game -> game
Map to the structure representation of discrete part of rules.
val all_fluents : game -> Aux.Strings.t * Aux.Strings.t * Aux.Strings.t
val compare_diff : ?cmp_funs:(float -> float -> bool) ->
game * game_state ->
game * game_state -> bool * string
Compare two (game, state) pairs and explain the first difference met. Formulas and expressions are compared for syntactical equality. Players need to be given in the same order. Data is ignored.

Move definition, generation and helper functions.


val cGRID_SIZE : int
Default number of sample points per parameter in tree search. TODO: fixed for now.
val list_moves : game -> game_state -> (int * move * game_state) array
Get moves and resulting game states for all rules the players can apply in the given game state. Returns the player together with a move.
val list_moves_shifts : game ->
game_state ->
(int * (move * ((string * string) * float list) list) *
game_state)
array
As list_moves but with animation shifts for each move.
val apply_rule_int : game * game_state ->
string * (string * int) list * float * (string * float) list ->
(game * game_state) * string
val apply_rewrite : game * game_state ->
int * (string * DiscreteRule.matching) -> game * game_state
val win_so_formula : ?inv:bool ->
?start0:bool ->
?subst:(string * string) list -> game -> int -> Formula.formula