bonuses are painful to deal with

This commit is contained in:
Alexandre 2024-12-02 17:41:02 +01:00
parent d09422f280
commit 14dae2a4cb
6 changed files with 37 additions and 31 deletions

BIN
again

Binary file not shown.

BIN
again.cmi

Binary file not shown.

BIN
again.cmx

Binary file not shown.

View File

@ -16,6 +16,7 @@ let logg = true ;;
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
let fodder = ref 0 ;;
type pt = {
x : int ;
y : int ;
@ -797,7 +798,7 @@ let sees_a_crate (gd : game_data) (dgs : danger_map) (x : int) (y : int) =
with
| ReturnBool b -> b ;;
let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (stime : float) (searchCrate : bool) (searchBonus : bool) (placedBomb : bool) (minDist : int) (ignorePlayers : bool) (maxDist : int) =
let bfs_for_crate ?return_x:(retx=fodder) ?return_y:(rety=fodder) (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (stime : float) (searchCrate : bool) (searchBonus : bool) (placedBomb : bool) (minDist : int) (ignorePlayers : bool) (maxDist : int) =
let lines = Array.length gd.laby
and cols = Array.length gd.laby.(0) in
@ -858,6 +859,8 @@ let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (sti
(not searchCrate || (sees_a_crate gd dgs x y && not dgs.explodedCrates.(x).(y))) && (* sees a crate *)
(not searchBonus || dgs.bonusMap.(x).(y)) (* is a bonus *)
then begin
retx := x ;
rety := y ;
raise (ReturnInt direction)
end;
if not (x0 = x && y0 = y) && (needs_gtfo || undead_end_tiles.(x).(y) * 2 <= nearest_player) then begin
@ -904,9 +907,10 @@ let move_crate (gd : game_data) (dgs : danger_map) =
if gd.players.(pid).bomb_to_place > 0 then begin
if logg then Printf.fprintf stderr "trying...\n" ;
let saved = simulate_bomb_deconstruct dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in
let bonusres_2 = bfs_for_crate gd dgs cxi cyi gd.dt false true false 0 false 7 in
if bonusres_2 <> 4 then begin
let bonus2_x = ref 0
and bonus2_y = ref 0 in
let bonusres_2 = bfs_for_crate ~return_x:bonus2_x ~return_y:bonus2_y gd dgs cxi cyi gd.dt false true false 0 false 7 in
if bonusres_2 <> 4 && (tile_distance gd cxi cyi !bonus2_x !bonus2_y <= min_dist_from_player gd cxi cyi) then begin
if logg then Printf.fprintf stderr "Bonus Spotted\n" ;
action := 1 ;
raise (ReturnInt bonusres_2) ;
@ -924,8 +928,10 @@ let move_crate (gd : game_data) (dgs : danger_map) =
end;
end;
if logg then Printf.fprintf stderr "bonusing...\n" ;
let bonusres = bfs_for_crate gd dgs cxi cyi gd.dt false true false 0 false 7 in
if bonusres <> 4 then begin
let bonus_x = ref 0
and bonus_y = ref 0 in
let bonusres = bfs_for_crate ~return_x:bonus_x ~return_y:bonus_y gd dgs cxi cyi gd.dt false true false 0 false 7 in
if bonusres <> 4 && (tile_distance gd cxi cyi !bonus_x !bonus_y <= min_dist_from_player gd cxi cyi) then begin
if logg then Printf.fprintf stderr "bonus spotted\n" ;
raise (ReturnInt bonusres) ;
end;

BIN
again.o

Binary file not shown.

View File

@ -1,29 +1,29 @@
155.0
2
97.00000000000013
0
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 6 6 6 6 6 0 2 2 2 0 4 5 4 4 4 4 1
1 3 1 3 1 6 1 6 1 2 1 2 1 2 1 5 1 4 1 5 1
1 3 3 6 6 6 6 6 6 6 0 2 0 5 5 5 5 5 4 4 1
1 0 1 3 1 6 1 6 1 2 1 2 1 2 1 5 1 4 1 0 1
1 3 6 6 6 6 6 6 6 6 0 2 0 4 4 4 4 4 4 4 1
1 6 1 3 1 6 1 6 1 2 1 2 1 2 1 4 1 4 1 0 1
1 6 3 3 6 6 6 6 6 0 2 0 2 0 0 4 5 5 5 4 1
1 6 1 3 1 6 1 6 1 2 1 2 1 2 1 4 1 4 1 4 1
1 6 6 3 3 3 3 6 3 0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