-
Notifications
You must be signed in to change notification settings - Fork 0
/
ltg-sig.sml
executable file
·103 lines (78 loc) · 2.58 KB
/
ltg-sig.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
signature LTG =
sig
datatype card = datatype Card.card
(* Keeps various counters for the slots. *)
type stat
type stats
val initialstats : unit -> stats
(* Expensive! Don't call except when in debugging modes. *)
val statstostring : stats -> string
(* Get the stat in the slot, which must be in [0, 255] *)
val statfor : stats -> int -> stat
(* Accessors for the stat fields.
TODO(tom7): document *)
val stat_left_applications : stat -> int
val stat_right_applications : stat -> int
val stat_damage_done : stat -> real
val stat_healing_done : stat -> real
val stat_iterations : stat -> int
val stat_gotten : stat -> int
(* All possible primitive functions, including partial
applications. For partial applications, the argument
are stored in reverse order in the list. Probably
don't need to use these, but they can be inspected
as part of a strategy, for example. *)
datatype function =
VAttack of value list
| VCopy
| VDbl
| VDec
| VGet
| VHelp of value list
| VI
| VInc
| VK of value list
| VPut
| VRevive
| VS of value list
| VSucc
| VZombie of value list
and value =
VFn of function
| VInt of int
datatype exp =
App of exp * exp
| V of value
val valtos : value -> string
val ftos : function -> string
(* Parallel arrays (always size 256) for field and vitality.
Vitality is always in [-1, 65535]. *)
type side = value array * int array
val evalcard : card -> value
datatype semantics = NORMAL | ZOMBIE
(* If tracing is enabled, then print out steps of evaluation. *)
val enable_trace : bool -> unit
val initialside : unit -> side
val initialstate : unit -> side * side
val slotisdead : side -> int -> bool
(* Like turn, but without the slot. *)
datatype halfturn =
HLeftApply of card
| HRightApply of card
datatype turn =
LeftApply of card * int
| RightApply of int * card
(* Adds a slot to a halfturn. *)
val halfturn2turn : int -> halfturn -> turn
val turn2str : turn -> string
val turns2str : turn list -> string
(* Take a turn. Without loss of generality, pass in the proponent as
the player taking the turn.
Updates in place. Doesn't check for game-ending
conditions (all dead; ran out of turns); that should
be handled by the caller. *)
val taketurn : side * side -> turn -> unit
(* Same, but optionally accumulate stats. *)
val taketurnex : (side * stats option) * (side * stats option) -> turn -> unit
val application_count_hook : (int -> unit) option ref
end