aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cards.ml12
1 files changed, 7 insertions, 5 deletions
diff --git a/cards.ml b/cards.ml
index a1d07ed..352d825 100644
--- a/cards.ml
+++ b/cards.ml
@@ -3,7 +3,6 @@ type lambda =
|Lambda of (lambda -> lambda);;
let unfold (Lambda x) = x
let (@) a1 a2 = unfold a1 a2;;
-let out (Lambda x) = x
let (!) x = Lambda x
let id = !(fun x -> x)
@@ -40,9 +39,9 @@ let attack = !(fun (Const i) -> !(fun (Const j) -> !(fun (Const n) ->
proponent.(i).vitality <- proponent.(i).vitality - n
else
failwith "not enough life";
- let w = opponent.(j).vitality in
+ let w = opponent.(255-j).vitality in
if w > 0 then
- proponent.(j).vitality <- max 0 (w - 9/10 *n);
+ proponent.(255-j).vitality <- max 0 (w - 9/10 *n);
id)))
let help = !(fun (Const i) -> !(fun (Const j) -> !(fun (Const n) ->
@@ -51,9 +50,9 @@ let help = !(fun (Const i) -> !(fun (Const j) -> !(fun (Const n) ->
proponent.(i).vitality <- proponent.(i).vitality - n
else
failwith "not enough life";
- let w = proponent.(255-j).vitality in
+ let w = proponent.(j).vitality in
if w > 0 then
- proponent.(255 - j).vitality <- min (w + n*11/10) 65535;
+ proponent.(j).vitality <- min (w + n*11/10) 65535;
id)))
let copy = !(fun (Const i) -> opponent.(i).field)
@@ -134,6 +133,9 @@ let left_apply card slot =
let right_apply slot card =
slot.field <- slot.field @ (cardfun_of_card card)
+let proponent = Array.init 256 (fun _ -> {vitality = 10000; field = id})
+
+let opponent = proponent =
right_apply proponent.(0) Help;;
right_apply proponent.(0) Zero;;
left_apply K proponent.(0);;