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,50 +1162,67 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) =
let pid = gd.player_id in
let cxi = gd.players.(pid).xy.x
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);
(* try to place a bomb *)
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
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;
let result_bomb = bfs_for_land ~return_ok:is_good true gd dgs cxi cyi xmax ymax gd.dt 1 80 in
if is_safe && gd.players.(pid).bomb_to_place > 0 && !is_good && !action <> 2 then begin
if logg then Printf.fprintf stderr "kaboom\n" ;
action := 1 ;
result_bomb
end
else begin
reverse_simulate_bomb dgs saved_p ;
(* try to place a bomb *)
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 res = bfs_for_land ~return_ok:is_good false gd dgs cxi cyi xmax ymax gd.dt 1 80 in
if !is_good then begin
if logg then Printf.fprintf stderr "going to kaboom\n" ;
res
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 logg then Printf.fprintf stderr "kaboom\n" ;
action := 1 ;
result_bomb
end
else begin
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
reverse_simulate_bomb dgs saved_p ;
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 logg then Printf.fprintf stderr "found\n";
if logg then Printf.fprintf stderr "going to kaboom\n" ;
res
end
else begin
if logg then Printf.fprintf stderr "Needs dash lmao (_2)\n";
if !remaining_dash <> 0. && gd.players.(pid).ndash > 0 then begin
if logg then Printf.fprintf stderr "-------------- Lets rewind time for a bit (_2) --------------\n";
remaining_dash := 3. ;
action := 2 ;
move_land gd dgs gn
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 -. !remaining_dash *. interval) 1 80 in
if !is_good then begin
if logg then Printf.fprintf stderr "found\n";
res
end
else begin
if logg then Printf.fprintf stderr "Now you're screwed (_2)\n" ;
4
if logg then Printf.fprintf stderr "Needs dash lmao (_2)\n";
if !remaining_dash <> 0. && gd.players.(pid).ndash > 0 then begin
if logg then Printf.fprintf stderr "-------------- Lets rewind time for a bit (_2) --------------\n";
remaining_dash := 3. ;
action := 2 ;
move_land gd dgs gn
end
else begin
if logg then Printf.fprintf stderr "Now you're screwed (_2)\n" ;
4
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
1
250.0
3
13 21
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 3 3 3 3 6 6 6 4 4 4 4 4 4 4 4 4 4 5 5 1
1 3 1 3 1 6 1 6 1 0 1 0 1 0 1 4 1 5 1 5 1
1 3 6 6 6 6 6 3 6 3 0 0 4 5 4 4 4 4 4 5 1
1 6 1 3 1 3 1 3 1 3 1 0 1 5 1 4 1 5 1 5 1
1 6 0 6 6 6 3 3 3 3 3 3 3 3 3 3 3 5 4 5 1
1 6 1 3 1 3 1 3 1 3 1 3 1 5 1 4 1 5 1 5 1
1 6 3 3 3 3 3 3 3 3 3 3 3 5 5 4 5 5 5 5 1
1 6 1 6 1 3 1 3 1 3 1 3 1 5 1 4 1 5 1 4 1
1 6 6 3 3 3 5 5 5 3 5 3 5 5 5 5 5 5 5 5 1
1 6 1 6 1 3 1 3 1 0 1 3 1 0 1 5 1 5 1 4 1
1 6 3 3 3 3 3 3 3 3 0 5 5 5 5 5 5 5 5 5 1
1 3 6 6 6 6 6 3 6 4 6 3 5 6 5 6 5 5 5 5 1
1 3 1 3 1 6 1 3 1 4 1 3 1 3 1 6 1 5 1 5 1
1 6 3 3 3 4 3 6 3 3 3 3 4 3 4 6 4 4 5 5 1
1 3 1 3 1 4 1 4 1 6 1 3 1 3 1 6 1 5 1 5 1
1 3 3 4 4 4 4 4 6 6 6 3 6 6 6 6 6 3 3 5 1
1 6 1 4 1 4 1 4 1 6 1 3 1 3 1 6 1 5 1 4 1
1 4 3 6 4 4 3 3 3 3 3 3 3 3 3 6 3 3 3 5 1
1 6 1 4 1 4 1 4 1 6 1 3 1 3 1 6 1 5 1 4 1
1 3 6 6 6 4 4 4 4 4 4 3 3 3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