added player bombing to move_lane

This commit is contained in:
Alexandre 2025-01-01 19:01:38 +01:00
parent 003a25f4cd
commit 0bedcd7378
6 changed files with 68 additions and 56 deletions

BIN
again

Binary file not shown.

BIN
again.cmi

Binary file not shown.

BIN
again.cmx

Binary file not shown.

View File

@ -1162,15 +1162,30 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) =
let pid = gd.player_id in let pid = gd.player_id in
let cxi = gd.players.(pid).xy.x let cxi = gd.players.(pid).xy.x
and cyi = gd.players.(pid).xy.y in and cyi = gd.players.(pid).xy.y in
let interval = Float.pow (0.9) (float_of_int gd.players.(gd.player_id).nspeed) in
if logg then Printf.fprintf stderr "going at (%d, %d) [score=%d]\n" xmax ymax gn.(xmax).(ymax); if logg then Printf.fprintf stderr "going at (%d, %d) [score=%d]\n" xmax ymax gn.(xmax).(ymax);
try
if gd.players.(pid).bomb_to_place > 0 && Array.exists (fun (p : player) -> p.id <> pid && p.xy.x = cxi && p.xy.y = cyi) gd.players && (is_empty_lst dgs.explosionTimes.(cxi).(cyi)) then begin
if logg then Printf.fprintf stderr "go away (_2)\n" ;
let saved_ppl = simulate_bomb_deconstruct gd dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in
let is_good_p = ref false in
let directn = bfs_for_land ~return_ok:is_good_p true gd dgs cxi cyi xmax ymax (gd.dt -. !remaining_dash *. interval) 1 80 in
if !is_good_p then begin
if logg then Printf.fprintf stderr "fire in the hole (%d)\n" directn ;
action := 1 ;
raise (ReturnInt directn)
end;
reverse_simulate_bomb dgs saved_ppl ;
end;
(* try to place a bomb *) (* 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 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 is_good = ref false in
let result_bomb = bfs_for_land ~return_ok:is_good true gd dgs cxi cyi xmax ymax gd.dt 1 80 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 then begin
if logg then Printf.fprintf stderr "kaboom\n" ; if logg then Printf.fprintf stderr "kaboom\n" ;
action := 1 ; action := 1 ;
@ -1179,14 +1194,14 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) =
else begin else begin
reverse_simulate_bomb dgs saved_p ; reverse_simulate_bomb dgs saved_p ;
let res = bfs_for_land ~return_ok:is_good false gd dgs cxi cyi xmax ymax gd.dt 1 80 in let res = bfs_for_land ~return_ok:is_good false gd dgs cxi cyi xmax ymax (gd.dt -. !remaining_dash *. interval) 1 80 in
if !is_good then begin if !is_good then begin
if logg then Printf.fprintf stderr "going to kaboom\n" ; if logg then Printf.fprintf stderr "going to kaboom\n" ;
res res
end end
else begin else begin
if logg then Printf.fprintf stderr "no explosion ?\n" ; if logg then Printf.fprintf stderr "no explosion ?\n" ;
let res = bfs_for_land ~leniency:20 ~return_ok:is_good false gd dgs cxi cyi xmax ymax gd.dt 1 80 in let res = bfs_for_land ~leniency:20 ~return_ok:is_good false gd dgs cxi cyi xmax ymax (gd.dt -. !remaining_dash *. interval) 1 80 in
if !is_good then begin if !is_good then begin
if logg then Printf.fprintf stderr "found\n"; if logg then Printf.fprintf stderr "found\n";
res res
@ -1205,7 +1220,9 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) =
end end
end end
end end
end ;; end
with
| ReturnInt k -> k ;;
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)

BIN
again.o

Binary file not shown.

View File

@ -1,31 +1,26 @@
169.0 250.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