experimental changes to pathfinding
This commit is contained in:
parent
f620572de5
commit
2cc0bfa70a
33
again.ml
33
again.ml
|
@ -11,7 +11,7 @@ TODO :
|
|||
Random.self_init () ;;
|
||||
|
||||
let debug_all = false ;;
|
||||
let logg = false ;;
|
||||
let logg = true ;;
|
||||
|
||||
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
|
||||
(* ---------------------------------------------------------------------------------------------------------------------------------------------------- *)
|
||||
|
@ -797,7 +797,7 @@ let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (sti
|
|||
|
||||
let undead_end_tiles = generate_dead_end_map gd in
|
||||
|
||||
if gd.player_id = 0 then begin
|
||||
if false && gd.player_id = 0 then begin
|
||||
for l = 0 to Array.length undead_end_tiles -1 do
|
||||
for c = 0 to Array.length undead_end_tiles.(l) -1 do
|
||||
if undead_end_tiles.(l).(c) >= 727 then
|
||||
|
@ -819,27 +819,38 @@ let bfs_for_crate (gd : game_data) (dgs : danger_map) (x0 : int) (y0 : int) (sti
|
|||
try
|
||||
while not (Queue.is_empty q) do
|
||||
let (x, y, ct, direction, polar) = Queue.pop q in
|
||||
(*Printf.fprintf stderr "at (%d %d)\n" x y;*)
|
||||
if is_valid x y lines cols && gd.laby.(x).(y) <> 1 && gd.laby.(x).(y) <> 2 then begin (* within the map *)
|
||||
if Hashtbl.find_opt visited (x, y, polar) = None then begin (* has not been visited yet *)
|
||||
Hashtbl.add visited (x, y, polar) 1 ;
|
||||
if
|
||||
not (is_dead_all dgs x y ct interval ignorePlayers) &&
|
||||
ct < stime +. (float_of_int maxDist) *. interval &&
|
||||
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
|
||||
then begin (* is not lethal *)
|
||||
if ct = stime+. interval then begin
|
||||
Printf.fprintf stderr "%b %b %b %b %b\n"
|
||||
(ct >= stime +. (float_of_int minDist) *. interval) (* not too deep *)
|
||||
(is_empty_lst dgs.explosionTimes.(x).(y)) (* safe *)
|
||||
(needs_gtfo || undead_end_tiles.(x).(y) * 2 <= nearest_player) (* is not going to be an ez kill *)
|
||||
(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 *)
|
||||
end;
|
||||
if
|
||||
(ct >= stime +. (float_of_int minDist) *. interval) && (* not too deep *)
|
||||
(is_empty_lst dgs.explosionTimes.(x).(y)) && (* safe *)
|
||||
(undead_end_tiles.(x).(y) * 2 <= nearest_player) && (* is not going to be an ez kill *)
|
||||
(needs_gtfo || undead_end_tiles.(x).(y) * 2 <= nearest_player) && (* is not going to be an ez kill *)
|
||||
(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
|
||||
raise (ReturnInt direction)
|
||||
end;
|
||||
if not (x0 == x && y0 == y) && (needs_gtfo || undead_end_tiles.(x).(y) * 2 <= nearest_player) then begin
|
||||
if not (x0 = x && y0 = y) && (needs_gtfo || undead_end_tiles.(x).(y) * 2 <= nearest_player) then begin
|
||||
for dir = 0 to 3 do
|
||||
Queue.add (x + (fst order.(dir)), y + (snd order.(dir)), ct +. interval, direction, polar) q ;
|
||||
done;
|
||||
Queue.add (x, y, ct +. interval, direction, polar+1) q
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -855,7 +866,7 @@ let move_crate (gd : game_data) (dgs : danger_map) =
|
|||
and cyi = gd.players.(pid).xy.y in
|
||||
try
|
||||
(* send away a player standing right on top *)
|
||||
if Array.exists (fun (p : player) -> p.id <> pid && p.xy.x = cxi && p.xy.y = cyi) gd.players then begin
|
||||
if 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 gd.players.(pid).bomb_to_place > 0 then begin
|
||||
if logg then Printf.fprintf stderr "oh no you dont\n" ;
|
||||
let saved_p = simulate_bomb_deconstruct dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in
|
||||
|
@ -883,6 +894,7 @@ let move_crate (gd : game_data) (dgs : danger_map) =
|
|||
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
|
||||
if logg then Printf.fprintf stderr "Bonus Spotted\n" ;
|
||||
action := 1 ;
|
||||
raise (ReturnInt bonusres_2) ;
|
||||
end;
|
||||
|
||||
|
@ -904,12 +916,19 @@ let move_crate (gd : game_data) (dgs : danger_map) =
|
|||
end;
|
||||
if logg then Printf.fprintf stderr "searching...\n" ;
|
||||
let rescr = bfs_for_crate gd dgs cxi cyi gd.dt true false false 0 false 80 in
|
||||
if logg then Printf.fprintf stderr "searching Done...\n" ;
|
||||
if rescr <> 4 then
|
||||
rescr
|
||||
else begin
|
||||
if logg then Printf.fprintf stderr "searching 2...\n" ;
|
||||
let rescr2 = bfs_for_crate gd dgs cxi cyi gd.dt false false false 0 false 80 in
|
||||
rescr2
|
||||
if logg then Printf.fprintf stderr "searching 2 Done...\n" ;
|
||||
if rescr2 <> 4 then
|
||||
rescr2
|
||||
else begin
|
||||
if logg then Printf.fprintf stderr "Needs dash lmao\n";
|
||||
4
|
||||
end
|
||||
end
|
||||
with
|
||||
| ReturnInt k -> k ;;
|
||||
|
|
36
entrees.txt
36
entrees.txt
|
@ -1,23 +1,25 @@
|
|||
229.1200000000008
|
||||
224.90000000000097
|
||||
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 3 3 3 6 3 6 3 3 3 3 3 5 5 5 5 5 5 5 5 1
|
||||
1 3 1 3 1 3 1 6 1 3 1 3 1 4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 0 1 2 4 3 3
|
||||
10 11 1 2 1 6 0 1
|
||||
10 13 2 2 1 3 2 3
|
||||
9 6 3 5 2 2 4 1
|
||||
0
|
||||
1 9 0 2 4 7 1 3
|
||||
3 10 1 3 1 2 1 1
|
||||
3 9 2 1 4 1 2 3
|
||||
3 14 3 0 1 3 2 1
|
||||
2
|
||||
2 11 0
|
||||
1 10 1
|
||||
|
|
|
@ -428,6 +428,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo
|
|||
while indiceJoueur != None:
|
||||
joueurs[indiceJoueur] = None
|
||||
print("DEATH :", indiceJoueur)
|
||||
assert(false)
|
||||
indiceJoueur = trouve_objet(i,j,joueurs)
|
||||
|
||||
# On fait exploser la bombe s'il y en a une
|
||||
|
|
Loading…
Reference in New Issue