-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer-gwillen1.sml
executable file
·86 lines (67 loc) · 2.01 KB
/
player-gwillen1.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
(* current story: broken; attacks opponent's slot 0 once and zombies it. Working on making the zombie do something. *)
val print = EPrint.eprint
structure Gwillen1 :> LAYER =
struct
structure GS = GameState
open Kompiler
open Macros
open LTG
infix 9 --
val op -- = Apply
val $ = Var
fun \ x exp = Lambda (x, exp)
infixr 1 `
fun a ` b = a b
fun init _ = ()
(* Zombie performs \_.Help (2*(Copy tgt)) (2(Copy tgt)+1) (Copy dmg) *)
fun zombie tgt dmg slot = let
val exp = \"_" ` Card Help -- (Card Dbl -- (Card Copy -- Int tgt)) -- (Card Succ -- (Card Dbl -- (Card Copy -- Int tgt))) -- (Card Copy -- Int dmg)
in
(* this should be named like, compile_assume_identity *)
Kompiler.compile_no_clear_rev exp slot
end
fun zombie_loader zombie s = Kompiler.compile_no_clear_rev (rrs_ref (
Card Zombie -- Card Z -- (Card Get -- Int zombie)
(*
fastload s Zombie @
apply s Z @
apply_slot_to_slot s zombie) s
*)
) s) s
val is = Int.toString
val strategy = let
val tgt = 0
val dmg = 1
val zmb = 2
val loader = 3
fun print_and_cat' [] = []
| print_and_cat' ((lbl, asm)::rest) = let
val _ = print (lbl ^ ": " ^ (is (length asm)) ^ "\n")
in
asm @ (print_and_cat' rest)
end
fun print_and_cat x = let
val result = print_and_cat' x
val _ = print ("TOTAL: " ^ (is (length result)) ^ "\n\n")
in
result
end
val result = ref (
print_and_cat [
("10k", fastnum dmg 10000),
("dblshot", fast_doubleshot 10 dmg 4 5 0),
("loadctr", fastnum tgt 0),
("zombie", zombie tgt dmg zmb),
("loader", zombie_loader zmb loader),
("bangbang", (rep 128 (apply loader Z @ succ tgt)))])
in
result
end
fun taketurn _ = case (!strategy) of nil => L Z 0
| today::future => let
val _ = strategy := future
in
today
end
end
structure Player = LayerFn(Gwillen1)