python improvments

This commit is contained in:
Alexandre 2024-12-04 15:43:39 +01:00
parent c4b42c2a89
commit 7ee82cce86
3 changed files with 27 additions and 47 deletions

BIN
audio/wood.mp3 Normal file

Binary file not shown.

View File

@ -1,27 +1,23 @@
10.0 180.16800000000111
3 2
13 21 13 21
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 3 0 0 2 2 2 2 2 2 2 0 2 0 2 2 2 2 0 5 1 1 4 4 4 4 4 4 4 0 0 0 6 6 6 6 6 6 6 6 5 1
1 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 5 1 1 3 1 3 1 4 1 4 1 3 1 5 1 6 1 5 1 5 1 5 1
1 0 0 2 0 2 2 0 2 2 2 2 0 2 2 2 2 2 2 0 1 1 3 0 3 0 4 6 6 6 3 6 5 6 6 6 6 6 6 5 5 1
1 0 1 2 1 2 1 2 1 0 1 2 1 2 1 2 1 2 1 2 1 1 3 1 3 1 4 1 4 1 3 1 6 1 6 1 4 1 4 1 5 1
1 2 2 2 0 2 2 2 0 0 2 2 2 2 2 0 2 2 2 2 1 1 3 3 3 3 4 3 3 3 3 3 3 3 3 3 6 6 6 6 6 1
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 0 1 2 1 2 1 1 3 1 3 1 3 1 4 1 3 1 6 1 6 1 4 1 4 1 4 1
1 2 2 2 2 0 2 2 2 2 0 2 0 2 2 2 0 2 2 2 1 1 6 6 6 6 6 6 4 6 3 6 6 6 6 6 6 6 6 4 4 1
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 0 1 2 1 2 1 1 3 1 3 1 3 1 6 1 3 1 6 1 6 1 4 1 4 1 4 1
1 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 1 1 6 6 3 3 3 3 3 3 3 3 6 3 3 3 4 4 4 4 4 1
1 6 1 0 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 4 1 1 3 1 6 1 6 1 6 1 3 1 6 1 6 1 4 1 4 1 4 1
1 6 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 4 1 1 6 6 6 6 3 3 6 3 3 3 6 3 6 4 4 4 4 4 4 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4 0
1 3 1 12.5 4
11 18 1 12.5 3 6 0 0 2 5 2 2
1 18 1 12.5 2 3 1 1 2 4 4 3
11 2 1 12.5 3 8 2 3 1 1 1 1
4 3 9 3 1 1 6 2 1
3 1 0 0 0 1 0 0
9 19 1 0 0 1 0 1
3 19 2 0 1 1 0 0
9 1 3 0 0 1 0 0
0 0

View File

@ -342,7 +342,11 @@ def casse(plateau, powerups, i,j):
if randrange(0,3)==0: if randrange(0,3)==0:
powerups.append([i,j, randrange(5)]) powerups.append([i,j, randrange(5)])
return return
def play_planks():
playsound('./audio/wood.mp3')
return
def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, joueurs, powerups, pieges): def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, joueurs, powerups, pieges):
if evenement[E_NATURE]==EVENEMENT_TOUR_JOUEUR: if evenement[E_NATURE]==EVENEMENT_TOUR_JOUEUR:
temps, nature, indiceJoueur = evenement temps, nature, indiceJoueur = evenement
@ -415,8 +419,7 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo
return return
elif plateau[i][j]==PLATEAU_BOIS: elif plateau[i][j]==PLATEAU_BOIS:
# Bois : destructible, on détruit # Bois : destructible, on détruit
'''CTS[CTPTR].start() (Thread(target=play_planks)).start()
CTPTR = (CTPTR+1)%12'''
casse(plateau, powerups, i,j) casse(plateau, powerups, i,j)
return return
else: else:
@ -465,23 +468,6 @@ Y_STEP_CLAIMS = 40
X_LARGEUR_EMPIRES = 60 X_LARGEUR_EMPIRES = 60
Y_LARGEUR_EMPIRES = 180 Y_LARGEUR_EMPIRES = 180
'''
CT1= Thread(target=play_planks)
CT2= Thread(target=play_planks)
CT3= Thread(target=play_planks)
CT4= Thread(target=play_planks)
CT5= Thread(target=play_planks)
CT6= Thread(target=play_planks)
CT7= Thread(target=play_planks)
CT8= Thread(target=play_planks)
CT9= Thread(target=play_planks)
CT10= Thread(target=play_planks)
CT11= Thread(target=play_planks)
CT12= Thread(target=play_planks)
CTS=[CT1, CT2, CT3, CT4, CT5, CT6, CT7, CT8, CT9, CT10, CT11, CT12]
CTPTR=0
'''
def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs, powerups, instant): def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs, powerups, instant):
with open("entrees.txt", "w") as entrees: with open("entrees.txt", "w") as entrees:
print(instant, file=entrees) print(instant, file=entrees)
@ -524,7 +510,7 @@ def simulation(strategies):
execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, joueurs, powerups, pieges) execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, joueurs, powerups, pieges)
affiche_plateau(canvas, plateau, plateauCouleur, bombes, joueurs, powerups) affiche_plateau(canvas, plateau, plateauCouleur, bombes, joueurs, powerups)
affiche_infos(canvasInfosJoueurs, joueurs, plateauCouleur) affiche_infos(canvasInfosJoueurs, joueurs, plateauCouleur)
affiche_empires(canvasInfosJoueurs, joueurs, plateauCouleur) # very laggy for some reason affiche_empires(canvasInfosJoueurs, joueurs, plateauCouleur) # very laggy for some reason # not anymore
temps = int((evenements[0][0]-evenement[0])/3*200) temps = int((evenements[0][0]-evenement[0])/3*200)
if temps != 0: if temps != 0:
fenetre.after(temps, pas_de_jeu) fenetre.after(temps, pas_de_jeu)
@ -563,9 +549,7 @@ def simulation(strategies):
fenetre.mainloop() fenetre.mainloop()
return return
def play_planks():
playsound('./audio/wood-effect-254997.mp3')
#simulation(["./again"]) #simulation(["./again"])
#simulation(["./again", "./again"]) #simulation(["./again", "./again"])
simulation(["./again", "./again", "./again", "./again"]) simulation(["./again", "./again", "./again", "./again"])