diff --git a/again b/again index 4f037b3..015dd10 100755 Binary files a/again and b/again differ diff --git a/again.cmi b/again.cmi index 9ffba6d..c6f7781 100644 Binary files a/again.cmi and b/again.cmi differ diff --git a/again.cmx b/again.cmx index 6d31559..99404fa 100644 Binary files a/again.cmx and b/again.cmx differ diff --git a/again.ml b/again.ml index b9e79d3..29b81df 100644 --- a/again.ml +++ b/again.ml @@ -241,6 +241,11 @@ let set_meta_info (pid : int) = (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) +let print_integer_aligned (n : int) (dmax : int) = + let size = 1+ln_b 10 n in + Printf.fprintf stderr "%d" n ; + Printf.fprintf stderr "%s" (String.make (dmax-size+1) ' ') ;; + let int_of_string (str : string) = String.fold_left (fun acc ch -> let cd = Char.code ch in if cd >= 48 || cd <= 57 then 10*acc + cd - 48 else failwith "not an integer\n") 0 str ;; @@ -432,7 +437,7 @@ let build_danger_map (gd : game_data) = done; res ;; -let generate_gain_map (gd : game_data) = +let generate_gain_map (gd : game_data) (dgs : danger_map) = let lines = Array.length gd.laby and cols = Array.length gd.laby.(0) in let bsize = gd.players.(gd.player_id).bomb_radius in @@ -441,6 +446,7 @@ let generate_gain_map (gd : game_data) = (* aim towards center by adding a bonus *) for i = 0 to lines -1 do for j = 0 to cols -1 do + if (gd.laby.(i).(j) >= 3) || gd.laby.(i).(j) = 0 then res.(i).(j) <- res.(i).(j) + (min (min (i) (lines -1-i)) (min (j) (cols -1-j))) ; done done ; @@ -449,18 +455,24 @@ let generate_gain_map (gd : game_data) = for l = 0 to lines -1 do for c = 0 to cols -1 do if (gd.laby.(l).(c) >= 3) || gd.laby.(l).(c) = 0 then begin + let halt = ref false in for dir = 0 to 3 do for w = 0 to bsize do - if (w > 0) || dir = 0 then begin + if dir = 0 || w > 0 then begin let nx = l + w * (fst order.(dir)) and ny = c + w * (snd order.(dir)) in - if is_valid nx ny lines cols && gd.laby.(l).(c) <> 3+gd.player_id then begin - res.(nx).(ny) <- res.(nx).(ny) + 1; - if (gd.laby.(l).(c) >= 3) then - res.(nx).(ny) <- res.(nx).(ny) + 1; + if 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 + halt := true + else if gd.laby.(nx).(ny) <> 3+gd.player_id then begin + res.(l).(c) <- res.(l).(c) +1 ; + if gd.laby.(nx).(ny) <> 0 then + res.(l).(c) <- res.(l).(c) +1 ; + end end end - done + done ; + halt := false ; done end done @@ -676,14 +688,14 @@ let reverse_simulate_bomb (dgs : danger_map) (save : (int * int, float) Hashtbl. let is_dead (dgs : danger_map) (x : int) (y : int) (t : float) (dt : float) = (List.fold_left (* bombs *) - (fun acc curtime -> - acc || (t >= curtime && t <= curtime +. dt) + (fun acc expl_time -> + acc || (t >= expl_time && t <= expl_time +. dt) ) false dgs.explosionTimes.(x).(y) ) || (List.fold_left (* player-related bombs (only if in range of another bomb) *) - (fun acc curtime -> - acc || (t >= curtime && t <= curtime +. dt) + (fun acc expl_time -> + acc || (t >= expl_time && t <= expl_time +. dt) ) false dgs.playersTimes.(x).(y) @@ -691,8 +703,8 @@ let is_dead (dgs : danger_map) (x : int) (y : int) (t : float) (dt : float) = let is_dead_2 (dgs : danger_map) (x : int) (y : int) (t : float) (dt : float) = (List.fold_left - (fun acc curtime -> - acc || (t >= curtime && t <= curtime +. dt) + (fun acc expl_time -> + acc || (t >= expl_time && t <= expl_time +. dt) ) false dgs.explosionTimes.(x).(y) @@ -924,16 +936,23 @@ let rec move_crate (gd : game_data) (dgs : danger_map) = if !success then rescr2 else begin - if logg then Printf.fprintf stderr "Needs dash lmao\n"; - if !remaining_dash <> 0. && gd.players.(pid).ndash > 0 then begin - if logg then Printf.fprintf stderr "---------------- Lets rewind time for a bit ----------------\n"; - remaining_dash := 3. ; - action := 2 ; - move_crate gd dgs - end + if logg then Printf.fprintf stderr "ignoring players...\n" ; + let rescrip2 = bfs_for_crate ~return_ok:success gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false false false 0 true 80 in + if logg then Printf.fprintf stderr "ignoring players Done (%d)...\n" rescrip2 ; + if !success then + rescrip2 else begin - if logg then Printf.fprintf stderr "Now you're screwed\n" ; - 4 + if logg then Printf.fprintf stderr "Needs dash lmao\n"; + if !remaining_dash <> 0. && gd.players.(pid).ndash > 0 then begin + if logg then Printf.fprintf stderr "---------------- Lets rewind time for a bit ----------------\n"; + remaining_dash := 3. ; + action := 2 ; + move_crate gd dgs + end + else begin + if logg then Printf.fprintf stderr "Now you're screwed\n" ; + 4 + end end end end @@ -1111,10 +1130,20 @@ let __start = Unix.gettimeofday() ;; let game_map = parse_input "entrees.txt" ;; if debug_all then print_game_data game_map ;; let danger_data = build_danger_map game_map ;; -let gain_map = generate_gain_map game_map ;; +let gain_map = generate_gain_map game_map danger_data ;; get_rem_dash ("again"^(string_of_int game_map.player_id)^".sav") ;; +Printf.fprintf stderr "\n" ;; +if game_map.player_id = 4 then begin + for l = 0 to Array.length gain_map -1 do + for c = 0 to Array.length gain_map.(l) -1 do + print_integer_aligned gain_map.(l).(c) 3 + done; + Printf.fprintf stderr "\n" + done +end ;; + (*Printf.fprintf stderr "\n" ;; print_dangers danger_data ;;*) diff --git a/again.o b/again.o index dc98ec9..2478c14 100644 Binary files a/again.o and b/again.o differ diff --git a/entrees.txt b/entrees.txt index b7e5f3b..f1558da 100644 --- a/entrees.txt +++ b/entrees.txt @@ -1,29 +1,29 @@ -102.4000000000002 -1 +182.76300000000106 +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 6 6 6 6 6 0 2 2 2 2 2 0 5 5 5 5 1 -1 3 1 3 1 6 1 3 1 2 1 2 1 2 1 0 1 5 1 5 1 -1 3 3 3 6 6 6 3 6 0 2 2 2 0 5 5 5 5 5 5 1 -1 3 1 6 1 6 1 6 1 2 1 2 1 2 1 5 1 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-9 7 1 -3 13 4 +6 13 0 5 1 4 4 5 +11 17 1 3 0 3 2 1 +9 11 2 1 7 1 4 2 +6 9 3 3 1 8 2 1 +1 +6 1 0 diff --git a/iachallenge2024_bomberman_tkinter.py b/iachallenge2024_bomberman_tkinter.py index e72714b..570ce76 100644 --- a/iachallenge2024_bomberman_tkinter.py +++ b/iachallenge2024_bomberman_tkinter.py @@ -450,7 +450,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo indiceJoueur = trouve_objet(i,j,joueurs) while indiceJoueur != None: joueurs[indiceJoueur] = None - print("\n\nDEATH (at time =", evenement[0], "):", indiceJoueur, "\n\n") + print("\n--------------------------------------------------------------------------------------------------------\n\nDEATH (at time =", evenement[0], "):", indiceJoueur, "\n\n--------------------------------------------------------------------------------------------------------\n") #assert(false) indiceJoueur = trouve_objet(i,j,joueurs) diff --git a/signal.txt b/signal.txt index c227083..d00491f 100644 --- a/signal.txt +++ b/signal.txt @@ -1 +1 @@ -0 \ No newline at end of file +1 diff --git a/sortie.txt b/sortie.txt index 69035af..389086a 100644 --- a/sortie.txt +++ b/sortie.txt @@ -1 +1 @@ -3 0 \ No newline at end of file +2 0 \ No newline at end of file