aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2011-06-19 12:35:15 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2011-06-19 12:35:15 -0400
commit338891c519fba83ccd6c61492082abfa2bb1cf22 (patch)
tree4d5e313ba743686fc824cc8b4c5a409ed3bd8f77
parent41d786684347ee091f8c6e5977bd1108e88714d4 (diff)
downloadicfp2011-338891c519fba83ccd6c61492082abfa2bb1cf22.tar.gz
Fixed the counting mechanism, should work now
-rw-r--r--game.ml81
1 files changed, 43 insertions, 38 deletions
diff --git a/game.ml b/game.ml
index aa8c478..0258e28 100644
--- a/game.ml
+++ b/game.ml
@@ -25,39 +25,44 @@ let proponent = ref player0
let opponent = ref player1
let increase card_count =
- if !card_count>=1000 then
+ if !card_count >= 1000 then
raise( Rule_error "apply limit exceeded")
else
card_count:=!card_count+1
-let zero = increase card_count;Const 0
-let succ = increase card_count;
- Lambda(fun a -> match a with
+let zero = Const 0
+
+let succ = Lambda(fun a -> increase card_count;
+ match a with
| Const n -> if n < 65535 then Const (n+1) else Const n
| _ -> raise( Rule_error "not an integer"))
-let dbl = increase card_count;
- Lambda(fun a -> match a with
- | Const n -> if n < 32768 then Const(2*n) else Const n
- | _ -> raise( Rule_error "not an integer"))
-let get = increase card_count;
- Lambda(fun a -> match a with
+
+let dbl = Lambda(fun a -> increase card_count;
+ match a with
+ | Const n -> if n < 32768 then Const(2*n) else Const n
+ | _ -> raise( Rule_error "not an integer"))
+
+let get = Lambda(fun a -> increase card_count;
+ match a with
| (Const i) -> if !proponent.(i).vitality > 0 then !proponent.(i).field else raise( Rule_error "not a valid slot number")
| _ -> raise( Rule_error "not an integer" ))
-let put = increase card_count;Lambda(fun x -> id)
-let s = increase card_count;Lambda(fun f -> Lambda(fun g -> Lambda(fun x -> (f @ x) @ (g @ x))))
-let k = increase card_count;Lambda(fun x -> Lambda(fun y -> x))
+let put = Lambda(fun x -> increase card_count;id)
+
+let s = Lambda(fun f -> increase card_count;Lambda(fun g -> Lambda(fun x -> (f @ x) @ (g @ x))))
-let inc = increase card_count;
- Lambda(fun a -> match a with
+let k = Lambda(fun x -> increase card_count;Lambda(fun y -> x))
+
+let inc = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> let v = !proponent.(i) .vitality in
if ( v < 65535 ) & ( v > 0 ) then
!proponent.(i).vitality <- v + 1;
id
| _ -> raise( Rule_error "not an integer"))
-let inc_bis = increase card_count;
- Lambda(fun a -> match a with
+let inc_bis = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> let v = !proponent.(i) .vitality in
if ( v < 65535 ) & ( v > 0 ) then
!proponent.(i).vitality <- v - 1;
@@ -65,24 +70,24 @@ let inc_bis = increase card_count;
| _ -> raise( Rule_error "not an integer"))
-let dec = increase card_count;
- Lambda(fun a -> match a with
+let dec = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> let v = !opponent.(255-i).vitality in
if v > 0 then
!opponent.(255-1).vitality <- v - 1;
id
| _ -> raise( Rule_error "not an integer"))
-let dec_bis = increase card_count;
- Lambda(fun a -> match a with
+let dec_bis = Lambda(fun a -> increase card_count;
+ match a with
| (Const i) -> let v = !opponent.(255-i).vitality in
if v > 0 then
!opponent.(255-1).vitality <- v + 1;
id
| _ -> raise( Rule_error "not an integer"))
-
-let attack = increase card_count;
- Lambda(fun a -> Lambda(fun b -> Lambda(fun c -> match a, b, c with
+
+let attack = Lambda(fun a -> increase card_count;
+ Lambda(fun b -> Lambda(fun c -> match a, b, c with
| Const i, Const j, Const n ->
let v = !proponent.(i).vitality in
if v - n > 0 then
@@ -95,8 +100,8 @@ let attack = increase card_count;
id
| _ -> raise( Rule_error "not an integer"))))
-let attack_bis = increase card_count;
- Lambda(fun a -> Lambda(fun b -> Lambda(fun c -> match a, b, c with
+let attack_bis = Lambda(fun a -> increase card_count;
+ Lambda(fun b -> Lambda(fun c -> match a, b, c with
| Const i, Const j, Const n ->
let v = !proponent.(i).vitality in
if v - n > 0 then
@@ -109,8 +114,8 @@ let attack_bis = increase card_count;
id
| _ -> raise( Rule_error "not an integer"))))
-let help = increase card_count;
- Lambda(fun a -> Lambda(fun b -> Lambda(fun c -> match a, b, c with
+let help = Lambda(fun a -> increase card_count;
+ Lambda(fun b -> Lambda(fun c -> match a, b, c with
| Const i, Const j, Const n ->
let v = !proponent.(i).vitality in
if v - n > 0 then
@@ -123,8 +128,8 @@ let help = increase card_count;
id
| _ -> raise( Rule_error "not an integer"))))
-let help_bis = increase card_count;
- Lambda(fun a -> Lambda(fun b -> Lambda(fun c -> match a, b, c with
+let help_bis = Lambda(fun a -> increase card_count;
+ Lambda(fun b -> Lambda(fun c -> match a, b, c with
| Const i, Const j, Const n ->
let v = !proponent.(i).vitality in
if v - n > 0 then
@@ -137,21 +142,21 @@ let help_bis = increase card_count;
id
| _ -> raise( Rule_error "not an integer"))))
-let copy = increase card_count;
- Lambda(fun a -> match a with
+let copy = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> !opponent.(i).field
| _ -> raise( Rule_error "not an integer"))
-
-let revive = increase card_count;
- Lambda(fun a -> match a with
+
+let revive = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> let v = !proponent.(i).vitality in
if v <= 0 then
!proponent.(i).vitality <- 1;
id
| _ -> raise( Rule_error "not an integer"))
-
-let zombie = increase card_count;
- Lambda(fun a -> match a with
+
+let zombie = Lambda(fun a -> increase card_count;
+ match a with
| Const i -> Lambda(fun x ->
let v = !opponent.(255-i).vitality in
if v <= 0 then