diff --git a/again b/again index 9a7022b..4f037b3 100755 Binary files a/again and b/again differ diff --git a/again.cmi b/again.cmi index bce338c..9ffba6d 100644 Binary files a/again.cmi and b/again.cmi differ diff --git a/again.cmx b/again.cmx index f923c30..6d31559 100644 Binary files a/again.cmx and b/again.cmx differ diff --git a/again.ml b/again.ml index ee6d9c3..b9e79d3 100644 --- a/again.ml +++ b/again.ml @@ -11,7 +11,9 @@ TODO : Random.self_init () ;; let debug_all = false ;; -let logg = false ;; +let logg = true ;; + +let remaining_dash = ref 0. ;; (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -330,6 +332,16 @@ let parse_input (str : string) = close_in ptr ; failwith "cannot happen unless something is wrong" ;; +let get_rem_dash (filename : string) = + let ptr = open_in filename in + remaining_dash := float_of_int (int_of_string (input_line ptr)) ; + close_in ptr ;; + +let set_rem_dash (filename : string) = + let ptr = open_out filename in + Printf.fprintf ptr "%d\n" (int_of_float (max 0. (!remaining_dash -. 1.))) ; + close_out ptr ;; + let build_danger_map (gd : game_data) = let lines = Array.length gd.laby and cols = Array.length gd.laby.(0) in @@ -842,10 +854,11 @@ let bfs_for_crate ?return_x:(retx=fodder) ?return_y:(rety=fodder) ?return_ok:(re retfl := true ; k ;; -let move_crate (gd : game_data) (dgs : danger_map) = +let rec move_crate (gd : game_data) (dgs : danger_map) = let pid = gd.player_id in let cxi = gd.players.(pid).xy.x and cyi = gd.players.(pid).xy.y in + let interval = Float.pow 0.9 (float_of_int gd.players.(pid).nspeed) 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 && (is_empty_lst dgs.explosionTimes.(cxi).(cyi)) then begin @@ -853,15 +866,15 @@ let move_crate (gd : game_data) (dgs : danger_map) = if logg then Printf.fprintf stderr "oh no you dont\n" ; let saved_p = simulate_bomb_deconstruct gd dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in - let bonusres_2p = bfs_for_crate gd dgs cxi cyi gd.dt false true false 0 false 5 in + let bonusres_2p = bfs_for_crate gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false true false 0 false 5 in if bonusres_2p <> 4 then begin - if logg then Printf.fprintf stderr "mine\n" ; + if logg then Printf.fprintf stderr "mine (%d) \n" bonusres_2p ; raise (ReturnInt bonusres_2p) ; end; - let resultp = bfs_for_crate gd dgs cxi cyi gd.dt false false true 1 false 80 in - if resultp <> 4 then begin - if logg then Printf.fprintf stderr "go away\n" ; + let resultp = bfs_for_crate gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false false true 1 false 80 in + if resultp <> 4 && !action <> 2 then begin + if logg then Printf.fprintf stderr "go away (%d) \n" resultp ; action := 1 ; raise (ReturnInt resultp) ; end; @@ -874,15 +887,16 @@ let move_crate (gd : game_data) (dgs : danger_map) = let saved = simulate_bomb_deconstruct gd dgs cxi cyi gd.players.(pid).bomb_radius (gd.dt +. 5.5) in 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 5 in - if bonusres_2 <> 4 && (tile_distance gd cxi cyi !bonus2_x !bonus2_y <= min_dist_from_player gd cxi cyi) then begin + let bonusres_2 = bfs_for_crate ~return_x:bonus2_x ~return_y:bonus2_y gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false true false 0 false 5 in + if bonusres_2 <> 4 && (tile_distance gd cxi cyi !bonus2_x !bonus2_y <= min_dist_from_player gd cxi cyi) && !action <> 2 then begin if logg then Printf.fprintf stderr "Bonus Spotted\n" ; action := 1 ; raise (ReturnInt bonusres_2) ; end; - let result = bfs_for_crate gd dgs cxi cyi gd.dt false false true 1 false 80 in - if result <> 4 then begin + let result = bfs_for_crate gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false false true 1 false 80 in + if result <> 4 && !action <> 2 then begin + if logg then Printf.fprintf stderr "found (%d) \n" result ; action := 1 ; raise (ReturnInt result) ; end; @@ -892,26 +906,35 @@ let move_crate (gd : game_data) (dgs : danger_map) = if logg then Printf.fprintf stderr "bonusing...\n" ; 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 5 in + let bonusres = bfs_for_crate ~return_x:bonus_x ~return_y:bonus_y gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false true false 0 false 5 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" ; + if logg then Printf.fprintf stderr "bonus spotted (%d) \n" bonusres ; raise (ReturnInt bonusres) ; 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" ; + let rescr = bfs_for_crate gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) true false false 0 false 80 in + if logg then Printf.fprintf stderr "searching Done (%d) ...\n" rescr ; if rescr <> 4 then rescr else begin if logg then Printf.fprintf stderr "searching 2...\n" ; let success = ref false in - let rescr2 = bfs_for_crate ~return_ok:success gd dgs cxi cyi gd.dt false false false 0 false 80 in - if logg then Printf.fprintf stderr "searching 2 Done...\n" ; + let rescr2 = bfs_for_crate ~return_ok:success gd dgs cxi cyi (gd.dt -. !remaining_dash *. interval) false false false 0 false 80 in + if logg then Printf.fprintf stderr "searching 2 Done (%d) ...\n" rescr2 ; if !success then rescr2 else begin if logg then Printf.fprintf stderr "Needs dash lmao\n"; - 4 + 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 with @@ -1090,6 +1113,8 @@ 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 ;; +get_rem_dash ("again"^(string_of_int game_map.player_id)^".sav") ;; + (*Printf.fprintf stderr "\n" ;; print_dangers danger_data ;;*) @@ -1108,9 +1133,9 @@ else begin end ;; Printf.printf "%d %d" !direction !action ; -if logg then Printf.fprintf stderr "[player %d] %d %d (at time %f)\n" game_map.player_id !direction !action game_map.dt;; - +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);; +set_rem_dash ("again"^(string_of_int game_map.player_id)^".sav") ;; (*set_meta_info game_map.player_id ;;*) let __end = Unix.gettimeofday() ;; -if logg then Printf.fprintf stderr "Time : %f\n" (__end -. __start) ;; +if logg then Printf.fprintf stderr "Time : %f\n\n" (__end -. __start) ;; diff --git a/again.o b/again.o index fcef603..dc98ec9 100644 Binary files a/again.o and b/again.o differ diff --git a/again.sav b/again.sav new file mode 100644 index 0000000..573541a --- /dev/null +++ b/again.sav @@ -0,0 +1 @@ +0 diff --git a/again0.sav b/again0.sav new file mode 100644 index 0000000..573541a --- /dev/null +++ b/again0.sav @@ -0,0 +1 @@ +0 diff --git a/again1.sav b/again1.sav new file mode 100644 index 0000000..573541a --- /dev/null +++ b/again1.sav @@ -0,0 +1 @@ +0 diff --git a/again2.sav b/again2.sav new file mode 100644 index 0000000..573541a --- /dev/null +++ b/again2.sav @@ -0,0 +1 @@ +0 diff --git a/again3.sav b/again3.sav new file mode 100644 index 0000000..573541a --- /dev/null +++ b/again3.sav @@ -0,0 +1 @@ +0 diff --git a/entrees.txt b/entrees.txt index 08678d1..b7e5f3b 100644 --- a/entrees.txt +++ b/entrees.txt @@ -1,27 +1,29 @@ -230.35480000000163 -0 +102.4000000000002 +1 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 6 6 6 6 6 6 3 4 4 4 3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7 14 1 235.06710000000166 +4 +11 13 1 102.50000000000017 +3 9 4 105.11000000000014 +7 15 2 106.5 +3 7 4 106.73000000000015 3 -8 19 0 4 2 5 3 4 -7 12 1 4 0 1 0 3 -5 11 3 2 1 5 3 2 -0 +9 15 1 1 4 1 2 5 +9 15 2 0 1 2 3 0 +5 7 3 2 3 4 0 2 +3 +11 7 0 +9 7 1 +3 13 4 diff --git a/iachallenge2024_bomberman_tkinter.py b/iachallenge2024_bomberman_tkinter.py index be3cbf0..e72714b 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 :", indiceJoueur, "\n\n") + print("\n\nDEATH (at time =", evenement[0], "):", indiceJoueur, "\n\n") #assert(false) indiceJoueur = trouve_objet(i,j,joueurs) diff --git a/sortie.txt b/sortie.txt index 389086a..69035af 100644 --- a/sortie.txt +++ b/sortie.txt @@ -1 +1 @@ -2 0 \ No newline at end of file +3 0 \ No newline at end of file