aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2011-06-18 21:49:57 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2011-06-18 21:49:57 -0400
commit665bec9bf77f1917a116e71f578d08995b8373c4 (patch)
tree607dc822dc2bbf4f3ab59357b37bb5eb1c240720
parentf414fbe3f87d18496691c1071363040a59ff468f (diff)
downloadicfp2011-665bec9bf77f1917a116e71f578d08995b8373c4.tar.gz
Added function bis
-rw-r--r--game.ml53
1 files changed, 53 insertions, 0 deletions
diff --git a/game.ml b/game.ml
index c2e3da0..9ee9f2e 100644
--- a/game.ml
+++ b/game.ml
@@ -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;