diff --git a/again b/again index 0dceb20..4f1fb29 100755 Binary files a/again and b/again differ diff --git a/again.cmi b/again.cmi index 09a98ab..a54b75f 100644 Binary files a/again.cmi and b/again.cmi differ diff --git a/again.cmx b/again.cmx index e853c0e..79d7981 100644 Binary files a/again.cmx and b/again.cmx differ diff --git a/again.ml b/again.ml index 81a5941..67d9780 100644 --- a/again.ml +++ b/again.ml @@ -145,6 +145,10 @@ let is_empty_lst = function | [] -> true | _ -> false ;; +let abs = function + | k when k < 0 -> -k + | k -> k ;; + (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -973,12 +977,7 @@ let path_seek (gd : game_data) (dgs : danger_map) (stime : float) (end_x : int) let x0 = gd.players.(pid).xy.x and y0 = gd.players.(pid).xy.y in - Queue.add (x0, y0, stime +. interval, 4, 1) q ; - - Queue.add (x0+1, y0, stime +. interval, 2, 1) q ; - Queue.add (x0-1, y0, stime +. interval, 0, 1) q ; - Queue.add (x0, y0+1, stime +. interval, 1, 1) q ; - Queue.add (x0, y0-1, stime +. interval, 3, 1) q ; + Queue.add (x0, y0, stime, 4, 0) q ; try while not (Queue.is_empty q) do @@ -998,10 +997,20 @@ let path_seek (gd : game_data) (dgs : danger_map) (stime : float) (end_x : int) then begin raise (ReturnInt direction) end; - 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 + if polar <> 0 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 + else begin + Queue.add (x0, y0, stime +. interval, 4, 1) q ; + + Queue.add (x0+1, y0, stime +. interval, 2, 1) q ; + Queue.add (x0-1, y0, stime +. interval, 0, 1) q ; + Queue.add (x0, y0+1, stime +. interval, 1, 1) q ; + Queue.add (x0, y0-1, stime +. interval, 3, 1) q ; + end end end end @@ -1023,22 +1032,27 @@ let seek_player (gd : game_data) (dgs : danger_map) = let player_range = 3 * gd.players.(pid).ndash in try - if gd.players.(pid).ntraps = 0 then begin - if logg then Printf.fprintf stderr "no trap\n"; + if gd.players.(pid).ntraps = 0 || (gd.players.(pid).bomb_to_place = 0 && is_empty_lst dgs.explosionTimes.(cxi).(cyi)) then begin + if logg then Printf.fprintf stderr "no trap/no available bomb\n"; raise (ReturnBool false); end; if logg then Printf.fprintf stderr "has trap(s)\n"; for pl = 0 to 3 do - if gd.players.(pl).id <> -1 then begin (* not dead *) + if gd.players.(pl).id <> -1 && gd.player_id <> pl then begin (* not dead *) let within_range = ref false in - let direct = path_seek gd dgs (gd.dt -. interval *. !remaining_dash) gd.players.(pl).xy.x gd.players.(pl).xy.y player_range within_range in + let direct = path_seek gd dgs (gd.dt -. interval *. !remaining_dash) gd.players.(pl).xy.x gd.players.(pl).xy.y (player_range + int_of_float !remaining_dash) within_range in if !within_range then begin - if logg then Printf.fprintf stderr "\n\nlesgo\n\n\n"; + if logg then Printf.fprintf stderr "\n\nlesgo (at %d, %d)\n\n\n" cxi cyi; if gd.players.(pl).xy.x = cxi && gd.players.(pl).xy.y = cyi then begin + if logg then Printf.fprintf stderr "no u\n" ; act := 3 end + else if abs (gd.players.(pl).xy.x - cxi) + abs (gd.players.(pl).xy.y - cyi) <= gd.players.(pid).bomb_radius then begin + if logg then Printf.fprintf stderr "boom\n" ; + act := 1 + end else begin - if !remaining_dash = 0. then begin + if !remaining_dash = 0. && gd.players.(pid).ndash > 0 then begin remaining_dash := 3. ; act := 2 ; end @@ -1278,7 +1292,7 @@ print_dangers danger_data ;;*) print_dangers danger_data ;;*) let direction = ref 4 ;; -if true || not (seek_player game_map danger_data) then begin +if not (seek_player game_map danger_data) then begin if exists_crate game_map danger_data then begin if logg then Printf.fprintf stderr "Crates\n" ; direction := move_crate game_map danger_data diff --git a/again.o b/again.o index 2b7a498..934bf7b 100644 Binary files a/again.o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6 1 4 1 4 1 0 1 4 1 0 1 +1 0 6 6 6 6 6 6 6 6 0 0 6 6 6 4 4 4 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -4 -3 14 4 251.5 -9 12 3 252.5 -8 13 3 254.5 -11 10 6 255.00000000000082 3 -11 9 0 1 2 6 1 4 -6 13 1 0 0 3 4 2 -6 13 3 0 1 4 2 4 -0 +5 9 2 59.5 +9 9 2 63.5 +7 7 1 63.5 +4 +7 6 0 0 1 1 0 0 +11 9 1 0 1 2 1 0 +7 11 2 0 0 2 1 0 +3 11 3 1 1 1 1 0 +1 +5 10 2 diff --git a/iachallenge2024_bomberman_tkinter.py b/iachallenge2024_bomberman_tkinter.py index 23a3c9f..29093ae 100644 --- a/iachallenge2024_bomberman_tkinter.py +++ b/iachallenge2024_bomberman_tkinter.py @@ -395,7 +395,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo piege = pieges[indicePiege] if piege[P_JOUEUR] != indiceJoueur: penalite = 3 - piege.pop(indicePiege) + pieges.pop(indicePiege) indicePowerup = trouve_objet(i,j,powerups) if indicePowerup != None: @@ -466,7 +466,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo ip, jp = prochain(i,j,direction) ajoute_evenement(evenements, [evenement[0]+TEMPS_PROPAGATION, EVENEMENT_PROPAGATION, ip, jp, direction, longueurFlammes-1, indJoueur]) -NB_TROUS = 0 +NB_TROUS = 120 BONUS_RANDMAX = 3 # >0 @@ -488,7 +488,7 @@ Y_STEP_CLAIMS = 40 X_LARGEUR_EMPIRES = 60 Y_LARGEUR_EMPIRES = 180 -TIME_FACTOR = 100 +TIME_FACTOR = 7 def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs, powerups, instant): with open("entrees.txt", "w") as entrees: 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 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