fixed gain map beinc incorrect + adjusted seek_player
This commit is contained in:
parent
ea743f6c17
commit
9cddee289a
89
again.ml
89
again.ml
|
@ -442,6 +442,64 @@ let build_danger_map (gd : game_data) =
|
||||||
done;
|
done;
|
||||||
res ;;
|
res ;;
|
||||||
|
|
||||||
|
let is_worth (gd : game_data) (bsize : int) =
|
||||||
|
let lines = Array.length gd.laby
|
||||||
|
and cols = Array.length gd.laby.(0) in
|
||||||
|
let cxi = gd.players.(gd.player_id).xy.x
|
||||||
|
and cyi = gd.players.(gd.player_id).xy.y in
|
||||||
|
let halt = ref false in
|
||||||
|
let count = ref 0 in
|
||||||
|
try
|
||||||
|
if gd.laby.(cxi).(cyi) = 1 || gd.laby.(cxi).(cyi) = 2 then
|
||||||
|
raise (ReturnBool false);
|
||||||
|
for dir = 0 to 3 do
|
||||||
|
for w = 0 to bsize do
|
||||||
|
if not !halt && dir = 0 || w > 0 then begin
|
||||||
|
let nx = cxi + w * (fst order.(dir))
|
||||||
|
and ny = cyi + w * (snd order.(dir)) in
|
||||||
|
if is_valid nx ny lines cols then begin
|
||||||
|
if gd.laby.(nx).(ny) = 0 || gd.laby.(nx).(ny) >= 3 && gd.laby.(nx).(ny) <> 3+gd.player_id then begin
|
||||||
|
incr count ;
|
||||||
|
if !count >= 2 then
|
||||||
|
raise (ReturnBool true)
|
||||||
|
end
|
||||||
|
else if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 then
|
||||||
|
halt := true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
done ;
|
||||||
|
halt := false
|
||||||
|
done ;
|
||||||
|
false
|
||||||
|
with
|
||||||
|
| ReturnBool b -> b ;;
|
||||||
|
|
||||||
|
let is_worth_pos (gd : game_data) (cxi : int) (cyi : int) (bsize : int) =
|
||||||
|
let lines = Array.length gd.laby
|
||||||
|
and cols = Array.length gd.laby.(0) in
|
||||||
|
let halt = ref false in
|
||||||
|
try
|
||||||
|
if gd.laby.(cxi).(cyi) = 1 || gd.laby.(cxi).(cyi) = 2 then
|
||||||
|
raise (ReturnBool false);
|
||||||
|
for dir = 0 to 3 do
|
||||||
|
for w = 0 to bsize do
|
||||||
|
if not !halt && dir = 0 || w > 0 then begin
|
||||||
|
let nx = cxi + w * (fst order.(dir))
|
||||||
|
and ny = cyi + w * (snd order.(dir)) in
|
||||||
|
if is_valid nx ny lines cols then begin
|
||||||
|
if gd.laby.(nx).(ny) = 0 || gd.laby.(nx).(ny) >= 3 && gd.laby.(nx).(ny) <> 3+gd.player_id then
|
||||||
|
raise (ReturnBool true)
|
||||||
|
else if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 then
|
||||||
|
halt := true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
done ;
|
||||||
|
halt := false
|
||||||
|
done ;
|
||||||
|
false
|
||||||
|
with
|
||||||
|
| ReturnBool b -> b ;;
|
||||||
|
|
||||||
let generate_gain_map (gd : game_data) (dgs : danger_map) =
|
let generate_gain_map (gd : game_data) (dgs : danger_map) =
|
||||||
let lines = Array.length gd.laby
|
let lines = Array.length gd.laby
|
||||||
and cols = Array.length gd.laby.(0) in
|
and cols = Array.length gd.laby.(0) in
|
||||||
|
@ -451,7 +509,7 @@ let generate_gain_map (gd : game_data) (dgs : danger_map) =
|
||||||
(* aim towards center by adding a bonus *)
|
(* aim towards center by adding a bonus *)
|
||||||
for i = 0 to lines -1 do
|
for i = 0 to lines -1 do
|
||||||
for j = 0 to cols -1 do
|
for j = 0 to cols -1 do
|
||||||
if (gd.laby.(i).(j) >= 3) || gd.laby.(i).(j) = 0 then
|
if false && is_worth_pos gd i j gd.players.(gd.player_id).bomb_radius then
|
||||||
res.(i).(j) <- res.(i).(j) + (min (min (i) (lines -1-i)) (min (j) (cols -1-j))) ;
|
res.(i).(j) <- res.(i).(j) + (min (min (i) (lines -1-i)) (min (j) (cols -1-j))) ;
|
||||||
done
|
done
|
||||||
done ;
|
done ;
|
||||||
|
@ -466,7 +524,7 @@ let generate_gain_map (gd : game_data) (dgs : danger_map) =
|
||||||
if dir = 0 || w > 0 then begin
|
if dir = 0 || w > 0 then begin
|
||||||
let nx = l + w * (fst order.(dir))
|
let nx = l + w * (fst order.(dir))
|
||||||
and ny = c + w * (snd order.(dir)) in
|
and ny = c + w * (snd order.(dir)) in
|
||||||
if is_valid nx ny lines cols then begin
|
if not !halt && is_valid nx ny lines cols then begin
|
||||||
if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 || Array.exists (fun (b : bomb) -> b.xy.x = nx && b.xy.y = ny) gd.bombs then
|
if gd.laby.(nx).(ny) = 1 || gd.laby.(nx).(ny) = 2 || Array.exists (fun (b : bomb) -> b.xy.x = nx && b.xy.y = ny) gd.bombs then
|
||||||
halt := true
|
halt := true
|
||||||
else if gd.laby.(nx).(ny) <> 3+gd.player_id then begin
|
else if gd.laby.(nx).(ny) <> 3+gd.player_id then begin
|
||||||
|
@ -1085,6 +1143,14 @@ let closest_boom (dgs : danger_map) (x : int) (y : int) =
|
||||||
if logg then Printf.fprintf stderr "%d %d\n" x y ;
|
if logg then Printf.fprintf stderr "%d %d\n" x y ;
|
||||||
List.fold_left min 999999. dgs.explosionTimes.(x).(y) ;;
|
List.fold_left min 999999. dgs.explosionTimes.(x).(y) ;;
|
||||||
|
|
||||||
|
let add_player_count (gd : game_data) =
|
||||||
|
let res = ref 0 in
|
||||||
|
for pl = 0 to 3 do
|
||||||
|
if gd.players.(pl).id <> -1 && gd.players.(pl).id <> gd.player_id then
|
||||||
|
res := 1
|
||||||
|
done ;
|
||||||
|
!res ;;
|
||||||
|
|
||||||
let seek_player (gd : game_data) (dgs : danger_map) =
|
let seek_player (gd : game_data) (dgs : danger_map) =
|
||||||
(* returns whether or not it found a target, and prints if found *)
|
(* returns whether or not it found a target, and prints if found *)
|
||||||
(* note : if this triggers then someone WILL die *)
|
(* note : if this triggers then someone WILL die *)
|
||||||
|
@ -1106,6 +1172,10 @@ let seek_player (gd : game_data) (dgs : danger_map) =
|
||||||
if logg then Printf.fprintf stderr "No trap/available bomb\n" ;
|
if logg then Printf.fprintf stderr "No trap/available bomb\n" ;
|
||||||
raise (ReturnBool false)
|
raise (ReturnBool false)
|
||||||
end ;
|
end ;
|
||||||
|
if gd.players.(pid).ndash <= add_player_count gd then begin
|
||||||
|
if logg then Printf.fprintf stderr "Saving bombs\n" ;
|
||||||
|
raise (ReturnBool false)
|
||||||
|
end ;
|
||||||
if logg then Printf.fprintf stderr "Can trap\n" ;
|
if logg then Printf.fprintf stderr "Can trap\n" ;
|
||||||
while not !has_trapped do
|
while not !has_trapped do
|
||||||
for pl = 0 to Array.length gd.players -1 do
|
for pl = 0 to Array.length gd.players -1 do
|
||||||
|
@ -1317,12 +1387,12 @@ let rec move_land (gd : game_data) (dgs : danger_map) (gn : int array array) =
|
||||||
end;
|
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 -. !remaining_dash *. interval) 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 && is_worth gd gd.players.(pid).bomb_radius then begin
|
||||||
if logg then Printf.fprintf stderr "kaboom\n" ;
|
if logg then Printf.fprintf stderr "kaboom\n" ;
|
||||||
action := 1 ;
|
action := 1 ;
|
||||||
result_bomb
|
result_bomb
|
||||||
|
@ -1393,7 +1463,7 @@ let get_cd (filename : string) =
|
||||||
close_in ptr ;;
|
close_in ptr ;;
|
||||||
|
|
||||||
let set_cd (nspeed : int) (filename : string) =
|
let set_cd (nspeed : int) (filename : string) =
|
||||||
if !remaining_dash = 0. then begin
|
if !remaining_dash = 0. && !action <> 2 then begin
|
||||||
let ptr = open_out filename in
|
let ptr = open_out filename in
|
||||||
let interval = Float.pow 0.9 (float_of_int nspeed) in
|
let interval = Float.pow 0.9 (float_of_int nspeed) in
|
||||||
Printf.fprintf ptr "%f\n" (max 0. (!cd -. interval)) ;
|
Printf.fprintf ptr "%f\n" (max 0. (!cd -. interval)) ;
|
||||||
|
@ -1413,7 +1483,7 @@ get_rem_dash "again_rem.sav" ;;
|
||||||
get_cd "again_cooldown.sav" ;;
|
get_cd "again_cooldown.sav" ;;
|
||||||
|
|
||||||
(*Printf.fprintf stderr "\n" ;;*)
|
(*Printf.fprintf stderr "\n" ;;*)
|
||||||
if game_map.player_id = 4 then begin
|
if game_map.player_id = 727 then begin
|
||||||
for l = 0 to Array.length gain_map -1 do
|
for l = 0 to Array.length gain_map -1 do
|
||||||
for c = 0 to Array.length gain_map.(l) -1 do
|
for c = 0 to Array.length gain_map.(l) -1 do
|
||||||
print_integer_aligned gain_map.(l).(c) 3
|
print_integer_aligned gain_map.(l).(c) 3
|
||||||
|
@ -1450,14 +1520,13 @@ else begin
|
||||||
if logg then Printf.fprintf stderr "[player %d] %d %d (at time %f - with %d dash potential)\n" game_map.player_id !direction !action game_map.dt (int_of_float !remaining_dash);
|
if logg then Printf.fprintf stderr "[player %d] %d %d (at time %f - with %d dash potential)\n" game_map.player_id !direction !action game_map.dt (int_of_float !remaining_dash);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
cd := (Float.pow 0.9 (float_of_int game_map.players.(game_map.player_id).nspeed)) *. 2.5 ;
|
cd := 3.0;
|
||||||
ignore (read_queue "again_dash.sav")
|
ignore (read_queue "again_dash.sav")
|
||||||
end
|
end
|
||||||
end;;
|
end;;
|
||||||
(*Printf.printf "\n4 0" ;;*)
|
|
||||||
set_rem_dash "again_rem.sav" ;;
|
set_rem_dash "again_rem.sav" ;;
|
||||||
set_cd game_map.players.(game_map.player_id).nspeed "again_cooldown.sav" ;;
|
set_cd game_map.players.(game_map.player_id).nspeed "again_cooldown.sav" ;;
|
||||||
(*set_meta_info game_map.player_id ;;*)
|
(*set_meta_info game_map.player_id ;;*)
|
||||||
let __end = Unix.gettimeofday() ;;
|
let __end = Unix.gettimeofday() ;;
|
||||||
if logg then Printf.fprintf stderr "Time : %f\n\n" (__end -. __start) ;;
|
if logg then Printf.fprintf stderr "Time : %f\n\n" (__end -. __start) ;;
|
||||||
|
|
41
entrees.txt
41
entrees.txt
|
@ -1,27 +1,24 @@
|
||||||
140.0
|
284.6347000000014
|
||||||
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 6 3 3 3 3 3 3 0 2 2 2 0 5 5 5 5 5 5 5 1
|
1 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1
|
||||||
1 6 1 3 1 0 1 2 1 2 1 2 1 2 1 5 1 5 1 5 1
|
1 3 1 6 1 6 1 5 1 5 1 6 1 5 1 6 1 5 1 5 1
|
||||||
1 6 6 3 6 6 6 0 2 2 2 2 0 5 5 5 5 5 5 5 1
|
1 6 5 5 5 5 5 5 5 5 5 5 5 5 5 6 5 5 5 5 1
|
||||||
1 6 1 3 1 6 1 0 1 2 1 2 1 2 1 5 1 5 1 5 1
|
1 6 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 4 1 5 1
|
||||||
1 3 6 6 6 6 6 6 0 2 2 2 2 0 0 5 5 5 5 5 1
|
1 6 6 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 5 1
|
||||||
1 6 1 3 1 6 1 0 1 2 1 2 1 5 1 5 1 5 1 4 1
|
1 3 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1
|
||||||
1 6 6 6 6 6 6 6 6 6 0 0 0 5 5 5 4 4 4 4 1
|
1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 5 5 5 1
|
||||||
1 6 1 3 1 6 1 0 1 2 1 5 1 5 1 4 1 4 1 4 1
|
1 3 1 6 1 6 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1
|
||||||
1 6 6 6 6 6 6 6 6 5 5 5 5 5 5 4 4 4 4 4 1
|
1 6 5 5 5 5 5 5 5 5 5 5 5 6 5 5 5 5 5 6 1
|
||||||
1 6 1 6 1 6 1 0 1 2 1 5 1 5 1 4 1 4 1 4 1
|
1 6 1 3 1 3 1 5 1 5 1 6 1 6 1 6 1 6 1 4 1
|
||||||
1 6 6 6 6 6 6 6 0 2 0 5 5 5 5 4 4 4 4 4 1
|
1 6 5 5 5 5 6 5 6 5 6 6 6 5 5 5 5 6 6 6 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
|
||||||
|
4
|
||||||
|
9 13 5 286.1981000000015
|
||||||
|
10 13 5 286.85420000000147
|
||||||
|
11 13 5 287.51030000000145
|
||||||
|
11 14 5 288.16640000000143
|
||||||
1
|
1
|
||||||
11 5 5 140.17600000000024
|
9 15 2 4 0 5 2 0
|
||||||
2
|
0
|
||||||
10 11 2 0 4 2 2 2
|
|
||||||
7 3 3 3 1 5 1 1
|
|
||||||
5
|
|
||||||
1 8 4
|
|
||||||
1 12 2
|
|
||||||
3 7 3
|
|
||||||
3 12 2
|
|
||||||
2 5 3
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0
|
1
|
||||||
|
|
Loading…
Reference in New Issue