diff --git a/again b/again index 4b336f1..26ace8e 100755 Binary files a/again and b/again differ diff --git a/again.cmi b/again.cmi index 0f343a2..cdd103c 100644 Binary files a/again.cmi and b/again.cmi differ diff --git a/again.cmx b/again.cmx index 6389832..da5bdaf 100644 Binary files a/again.cmx and b/again.cmx differ diff --git a/again.ml b/again.ml index f163a04..ea10d85 100644 --- a/again.ml +++ b/again.ml @@ -442,6 +442,64 @@ let build_danger_map (gd : game_data) = done; res ;; +let is_worth (gd : game_data) (bsize : int) = + let lines = Array.length gd.laby + and cols = Array.length gd.laby.(0) in + let cxi = gd.players.(gd.player_id).xy.x + and cyi = gd.players.(gd.player_id).xy.y in + let halt = ref false in + let count = ref 0 in + try + if gd.laby.(cxi).(cyi) = 1 || gd.laby.(cxi).(cyi) = 2 then + raise (ReturnBool false); + for dir = 0 to 3 do + for w = 0 to bsize do + if not !halt && dir = 0 || w > 0 then begin + let nx = cxi + w * (fst order.(dir)) + and ny = cyi + w * (snd order.(dir)) in + if is_valid nx ny lines cols then begin + if gd.laby.(nx).(ny) = 0 || gd.laby.(nx).(ny) >= 3 && gd.laby.(nx).(ny) <> 3+gd.player_id then begin + incr count ; + if !count >= 2 then + raise (ReturnBool true) + end + else if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 then + halt := true + end + end + done ; + halt := false + done ; + false + with + | ReturnBool b -> b ;; + +let is_worth_pos (gd : game_data) (cxi : int) (cyi : int) (bsize : int) = + let lines = Array.length gd.laby + and cols = Array.length gd.laby.(0) in + let halt = ref false in + try + if gd.laby.(cxi).(cyi) = 1 || gd.laby.(cxi).(cyi) = 2 then + raise (ReturnBool false); + for dir = 0 to 3 do + for w = 0 to bsize do + if not !halt && dir = 0 || w > 0 then begin + let nx = cxi + w * (fst order.(dir)) + and ny = cyi + w * (snd order.(dir)) in + if is_valid nx ny lines cols then begin + if gd.laby.(nx).(ny) = 0 || gd.laby.(nx).(ny) >= 3 && gd.laby.(nx).(ny) <> 3+gd.player_id then + raise (ReturnBool true) + else if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 then + halt := true + end + end + done ; + halt := false + done ; + false + with + | ReturnBool b -> b ;; + let generate_gain_map (gd : game_data) (dgs : danger_map) = let lines = Array.length gd.laby and cols = Array.length gd.laby.(0) in @@ -451,7 +509,7 @@ let generate_gain_map (gd : game_data) (dgs : danger_map) = (* aim towards center by adding a bonus *) for i = 0 to lines -1 do for j = 0 to cols -1 do - if (gd.laby.(i).(j) >= 3) || gd.laby.(i).(j) = 0 then + if false && is_worth_pos gd i j gd.players.(gd.player_id).bomb_radius then res.(i).(j) <- res.(i).(j) + (min (min (i) (lines -1-i)) (min (j) (cols -1-j))) ; done done ; @@ -466,7 +524,7 @@ let generate_gain_map (gd : game_data) (dgs : danger_map) = if dir = 0 || w > 0 then begin let nx = l + w * (fst order.(dir)) and ny = c + w * (snd order.(dir)) in - if is_valid nx ny lines cols then begin + if not !halt && is_valid nx ny lines cols then begin if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 || Array.exists (fun (b : bomb) -> b.xy.x = nx && b.xy.y = ny) gd.bombs then halt := true else if gd.laby.(nx).(ny) <> 3+gd.player_id then begin @@ -1085,6 +1143,14 @@ let closest_boom (dgs : danger_map) (x : int) (y : int) = if logg then Printf.fprintf stderr "%d %d\n" x y ; List.fold_left min 999999. dgs.explosionTimes.(x).(y) ;; +let add_player_count (gd : game_data) = + let res = ref 0 in + for pl = 0 to 3 do + if gd.players.(pl).id <> -1 && gd.players.(pl).id <> gd.player_id then + res := 1 + done ; + !res ;; + let seek_player (gd : game_data) (dgs : danger_map) = (* returns whether or not it found a target, and prints if found *) (* note : if this triggers then someone WILL die *) @@ -1106,6 +1172,10 @@ let seek_player (gd : game_data) (dgs : danger_map) = if logg then Printf.fprintf stderr "No trap/available bomb\n" ; raise (ReturnBool false) end ; + if gd.players.(pid).ndash <= add_player_count gd then begin + if logg then Printf.fprintf stderr "Saving bombs\n" ; + raise (ReturnBool false) + end ; if logg then Printf.fprintf stderr "Can trap\n" ; while not !has_trapped do for pl = 0 to Array.length gd.players -1 do @@ -1317,12 +1387,12 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) = end; (* try to place a bomb *) - let is_safe = is_empty_lst dgs.explosionTimes.(cxi).(cyi) in + (*let is_safe = is_empty_lst dgs.explosionTimes.(cxi).(cyi) in*) let saved_p = simulate_bomb_deconstruct gd dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in let is_good = ref false in let result_bomb = bfs_for_land ~return_ok:is_good true gd dgs cxi cyi xmax ymax (gd.dt -. !remaining_dash *. interval) 1 80 in - if is_safe && gd.players.(pid).bomb_to_place > 0 && !is_good && !action <> 2 then begin + if (*is_safe && *)gd.players.(pid).bomb_to_place > 0 && !is_good && !action <> 2 && is_worth gd gd.players.(pid).bomb_radius then begin if logg then Printf.fprintf stderr "kaboom\n" ; action := 1 ; result_bomb @@ -1393,7 +1463,7 @@ let get_cd (filename : string) = close_in ptr ;; let set_cd (nspeed : int) (filename : string) = - if !remaining_dash = 0. then begin + if !remaining_dash = 0. && !action <> 2 then begin let ptr = open_out filename in let interval = Float.pow 0.9 (float_of_int nspeed) in Printf.fprintf ptr "%f\n" (max 0. (!cd -. interval)) ; @@ -1413,7 +1483,7 @@ get_rem_dash "again_rem.sav" ;; get_cd "again_cooldown.sav" ;; (*Printf.fprintf stderr "\n" ;;*) -if game_map.player_id = 4 then begin +if game_map.player_id = 727 then begin for l = 0 to Array.length gain_map -1 do for c = 0 to Array.length gain_map.(l) -1 do print_integer_aligned gain_map.(l).(c) 3 @@ -1450,14 +1520,13 @@ else begin if logg then Printf.fprintf stderr "[player %d] %d %d (at time %f - with %d dash potential)\n" game_map.player_id !direction !action game_map.dt (int_of_float !remaining_dash); end else begin - cd := (Float.pow 0.9 (float_of_int game_map.players.(game_map.player_id).nspeed)) *. 2.5 ; + cd := 3.0; ignore (read_queue "again_dash.sav") end end;; -(*Printf.printf "\n4 0" ;;*) + set_rem_dash "again_rem.sav" ;; set_cd game_map.players.(game_map.player_id).nspeed "again_cooldown.sav" ;; (*set_meta_info game_map.player_id ;;*) let __end = Unix.gettimeofday() ;; -if logg then Printf.fprintf stderr "Time : %f\n\n" (__end -. __start) ;; - +if logg then Printf.fprintf stderr "Time : %f\n\n" (__end -. __start) ;; \ No newline at end of file diff --git a/again.o b/again.o index ea31d32..28b5549 100644 Binary files a/again.o and b/again.o differ diff --git a/entrees.txt b/entrees.txt index 147559a..8ec3a62 100644 --- a/entrees.txt +++ b/entrees.txt @@ -1,27 +1,24 @@ -140.0 +284.6347000000014 2 13 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 6 3 3 3 3 3 3 0 2 2 2 0 5 5 5 5 5 5 5 1 -1 6 1 3 1 0 1 2 1 2 1 2 1 2 1 5 1 5 1 5 1 -1 6 6 3 6 6 6 0 2 2 2 2 0 5 5 5 5 5 5 5 1 -1 6 1 3 1 6 1 0 1 2 1 2 1 2 1 5 1 5 1 5 1 -1 3 6 6 6 6 6 6 0 2 2 2 2 0 0 5 5 5 5 5 1 -1 6 1 3 1 6 1 0 1 2 1 2 1 5 1 5 1 5 1 4 1 -1 6 6 6 6 6 6 6 6 6 0 0 0 5 5 5 4 4 4 4 1 -1 6 1 3 1 6 1 0 1 2 1 5 1 5 1 4 1 4 1 4 1 -1 6 6 6 6 6 6 6 6 5 5 5 5 5 5 4 4 4 4 4 1 -1 6 1 6 1 6 1 0 1 2 1 5 1 5 1 4 1 4 1 4 1 -1 6 6 6 6 6 6 6 0 2 0 5 5 5 5 4 4 4 4 4 1 +1 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 +1 3 1 6 1 6 1 5 1 5 1 6 1 5 1 6 1 5 1 5 1 +1 6 5 5 5 5 5 5 5 5 5 5 5 5 5 6 5 5 5 5 1 +1 6 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 4 1 5 1 +1 6 6 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 5 1 +1 3 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1 +1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 5 5 5 1 +1 3 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1 +1 6 5 5 5 5 5 5 5 5 5 5 5 6 5 5 5 5 5 6 1 +1 6 1 3 1 3 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1 +1 6 5 5 5 5 6 5 6 5 6 6 6 5 5 5 5 6 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +4 +9 13 5 286.1981000000015 +10 13 5 286.85420000000147 +11 13 5 287.51030000000145 +11 14 5 288.16640000000143 1 -11 5 5 140.17600000000024 -2 -10 11 2 0 4 2 2 2 -7 3 3 3 1 5 1 1 -5 -1 8 4 -1 12 2 -3 7 3 -3 12 2 -2 5 3 +9 15 2 4 0 5 2 0 +0 diff --git a/signal.txt b/signal.txt index c227083..d00491f 100644 --- a/signal.txt +++ b/signal.txt @@ -1 +1 @@ -0 \ No newline at end of file +1