diff options
| -rw-r--r-- | game.ml | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -26,18 +26,31 @@ let get = Lambda(fun (Const i) -> if !proponent.(i).vitality > 0 then !proponent let put = Lambda(fun x -> id) let s = Lambda(fun f -> Lambda(fun g -> Lambda(fun x -> (f @ x) @ (g @ x)))) let k = Lambda(fun x -> Lambda(fun y -> x)) + let inc = Lambda(fun (Const i) -> let v = !proponent.(i) .vitality in if ( v < 65535 ) & ( v > 0 ) then !proponent.(i).vitality <- v + 1; id) +let inc_bis = Lambda(fun (Const i) -> + let v = !proponent.(i) .vitality in + if ( v < 65535 ) & ( v > 0 ) then + !proponent.(i).vitality <- v - 1; + id) + let dec = Lambda(fun (Const i) -> let v = !opponent.(255-i).vitality in if v > 0 then !opponent.(255-1).vitality <- v - 1; id) +let dec_bis = Lambda(fun (Const i) -> + let v = !opponent.(255-i).vitality in + if v > 0 then + !opponent.(255-1).vitality <- v + 1; + id) + let attack = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n) -> let v = !proponent.(i).vitality in if v - n > 0 then @@ -49,6 +62,17 @@ let attack = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n !opponent.(255-j).vitality <- max 0 (w - 9/10 *n); id))) +let attack_bis = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n) -> + let v = !proponent.(i).vitality in + if v - n > 0 then + !proponent.(i).vitality <- v - n + else + failwith "not enough life"; + let w = !opponent.(255-j).vitality in + if w > 0 then + !opponent.(255-j).vitality <- min 65535 (w + 9/10 *n); + id))) + let help = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n) -> let v = !proponent.(i).vitality in if v - n > 0 then @@ -57,6 +81,17 @@ let help = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n) failwith "not enough life"; let w = !proponent.(j).vitality in if w > 0 then + !proponent.(j).vitality <- max (w - n*11/10) 0; + id))) + +let help_bis = Lambda(fun (Const i) -> Lambda(fun (Const j) -> Lambda(fun (Const n) -> + let v = !proponent.(i).vitality in + if v - n > 0 then + !proponent.(i).vitality <- v - n + else + failwith "not enough life"; + let w = !proponent.(j).vitality in + if w > 0 then !proponent.(j).vitality <- min (w + n*11/10) 65535; id))) @@ -132,6 +167,24 @@ let cardfun_of_card c = match c with | Revive -> revive | Zombie -> zombie +let cardfun_of_card_bis c = match c with + | I -> id + | Zero -> zero + | Succ -> succ + | Dbl -> dbl + | Get -> get + | Put -> put + | S -> s + | K -> k + | Inc -> inc_bis + | Dec -> dec_bis + | Attack -> attack_bis + | Help -> help_bis + | Copy -> copy + | Revive -> revive + | Zombie -> zombie + + let left_apply player card number = if player = 0 then begin proponent := player0; |
