From 4d19ec5628a6b3e5ebc8234551fb73a13c52cbe1 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Sat, 18 Jun 2011 17:47:04 -0400 Subject: Fixed a bug, but still not working... --- cards.ml | 12 +++++++----- 1 file 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);; -- cgit v1.2.3-70-g09d2