diff --git a/again b/again index ec8f960..0ae4ef6 100755 Binary files a/again and b/again differ diff --git a/again.cmi b/again.cmi index 532f6de..d0e795c 100644 Binary files a/again.cmi and b/again.cmi differ diff --git a/again.cmo b/again.cmo index 6f80752..ccba6d7 100644 Binary files a/again.cmo and b/again.cmo differ diff --git a/again.ml b/again.ml index 907e722..6dc351a 100644 --- a/again.ml +++ b/again.ml @@ -3,6 +3,7 @@ TODO : - deal with double bombing (DONE) - well shit ==> dash - deeper analysis on pathfinfing (~DONE) +- correct fatal bug on player death *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -51,7 +52,7 @@ let default_bomb = { } and default_player = { - id = 0 ; + id = -1 ; xy = default_point ; nspeed = 0 ; nbomb_atonce = 0 ; @@ -138,6 +139,12 @@ let is_empty_lst = function (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) +let get_player_id (gd : game_data) (raw_id : int) = + try + Array.fold_left (fun i (p : player) -> if p.id = raw_id then raise (ReturnInt i); i+1) 0 gd.players + with + | ReturnInt k -> k ;; + let print_game_data (gd : game_data) = Printf.fprintf stderr "--------------------------------| Board data |--------------------------------\n" ; Printf.fprintf stderr "Time : %f\n" gd.dt ; @@ -288,10 +295,10 @@ let parse_input (str : string) = if debug_all then Printf.fprintf stderr "Players\n" ; res.nplayers <- int_of_string (input_line ptr) ; - res.players <- Array.make res.nplayers default_player ; + res.players <- Array.make 4 default_player ; for p = 0 to res.nplayers -1 do let dat = int_n_of_string (input_line ptr) 8 useless in - res.players.(p) <- {id = dat.(2) ; xy = {x = dat.(0) ; y = dat.(1) ;} ; nspeed = dat.(3) ; nbomb_atonce = dat.(4) ; bomb_radius = dat.(5) ; ndash = dat.(6) ; ntraps = dat.(7) ;} + res.players.(dat.(2)) <- {id = dat.(2) ; xy = {x = dat.(0) ; y = dat.(1) ;} ; nspeed = dat.(3) ; nbomb_atonce = dat.(4) ; bomb_radius = dat.(5) ; ndash = dat.(6) ; ntraps = dat.(7) ;} done; (* boosts *) diff --git a/entrees.txt b/entrees.txt index 4d9cdc4..eafbc8b 100644 --- a/entrees.txt +++ b/entrees.txt @@ -1,26 +1,24 @@ -107.70000000000023 +168.2180000000007 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 3 3 3 3 3 3 0 2 2 2 0 4 4 5 5 5 1 -1 3 1 3 1 3 1 0 1 2 1 0 1 2 1 4 1 5 1 5 1 -1 3 3 3 3 3 3 3 0 2 2 2 2 2 0 4 4 5 5 5 1 -1 0 1 3 1 6 1 2 1 2 1 2 1 2 1 4 1 5 1 5 1 -1 0 3 3 3 3 0 2 2 2 2 2 2 2 2 4 4 4 5 5 1 -1 0 1 3 1 6 1 2 1 2 1 2 1 2 1 4 1 5 1 5 1 -1 3 3 3 3 3 0 2 2 2 2 2 2 0 0 4 4 4 5 5 1 -1 3 1 3 1 0 1 2 1 2 1 2 1 5 1 4 1 5 1 5 1 -1 3 6 6 6 0 2 2 2 2 2 0 5 5 5 4 5 5 4 5 1 -1 3 1 6 1 2 1 0 1 2 1 2 1 5 1 5 1 5 1 4 1 -1 3 3 3 0 2 2 2 2 2 2 2 2 5 5 5 5 5 5 5 1 +1 3 3 3 3 3 3 3 0 0 5 5 5 5 5 5 5 5 5 5 1 +1 3 1 3 1 3 1 0 1 0 1 0 1 5 1 5 1 5 1 5 1 +1 3 3 3 3 3 3 6 3 5 0 5 5 6 5 5 5 5 5 5 1 +1 3 1 3 1 3 1 6 1 5 1 5 1 6 1 4 1 5 1 5 1 +1 3 3 3 6 3 5 6 5 5 5 5 5 6 5 4 5 5 5 4 1 +1 3 1 3 1 6 1 6 1 5 1 5 1 6 1 4 1 4 1 4 1 +1 3 3 3 3 3 3 6 3 5 6 6 6 6 6 6 6 6 4 4 1 +1 3 1 3 1 6 1 6 1 5 1 5 1 6 1 6 1 4 1 4 1 +1 3 6 3 6 6 4 6 4 4 4 4 4 6 6 6 4 4 4 4 1 +1 3 1 3 1 6 1 6 1 4 1 5 1 6 1 6 1 4 1 4 1 +1 6 6 6 6 6 6 6 6 6 6 6 6 5 5 6 6 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 -2 -11 14 2 110.22000000000013 -9 5 4 112.5 -3 -8 5 0 0 2 4 1 1 -8 15 1 2 2 2 2 2 -9 15 2 1 3 2 0 0 -2 -9 11 0 -7 14 4 +1 +3 9 4 169.63600000000093 +4 +1 8 0 2 3 3 2 3 +5 10 1 1 4 3 2 1 +5 10 2 3 3 3 3 4 +5 10 3 3 2 4 2 2 +0 diff --git a/iachallenge2024_bomberman_tkinter.py b/iachallenge2024_bomberman_tkinter.py index 14a8bfe..9319f02 100644 --- a/iachallenge2024_bomberman_tkinter.py +++ b/iachallenge2024_bomberman_tkinter.py @@ -443,7 +443,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo TAILLE_TUILE = 40 HAUTEUR_JOUEUR = TAILLE_TUILE -LARGEUR_INFOS = 1100 +LARGEUR_INFOS = 800 COULEURS_JOUEURS = ["red", "blue", "green", "yellow"] COULEURS_POWERUPS = ["cyan", "orangered", "red", "magenta", "purple"] @@ -481,11 +481,11 @@ def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs, for pu in powerups: print(pu[PU_LIGNE], pu[PU_COLONNE], pu[PU_NATURE], file=entrees) if os.name == "posix": - os.system("cat entrees.txt | "+programme+" > sortie.txt") - #subprocess.run("cat entrees.txt | "+programme+" > sortie.txt") + #os.system("cat entrees.txt | "+programme+" > sortie.txt") + subprocess.run("cat entrees.txt | "+programme+" > sortie.txt", shell=True) elif os.name =="nt": - os.system('type entrees.txt | python '+programme[2:]+ ' >sortie.txt') - #subprocess.run('type entrees.txt | python '+programme[2:]+ ' >sortie.txt') + #os.system('type entrees.txt | python '+programme[2:]+ ' >sortie.txt') + subprocess.run('type entrees.txt | python '+programme[2:]+ ' >sortie.txt', shell=True) with open("sortie.txt", "r") as sortie: direction, b = sortie.readline().split() action = int(b) diff --git a/sortie.txt b/sortie.txt index 4a3b60a..7cc0f37 100644 --- a/sortie.txt +++ b/sortie.txt @@ -1 +1 @@ -0 0 \ No newline at end of file +4 0 \ No newline at end of file