[python] added display of empires
This commit is contained in:
parent
60788b784d
commit
b5caa5e351
44
entrees.txt
44
entrees.txt
|
@ -1,26 +1,26 @@
|
|||
164.23000000000036
|
||||
3
|
||||
107.70000000000023
|
||||
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 0 2 2 2 0 4 4 4 4 4 4 5 5 1
|
||||
1 0 1 3 1 3 1 3 1 2 1 2 1 4 1 5 1 5 1 5 1
|
||||
1 3 3 3 3 3 3 3 3 0 0 4 4 4 4 4 4 4 5 4 1
|
||||
1 0 1 3 1 3 1 3 1 0 1 6 1 4 1 5 1 4 1 4 1
|
||||
1 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 1
|
||||
1 3 1 3 1 3 1 3 1 2 1 6 1 4 1 5 1 4 1 4 1
|
||||
1 3 3 3 3 3 3 3 0 0 4 4 4 4 4 4 5 5 4 4 1
|
||||
1 3 1 3 1 3 1 3 1 0 1 6 1 4 1 5 1 4 1 4 1
|
||||
1 3 6 3 6 3 6 3 6 6 6 6 6 5 5 5 5 4 4 4 1
|
||||
1 3 1 6 1 3 1 0 1 6 1 0 1 5 1 4 1 4 1 4 1
|
||||
1 6 3 3 3 3 3 6 6 6 0 0 5 5 5 5 4 4 4 4 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
4
|
||||
7 8 3 165.48950000000036
|
||||
3 11 2 166.5
|
||||
1 13 3 167.44000000000028
|
||||
9 9 3 168.7700000000004
|
||||
2
|
||||
11 14 2 110.22000000000013
|
||||
9 5 4 112.5
|
||||
3
|
||||
11 9 0 4 0 3 2 2
|
||||
3 15 2 0 1 2 1 4
|
||||
4 9 3 2 2 2 2 1
|
||||
0
|
||||
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
|
||||
|
|
|
@ -59,6 +59,7 @@ PU_NATURE = 2
|
|||
|
||||
from random import randrange
|
||||
from copy import deepcopy
|
||||
import subprocess
|
||||
from tkinter import *
|
||||
import os
|
||||
|
||||
|
@ -215,7 +216,24 @@ def compte_couleur(grille, nbJoueurs):
|
|||
if couleur >= 0:
|
||||
compteurs[couleur]+=1
|
||||
return compteurs
|
||||
|
||||
|
||||
def ln_b(n, b):
|
||||
if(n < b):
|
||||
return 0
|
||||
else:
|
||||
return 1 + ln_b(n/b, b)
|
||||
|
||||
def affiche_empires(canvas, joueurs, plateauCouleur):
|
||||
scores = compte_couleur(plateauCouleur, len(joueurs))
|
||||
canvas.create_polygon(
|
||||
0, 0,
|
||||
0 + X_LARGEUR_EMPIRES, 0,
|
||||
0 + X_LARGEUR_EMPIRES, 0 + Y_LARGEUR_EMPIRES,
|
||||
0, 0 + Y_LARGEUR_EMPIRES,
|
||||
fill="black")
|
||||
for k in range(len(scores)):
|
||||
canvas.create_text(X_LARGEUR_EMPIRES/2, Y0_EMPIRES + k*Y_STEP_CLAIMS, text=str(scores[k]), fill=COULEURS_JOUEURS[k])
|
||||
|
||||
def affiche_infos(canvas, joueurs, plateauCouleur):
|
||||
canvas.delete(ALL)
|
||||
scores = list(reversed((sorted(zip(compte_couleur(plateauCouleur, len(joueurs)), range(len(joueurs)))))))
|
||||
|
@ -292,8 +310,8 @@ def affiche_infos(canvas, joueurs, plateauCouleur):
|
|||
else:
|
||||
couleur = "gray"
|
||||
trace_bomberman(canvas, 0, HAUTEUR_JOUEUR*k,couleur)
|
||||
|
||||
|
||||
|
||||
|
||||
def ajoute_evenement(evenements, evenement):
|
||||
for i in range(0,len(evenements)):
|
||||
if evenement[0]<evenements[i][0]:
|
||||
|
@ -425,14 +443,21 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo
|
|||
|
||||
TAILLE_TUILE = 40
|
||||
HAUTEUR_JOUEUR = TAILLE_TUILE
|
||||
LARGEUR_INFOS = 800
|
||||
LARGEUR_INFOS = 1100
|
||||
COULEURS_JOUEURS = ["red", "blue", "green", "yellow"]
|
||||
COULEURS_POWERUPS = ["cyan", "orangered", "red", "magenta", "purple"]
|
||||
|
||||
OFFSET_CRATE = TAILLE_TUILE/25
|
||||
TAILLE_OVERLAY = 15
|
||||
NOMBRE_SPARKS = 10
|
||||
SIZE_SPARKS = 12
|
||||
|
||||
Y0_EMPIRES = 20
|
||||
Y_STEP_CLAIMS = 40
|
||||
|
||||
X_LARGEUR_EMPIRES = 400
|
||||
Y_LARGEUR_EMPIRES = 180
|
||||
|
||||
def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs, powerups, instant):
|
||||
with open("entrees.txt", "w") as entrees:
|
||||
print(instant, file=entrees)
|
||||
|
@ -457,8 +482,10 @@ def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs,
|
|||
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")
|
||||
elif os.name =="nt":
|
||||
os.system('type entrees.txt | python '+programme[2:]+ ' >sortie.txt')
|
||||
#subprocess.run('type entrees.txt | python '+programme[2:]+ ' >sortie.txt')
|
||||
with open("sortie.txt", "r") as sortie:
|
||||
direction, b = sortie.readline().split()
|
||||
action = int(b)
|
||||
|
@ -472,6 +499,7 @@ def simulation(strategies):
|
|||
return
|
||||
execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, joueurs, powerups, pieges)
|
||||
affiche_plateau(canvas, plateau, plateauCouleur, bombes, joueurs, powerups)
|
||||
affiche_empires(canvasInfosLand, joueurs, plateauCouleur) # very laggy for some reason
|
||||
affiche_infos(canvasInfosJoueurs, joueurs, plateauCouleur)
|
||||
temps = int((evenements[0][0]-evenement[0])/3*200)
|
||||
if temps != 0:
|
||||
|
@ -507,9 +535,13 @@ def simulation(strategies):
|
|||
canvasInfosJoueurs = Canvas(width = LARGEUR_INFOS, height=len(joueurs)*HAUTEUR_JOUEUR)
|
||||
canvasInfosJoueurs.pack()
|
||||
|
||||
canvasInfosLand = Canvas(width = X_LARGEUR_EMPIRES, height=Y_LARGEUR_EMPIRES)
|
||||
canvasInfosLand.pack()
|
||||
|
||||
pas_de_jeu()
|
||||
|
||||
fenetre.mainloop()
|
||||
return
|
||||
|
||||
#simulation(["./again", "./again"])
|
||||
simulation(["./again", "./again", "./again", "./again"])
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0 0
|
Loading…
Reference in New Issue