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1 2 1 4 1 4 1 4 1 +1 6 6 6 6 6 6 0 2 2 2 2 2 2 0 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +5 +7 17 3 108.35799999999998 +11 15 2 109.5 +11 6 2 109.50000000000011 +3 6 3 109.64919999999982 +10 7 2 112.20000000000013 4 -5 9 5 206.50000000000063 -5 18 2 207.00000000000085 -7 10 5 209.20000000000064 -11 15 4 209.69300000000123 -3 -11 17 1 3 2 4 1 3 -3 19 2 1 2 2 1 3 -8 9 3 1 4 5 4 3 -0 +1 7 0 4 3 3 0 0 +8 15 1 0 2 2 3 1 +9 17 2 3 3 3 0 2 +10 7 3 1 2 2 3 0 +1 +5 13 1 diff --git a/main b/main index ae859d2..d1bb265 100755 Binary files a/main and b/main differ diff --git a/main.cmi b/main.cmi index 3bc2c54..da3dca3 100644 Binary files a/main.cmi and b/main.cmi differ diff --git a/main.cmo b/main.cmo index d713901..d363de2 100644 Binary files a/main.cmo and b/main.cmo differ diff --git a/main.ml b/main.ml index b9c1383..8282a81 100755 --- a/main.ml +++ b/main.ml @@ -1,4 +1,10 @@ (*#! /home/alexandre/.opam/myswitch/bin/ocaml *) +(* +TODO : +- deal with double bombing (DONE) +- well shit ==> dash (DONE (needs dash to be fixed tho)) +- deeper analysis on pathfinfing +*) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -103,6 +109,8 @@ exception ReturnBool of bool ;; let current_status = ref BlowUpCrates ;; let action = ref 0 ;; +let dash_left = ref 0 ;; + let equal_pt (p1 : pt) (p2 : pt) = p1.x = p2.x && p1.y = p2.y ;; @@ -194,21 +202,32 @@ let rec ln_b b = function let get_meta_info (pid : int) = let ptr = open_in ("main_"^(string_of_int pid)^".sav") in - match (int_of_string (input_line ptr)) with + let fct0 () = match (int_of_string (input_line ptr)) with | 0 -> current_status := EscapeDeath | 1 -> current_status := BlowUpCrates | 2 -> current_status := ClaimLand | 3 -> current_status := KillPlayers - | _ -> current_status := EscapeDeath ; - close_in ptr ;; + | _ -> current_status := EscapeDeath + in + fct0 () ; + try + let resu = int_of_string (input_line ptr) in + dash_left := resu -1; + close_in ptr + with + | End_of_file -> close_in ptr ;; let set_meta_info (pid : int) = let ptr = open_out ("main_"^(string_of_int pid)^".sav") in - match !current_status with + let fct0 () = match !current_status with | EscapeDeath -> Printf.fprintf ptr "0" | BlowUpCrates -> Printf.fprintf ptr "1" | ClaimLand -> Printf.fprintf ptr "2" - | KillPlayers -> Printf.fprintf ptr "3" ; + | KillPlayers -> Printf.fprintf ptr "3" + in + fct0 () ; + if !dash_left > 0 then + Printf.fprintf ptr "\n%d" !dash_left ; close_out ptr ;; (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -329,21 +348,6 @@ let evaluate_dangers (gd : game_data) = done done ; - (* add players *) - for p = 0 to gd.nplayers -1 do - if p <> gd.player_id then begin - let player_dgr = (Danger (gd.dt +. 5.5)) in - for d = 0 to 3 do - for o = 0 to gd.players.(p).bomb_radius do - let nx = gd.players.(p).xy.x + o*(fst order.(d)) - and ny = gd.players.(p).xy.y + o*(snd order.(d)) in - if is_valid nx ny lines cols then - res.(nx).(ny) <- danger_priority res.(nx).(ny) player_dgr ; - done - done - end - done; - (* add bonuses *) for b = 0 to gd.nboosts -1 do res.(gd.boosts.(b).xy.x).(gd.boosts.(b).xy.y) <- danger_priority (res.(gd.boosts.(b).xy.x).(gd.boosts.(b).xy.y)) Bonus @@ -365,12 +369,12 @@ let evaluate_dangers (gd : game_data) = (* add bomb tiles *) let exploded = Hashtbl.create 12 in for b = 0 to gd.nbombs -1 do - let dgr = warn_level gd.bombs.(b) gd.dt in - let halt = ref false in - let bx = gd.bombs.(b).xy.x and by = gd.bombs.(b).xy.y in + let dgr = danger_priority (warn_level gd.bombs.(b) gd.dt) (res.(bx).(by)) in (* be careful of chained bombs *) + let halt = ref false in + for dir = 0 to 3 do for w = 0 to gd.bombs.(b).size do let cx = bx + w*(fst order.(dir)) @@ -392,6 +396,21 @@ let evaluate_dangers (gd : game_data) = done done; + (* add players *) + for p = 0 to gd.nplayers -1 do + if p <> gd.player_id then begin + let player_dgr = danger_priority (Danger (gd.dt +. 5.5)) (res.(gd.players.(p).xy.x).(gd.players.(p).xy.y)) in + for d = 0 to 3 do + for o = 0 to gd.players.(p).bomb_radius do + let nx = gd.players.(p).xy.x + o*(fst order.(d)) + and ny = gd.players.(p).xy.y + o*(snd order.(d)) in + if is_valid nx ny lines cols then + res.(nx).(ny) <- danger_priority res.(nx).(ny) player_dgr ; + done + done + end + done; + res ;; (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -588,7 +607,7 @@ let move_explore (gd: game_data) (dgs : danger array array) = let (cxi, cyi) = (gd.players.(pid).xy.x, gd.players.(pid).xy.y) in let move_with_caution (exit : bool) = - let res = has_a_safe_path_origin_2 cxi cyi lines cols gd.dt interval gd dgs [|Bonus|] [||] [|Blocked|] [||] 5 in + let res = has_a_safe_path_origin_2 cxi cyi lines cols gd.dt interval gd dgs [|Bonus|] [||] [|Blocked|] [||] 7 in if res <> 4 then begin if debug_all then Printf.fprintf stderr "[crates] success 1/2!\n" ; res @@ -612,9 +631,10 @@ let move_explore (gd: game_data) (dgs : danger array array) = (* simulate the placement of a bomb, and test if that stills allows safe escape *) let bomb_hash = Hashtbl.create (4 * (bsize +1)) in let saved_dgs = Hashtbl.create (4 * (bsize +1)) in + let bomb_dgr = (danger_priority (Danger (gd.dt +. 5.5)) dgs.(bx).(by)) in for dir = 0 to 3 do for w = 0 to bsize do - Hashtbl.add bomb_hash (bx + w*(fst order.(dir)), by + w*(snd order.(dir))) (Danger (gd.dt +. 5.5)) ; + Hashtbl.add bomb_hash (bx + w*(fst order.(dir)), by + w*(snd order.(dir))) bomb_dgr ; done done; Hashtbl.iter @@ -713,9 +733,10 @@ let move_claim (gd : game_data) (dgs : danger array array) (gns : int array arra let bomb_hash = Hashtbl.create (4 * (bsize +1)) in let saved_dgs = Hashtbl.create (4 * (bsize +1)) in + let bomb_dgr = danger_priority (Danger (gd.dt +. 5.5)) (dgs.(gd.players.(pid).xy.x).(gd.players.(pid).xy.y)) in for dir = 0 to 3 do for w = 0 to bsize do - Hashtbl.add bomb_hash (cxi + w*(fst order.(dir)), cyi + w*(snd order.(dir))) (Danger (gd.dt +. 5.5)) ; + Hashtbl.add bomb_hash (cxi + w*(fst order.(dir)), cyi + w*(snd order.(dir))) bomb_dgr ; done done; Hashtbl.iter @@ -769,7 +790,7 @@ let move_safe (gd : game_data) (dgs : danger array array) (gns : int array array try (* 0. if you're standing on a safe tile, switch mode *) let (cx, cy) = (gd.players.(pid).xy.x, gd.players.(pid).xy.y) in - if dgs.(cx).(cy) = Safe then begin + if (!dash_left = 0) && dgs.(cx).(cy) = Safe then begin if contains_crate gd then begin current_status := BlowUpCrates ; raise (ReturnInt (move_explore gd dgs)) ; @@ -782,13 +803,25 @@ let move_safe (gd : game_data) (dgs : danger array array) (gns : int array array (*let result = has_a_safe_path (cx) (cy) gd.dt in*) let result = has_a_safe_path_origin_2 cx cy lines cols gd.dt interval gd dgs [|Bonus|] [||] [|Blocked|] [||] 20 in - if result <> 4 then result else begin + if (!dash_left = 0) && result <> 4 then + result + else begin let result2 = has_a_safe_path_origin_2 cx cy lines cols gd.dt interval gd dgs [|Safe|] [||] [|Blocked|] [||] 80 in - if result2 <> 4 then result2 + if (!dash_left = 0) && result2 <> 4 then + result2 else begin - (* you're probably dead if the code reaches here... *) - Printf.fprintf stderr "well shit\n" ; - 4 + (* you're probably dead if the code reaches here, unless... *) + if (!dash_left > 0) || gd.players.(pid).ndash > 0 then begin + Printf.fprintf stderr "*teleports*\n" ; + if (!dash_left = 0) then + action := 2 ; + dash_left := 3 ; + has_a_safe_path_origin_2 cx cy lines cols (gd.dt -. interval *. float_of_int (!dash_left)) interval gd dgs [|Safe|] [||] [|Blocked|] [||] 80 + end + else begin + Printf.fprintf stderr "well shit\n" ; + 4 + end end end with diff --git a/main_0.sav b/main_0.sav index c227083..56a6051 100644 --- a/main_0.sav +++ b/main_0.sav @@ -1 +1 @@ -0 \ No newline at end of file +1 \ No newline at end of file diff --git a/main_1.sav b/main_1.sav index c227083..56a6051 100644 --- a/main_1.sav +++ b/main_1.sav @@ -1 +1 @@ -0 \ No newline at end of file +1 \ No newline at end of file diff --git a/main_2.sav b/main_2.sav index d8263ee..56a6051 100644 --- a/main_2.sav +++ b/main_2.sav @@ -1 +1 @@ -2 \ No newline at end of file +1 \ No newline at end of file diff --git a/main_3.sav b/main_3.sav index c227083..56a6051 100644 --- a/main_3.sav +++ b/main_3.sav @@ -1 +1 @@ -0 \ No newline at end of file +1 \ No newline at end of file diff --git a/sortie.txt b/sortie.txt index e69de29..6ad1e30 100644 --- a/sortie.txt +++ b/sortie.txt @@ -0,0 +1 @@ +2 2 \ No newline at end of file