fixed fatal bug with out_of_bounds when player died

This commit is contained in:
Alexandre 2024-11-18 17:19:49 +01:00
parent b5caa5e351
commit 832384634e
7 changed files with 36 additions and 31 deletions

BIN
again

Binary file not shown.

BIN
again.cmi

Binary file not shown.

BIN
again.cmo

Binary file not shown.

View File

@ -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) 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 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

View File

@ -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)

View File

@ -1 +1 @@
0 0
4 0