[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
|
107.70000000000023
|
||||||
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 3 3 3 3 3 0 2 2 2 0 4 4 4 4 4 4 5 5 1
|
1 3 3 3 3 3 3 3 3 3 0 2 2 2 0 4 4 5 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 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 3 0 0 4 4 4 4 4 4 4 5 4 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 3 1 3 1 0 1 6 1 4 1 5 1 4 1 4 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 3 3 3 3 4 4 4 4 4 4 4 4 4 4 1
|
1 0 3 3 3 3 0 2 2 2 2 2 2 2 2 4 4 4 5 5 1
|
||||||
1 3 1 3 1 3 1 3 1 2 1 6 1 4 1 5 1 4 1 4 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 3 3 0 0 4 4 4 4 4 4 5 5 4 4 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 3 1 3 1 0 1 6 1 4 1 5 1 4 1 4 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 3 6 3 6 3 6 6 6 6 6 5 5 5 5 4 4 4 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 3 1 0 1 6 1 0 1 5 1 4 1 4 1 4 1
|
1 3 1 6 1 2 1 0 1 2 1 2 1 5 1 5 1 5 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 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
|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||||
4
|
2
|
||||||
7 8 3 165.48950000000036
|
11 14 2 110.22000000000013
|
||||||
3 11 2 166.5
|
9 5 4 112.5
|
||||||
1 13 3 167.44000000000028
|
|
||||||
9 9 3 168.7700000000004
|
|
||||||
3
|
3
|
||||||
11 9 0 4 0 3 2 2
|
8 5 0 0 2 4 1 1
|
||||||
3 15 2 0 1 2 1 4
|
8 15 1 2 2 2 2 2
|
||||||
4 9 3 2 2 2 2 1
|
9 15 2 1 3 2 0 0
|
||||||
0
|
2
|
||||||
|
9 11 0
|
||||||
|
7 14 4
|
||||||
|
|
|
@ -59,6 +59,7 @@ PU_NATURE = 2
|
||||||
|
|
||||||
from random import randrange
|
from random import randrange
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
import subprocess
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -216,6 +217,23 @@ def compte_couleur(grille, nbJoueurs):
|
||||||
compteurs[couleur]+=1
|
compteurs[couleur]+=1
|
||||||
return compteurs
|
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):
|
def affiche_infos(canvas, joueurs, plateauCouleur):
|
||||||
canvas.delete(ALL)
|
canvas.delete(ALL)
|
||||||
scores = list(reversed((sorted(zip(compte_couleur(plateauCouleur, len(joueurs)), range(len(joueurs)))))))
|
scores = list(reversed((sorted(zip(compte_couleur(plateauCouleur, len(joueurs)), range(len(joueurs)))))))
|
||||||
|
@ -425,14 +443,21 @@ def execute_evenement(evenements, evenement, plateau, plateauCouleur, bombes, jo
|
||||||
|
|
||||||
TAILLE_TUILE = 40
|
TAILLE_TUILE = 40
|
||||||
HAUTEUR_JOUEUR = TAILLE_TUILE
|
HAUTEUR_JOUEUR = TAILLE_TUILE
|
||||||
LARGEUR_INFOS = 800
|
LARGEUR_INFOS = 1100
|
||||||
COULEURS_JOUEURS = ["red", "blue", "green", "yellow"]
|
COULEURS_JOUEURS = ["red", "blue", "green", "yellow"]
|
||||||
COULEURS_POWERUPS = ["cyan", "orangered", "red", "magenta", "purple"]
|
COULEURS_POWERUPS = ["cyan", "orangered", "red", "magenta", "purple"]
|
||||||
|
|
||||||
OFFSET_CRATE = TAILLE_TUILE/25
|
OFFSET_CRATE = TAILLE_TUILE/25
|
||||||
TAILLE_OVERLAY = 15
|
TAILLE_OVERLAY = 15
|
||||||
NOMBRE_SPARKS = 10
|
NOMBRE_SPARKS = 10
|
||||||
SIZE_SPARKS = 12
|
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):
|
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)
|
||||||
|
@ -457,8 +482,10 @@ def decision(programme, indiceJoueur, plateau, plateauCouleur, bombes, joueurs,
|
||||||
print(pu[PU_LIGNE], pu[PU_COLONNE], pu[PU_NATURE], file=entrees)
|
print(pu[PU_LIGNE], pu[PU_COLONNE], pu[PU_NATURE], file=entrees)
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
os.system("cat entrees.txt | "+programme+" > sortie.txt")
|
os.system("cat entrees.txt | "+programme+" > sortie.txt")
|
||||||
|
#subprocess.run("cat entrees.txt | "+programme+" > sortie.txt")
|
||||||
elif os.name =="nt":
|
elif os.name =="nt":
|
||||||
os.system('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')
|
||||||
with open("sortie.txt", "r") as sortie:
|
with open("sortie.txt", "r") as sortie:
|
||||||
direction, b = sortie.readline().split()
|
direction, b = sortie.readline().split()
|
||||||
action = int(b)
|
action = int(b)
|
||||||
|
@ -472,6 +499,7 @@ def simulation(strategies):
|
||||||
return
|
return
|
||||||
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_empires(canvasInfosLand, joueurs, plateauCouleur) # very laggy for some reason
|
||||||
affiche_infos(canvasInfosJoueurs, joueurs, plateauCouleur)
|
affiche_infos(canvasInfosJoueurs, joueurs, plateauCouleur)
|
||||||
temps = int((evenements[0][0]-evenement[0])/3*200)
|
temps = int((evenements[0][0]-evenement[0])/3*200)
|
||||||
if temps != 0:
|
if temps != 0:
|
||||||
|
@ -507,9 +535,13 @@ def simulation(strategies):
|
||||||
canvasInfosJoueurs = Canvas(width = LARGEUR_INFOS, height=len(joueurs)*HAUTEUR_JOUEUR)
|
canvasInfosJoueurs = Canvas(width = LARGEUR_INFOS, height=len(joueurs)*HAUTEUR_JOUEUR)
|
||||||
canvasInfosJoueurs.pack()
|
canvasInfosJoueurs.pack()
|
||||||
|
|
||||||
|
canvasInfosLand = Canvas(width = X_LARGEUR_EMPIRES, height=Y_LARGEUR_EMPIRES)
|
||||||
|
canvasInfosLand.pack()
|
||||||
|
|
||||||
pas_de_jeu()
|
pas_de_jeu()
|
||||||
|
|
||||||
fenetre.mainloop()
|
fenetre.mainloop()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#simulation(["./again", "./again"])
|
||||||
simulation(["./again", "./again", "./again", "./again"])
|
simulation(["./again", "./again", "./again", "./again"])
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0 0
|
Loading…
Reference in New Issue