weird behavior with bonuses

This commit is contained in:
Alexandre 2024-12-02 17:25:45 +01:00
parent 2cc0bfa70a
commit d09422f280
8 changed files with 45 additions and 27 deletions

BIN
again

Binary file not shown.

BIN
again.cmi

Binary file not shown.

BIN
again.cmx

Binary file not shown.

View File

@ -538,6 +538,20 @@ let min_dist_from_player (gd : game_data) (x : int) (y : int) =
) )
) ;; ) ;;
let min_dist_with_dash (gd : game_data) (x : int) (y : int) =
Array.fold_left min 999999 (Array.init
(Array.length gd.players)
(fun i ->
if gd.player_id = gd.players.(i).id then
999999
else begin
let d = tile_distance gd x y (gd.players.(i).xy.x) (gd.players.(i).xy.y) in
if d = 0 then 0 else
if d = -1 then 999999 else max 1 (d - 3*gd.players.(i).ndash)
end
)
) ;;
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
@ -589,7 +603,7 @@ let generate_dead_end_map (gd : game_data) =
end end
end end
in in
dfs gd.players.(pid).xy.x gd.players.(pid).xy.y [] 4 ; dfs gd.players.(pid).xy.x gd.players.(pid).xy.y [] 4;
(* fills remaining spaces with BFS *) (* fills remaining spaces with BFS *)
let bfs (x0 : int) (y0 : int) = let bfs (x0 : int) (y0 : int) =
@ -617,7 +631,7 @@ let generate_dead_end_map (gd : game_data) =
done; done;
() ()
with with
| ReturnInt k -> res.(x0).(y0) <- k | ReturnInt k -> res.(x0).(y0) <- k
in in
for l = 0 to lines -1 do for l = 0 to lines -1 do
for c = 0 to cols -1 do for c = 0 to cols -1 do
@ -793,7 +807,7 @@ let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (sti
let pid = gd.player_id in let pid = gd.player_id in
let needs_gtfo = not (is_empty_lst dgs.explosionTimes.(x0).(y0)) in let needs_gtfo = not (is_empty_lst dgs.explosionTimes.(x0).(y0)) in
let nearest_player = min_dist_from_player gd gd.players.(pid).xy.x gd.players.(pid).xy.y in let nearest_player = min_dist_with_dash gd gd.players.(pid).xy.x gd.players.(pid).xy.y in
let undead_end_tiles = generate_dead_end_map gd in let undead_end_tiles = generate_dead_end_map gd in
@ -829,7 +843,7 @@ let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (sti
not (Array.fold_left (fun acc (b : bomb) -> acc || (b.xy.x = x && b.xy.y = y)) false gd.bombs) && not (Array.fold_left (fun acc (b : bomb) -> acc || (b.xy.x = x && b.xy.y = y)) false gd.bombs) &&
polar <= 4 polar <= 4
then begin (* is not lethal *) then begin (* is not lethal *)
if ct = stime+. interval then begin if ct = stime +. interval then begin
Printf.fprintf stderr "%b %b %b %b %b\n" Printf.fprintf stderr "%b %b %b %b %b\n"
(ct >= stime +. (float_of_int minDist) *. interval) (* not too deep *) (ct >= stime +. (float_of_int minDist) *. interval) (* not too deep *)
(is_empty_lst dgs.explosionTimes.(x).(y)) (* safe *) (is_empty_lst dgs.explosionTimes.(x).(y)) (* safe *)
@ -909,6 +923,7 @@ let move_crate (gd : game_data) (dgs : danger_map) =
raise (ReturnInt 4) raise (ReturnInt 4)
end; end;
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 let bonusres = bfs_for_crate gd dgs cxi cyi gd.dt false true false 0 false 7 in
if bonusres <> 4 then begin if bonusres <> 4 then begin
if logg then Printf.fprintf stderr "bonus spotted\n" ; if logg then Printf.fprintf stderr "bonus spotted\n" ;

BIN
again.o

Binary file not shown.

View File

@ -1,25 +1,29 @@
224.90000000000097 155.0
2 2
13 21 13 21
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 3 0 3 0 3 0 0 4 4 4 4 3 3 3 3 1 1 3 3 3 6 6 6 6 6 0 2 2 2 0 4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 9 2 1 4 1 2 3 6 15 2 0 1 2 2 0
3 14 3 0 1 3 2 1 7 7 3 1 2 4 5 6
2 5
2 11 0 11 8 0
1 10 1 11 12 0
10 7 1
7 9 2
1 9 4

View File

@ -427,8 +427,8 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo
indiceJoueur = trouve_objet(i,j,joueurs) indiceJoueur = trouve_objet(i,j,joueurs)
while indiceJoueur != None: while indiceJoueur != None:
joueurs[indiceJoueur] = None joueurs[indiceJoueur] = None
print("DEATH :", indiceJoueur) print("\n\nDEATH :", indiceJoueur, "\n\n")
assert(false) #assert(false)
indiceJoueur = trouve_objet(i,j,joueurs) indiceJoueur = trouve_objet(i,j,joueurs)
# On fait exploser la bombe s'il y en a une # On fait exploser la bombe s'il y en a une

View File

@ -1 +0,0 @@
4 0