
L'annonce est déjà prête pour TI-Planet. Manque juste à finaliser celle pour Planète Casio.
scoreliste
qui s'allonge avec chaque nouveau meilleur score. Il suffit alors de prendre scoreliste[-1]
pour récupérer le dernier élément, donc le meilleur score.codeliste
. Par la suite, j'ai créé une variable score_max
qui stocke la valeur scoreliste[-1]
.scoreliste[-1]
, le code associé codeliste[-1]
ainsi que la liste des pokemon
et la liste des puissances associées attaque
.>=
et non pas un >
pour stocker un nouveau score s'il est meilleur que le dernier meilleur score obtenu, ou s'il est égal à ce dernier. C'est peut-être peu pertinent, mais ça permet de changer de temps en temps la liste des if score>=score_max:
atta.append(attaque[:])
poke.append(pokemon[:])
if score>score_max:
print(scoreliste[-1],iii)
print("#",score,codeliste[-1])
print("# poke",poke[-1])
print("# atta",atta[-1])
print("")
score_max=score
pokemon
et ma liste des puissances attaque
avec des 1, je crois.pokemon=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1] (ou pokemon=[1]*10)
attaque=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1] (ou attaque=[1]*10)
for kkk in range(10):
pk(pokemon[kkk],attaque[kkk])
for jjj in range(10):
pk(pokemon[jjj],0)
rang=randint(0,9)
attaque[rang]=randint(1,200)
rang=randint(0,9)
pokemon[rang]=randint(1,94)
if nb_chgt==10:
attaque=atta[-1] (ou pokemon=poke[-1] dans l'autre programme)
rang=randint(0,9)
attaque[rang]+=2*randint(0,1)-1
attaque[randint(0,9)]+=2*randint(0,1)-1
attaque[randint(0,9)]=attaque[randint(0,9)]+2*randint(0,1)-1
+=
parce que les deux nombres tirés aléatoirement avec randint(0,9)
sont très souvent différents, et ça ne m'intéresse pas.49.31730339247606
'O#0K_g^huS""3""f""""'
poke [51, 85, 72, 62, 71, 63, 43, 16, 3, 47]
atta [4, 4, 61, 2, 2, 235, 3, 2, 3, 3]
49.3185945083636
'O#0K_g^huS""3""g""""'
poke [51, 85, 72, 62, 71, 63, 43, 16, 3, 47]
atta [2, 3, 61, 2, 2, 239, 2, 4, 2, 2]
rang=3*randint(0,1)+2
randint(0,1)
? Euh...bah...euh... c'est pas faux. Bien vu ! pfff xD49.31975298152274
'O#0K_g^huS""3""h""""'
poke [51, 85, 72, 62, 71, 63, 43, 16, 3, 47]
atta [2, 2, 58, 2, 2, 234, 2, 2, 2, 2]
49.32078546995182
'O#0K_g^huS""3""i""""'
poke [51, 85, 72, 62, 71, 63, 43, 16, 3, 47]
atta [1, 1, 35, 1, 1, 143, 1, 1, 1, 1]
setst()
pour retrouver le score et que c'est ce score qui est validé et ajouté dans le tableau des participations.setst("code_obtenu")
avant de le comparer à mon meilleur score.score=setst(codeliste[-1])
setst()
, avec le même coefficient multiplicateur, pour que leur somme ne dépasse plus 100, puis arrondies à l'unité. Si les puissances réduites sont trop petites, alors l'arrondi à l'unité donne 0, ce qui explique la disparition de certains setst('O#0K_g^huS""\x3D""\x99""""')
49.318885384185236
setst('O#0K_g^huS""\x42""\xB2""""')
49.31951877543954
setst()
et qui n'utilise pas de caractères bizarres commençant par un \.#score=[]
codeliste=[0]
scoreliste=[0]
#cas
from math import *
def mmod(a,b):
return a%b
#0 Nspire MicroPython
#1 NumWorks Python
#2 G90/35+E2 Python
#3 G75/85/95 CasioPython
#4 83PCE Python/PyAdapt
#5 HP Prime CAS
#6 G90/35+E2 KhiCAS
def getplatform():
k=-1
try:
if chr(256)==chr(0):
k=[6,5][("HP" in version())>0]
except:
pass
if k>=0:
return k
try:
import sys
try:
if sys.platform=="nspire":
k=0
elif sys.platform.startswith("TI-Python"):
k=4
except:
k=3
except:
try:
import kandinsky
k=1
except:
k=2
return k
def getlinechars(o=False):
c,k=2**31-1,getplatform()
if k>=0:
c=[53,o and 99 or 29,o and 509 or 21,31,32,c,c][k]
return c
lnm=["Bulbizarre","Herbizarre","Florizarre","Salameche","Reptincel","Dracaufeu","Carapuce","Carabaffe","Tortank","Chenipan","Chrysacier","Papilusion","Aspicot","Coconfort","Dardargnan","Roucool","Roucoups","Roucarnage","Rattata","Rattatac","Piafabec"]
lnm.extend(["Rapasdepic","Abo","Arbok","Pikachu","Raichu","Sabelette","Sablaireau","Nidoran F","Nidorina","Nidoqueen","Nidoran M","Nidorino","Nidoking","Melofee","Melodelfe","Goupix","Feunard","Rondoudou","Grodoudou","Nosferapti","Nosferalto"])
lnm.extend(["Mystherbe","Ortide","Rafflesia","Paras","Parasect","Mimitoss","Aeromite","Taupiqueur","Triopikeur","Miaouss","Persian","Psykokwak","Akwakwak","Ferosinge","Colossinge","Caninos","Arcanin","Ptitard","Tetarte","Tartard","Abra","Kadabra"])
lnm.extend(["Alakazam","Machoc","Machopeur","Mackogneur","Chetiflor","Boustiflor","Empiflor","Tentacool","Tentacruel","Racaillou","Gravalanch","Grolem","Ponyta","Galopa","Ramoloss","Flagadoss","Magneti","Magneton","Canarticho","Doduo","Dodrio","Otaria"])
lnm.extend(["Lamantine","Tadmorv","Grotadmorv","Kokiyas","Crustabri","Fantominus","Spectrum","Ectoplasma"])
na,pkl=21,[]
mrandmax,mrand,mfmax,nn,mp=2**31-1,0,93,getlinechars(True)-na,na//2
def mround(f):
d=mmod(abs(f),1)
return (mfloor(abs(f))+(d>=.5))*(1-2*(f<0))
def mfloor(f):
return round(f)-(round(f)>f)
def mceil(f):
return round(f)+(round(f)<f)
def mseed(s):
global mrand
mrand=mmod(s,mrandmax)
def mrandom():
mseed(mrand*16807)
return float(mrand/mrandmax)
def muniform(mini,maxi):
return mrandom()*(maxi-mini)+mini
def mrandint(mini,maxi):
return mround(muniform(mceil(mini),mfloor(maxi)))
def f2mf(f):
return mround(float(f*mfmax))
def mf2f(n):
return float(n/mfmax)
def mbit(a,b):
return mmod((a//(2**b)),2)
def getattack(p,pts):
global pkt
mseed(42)
for k in range(p+1):
mrandom()
a,pka=mrandint(1,mrandmax),""
for j in range(na):
if mbit(a,j)!=0:
pka+="X"
pkt[j]+=pts
else:
pka+=" -"[getplatform()>=5]
return pka
def i2c(k):
return chr(k+33)
def c2i(c):
return ord(c)-33
def clean():
global pkl
t,s=0,0
for l in pkl:
t+=l[1]
for l in pkl:
l[2]=f2mf(l[1]/(t or 1))
s+=l[2]
if(l[2]<=0):
pkl.remove(l)
return clean()
return s
def pk(n,p=1,d=2):
global pkt, pkl
n-=1
if n>=0 and n<len(lnm):
new=True
for k in range(len(pkl)):
if pkl[k][0]==n:
new,pkl[k][1]=False,max(p,0)
if new and len(pkl)<mp:
pkl.append([n,max(p,0),0])
ptt,pkt,t,st=clean(),[0 for k in range(na)],0,""
for l in pkl:
s=getattack(l[0],l[2]/ptt)
if d:
sn=" "+lnm[l[0]]
if len(sn)>nn:
sn=sn[:nn]
#print(s+sn)
st=i2c(l[0])+st+i2c(l[2])
for k in pkt:
if(k):
t+=log(e+k*len(pkl))
if(d):
if(d>=2):
#print("Bon score ? Si oui\nenvoie code suivant\na info@tiplanet.org :")
scoreliste.append(float(t))
codeliste.append(""+st)
#score.append(setst(st))
#print(""+st)
return float(t)
def setst(st):
s,pkl[:],n=0,[],len(st)//2
for k in range(n):
s=pk(c2i(st[n-1-k])+1,c2i(st[n+k+len(st)%2]),k+1>=n)
return s
print("pk(n,p) pour rajouter\nle Pokemon n a ta main\navec p points d'attaque.")
#end
score_max=0
poke=[]
atta=[]
pokemon=[57, 72, 5, 43, 3, 69, 89, 62, 63, 16]
#attaque=[1, 1, 1, 1, 1, 1, 1, 1, 59, 236]
#pokemon=[51, 85, 72, 62, 71, 63, 43, 16, 3, 47]
#dd=9
attaque=[1, 1, 17, 1, 1, 68, 1, 1, 1, 1]
#pokemon=[1]*10
#attaque=[dd]*10
nb_chgt=0
from random import randint
for iii in range(50):
#pokemon=[randint(1,94) for y in range(10)]
#attaque=[randint(1,200) for y in range(10)]
if iii>0: # et si iii vaut 0, on évite cette boucle et on ajoute un premier score non nul dans scoreliste
#pokemon[randint(0,9)]+=2*randint(0,1)-1#randint(1,94)
#rang=randint(0,9)
rang=3*randint(0,1)+2
#pokemon[randint(0,9)]=randint(1,94)
#attaque[rang]-=1
#attaque[rang]=max(attaque[rang]+2*randint(0,1)-1,1)
#rang=randint(0,9)
#rang=8-rang #3*randint(0,1)+2
#pokemon[rang]=randint(1,94)
#attaque[rang]=max(1,93-(sum(attaque[:])-attaque[rang]))
#attaque[rang]=randint(1,50)
attaque[rang]+=2*randint(0,1)-1
#attaque[3*randint(0,1)+2]+=1*(2*randint(0,1)-1)
for kkk in range(10):
pk(pokemon[kkk],attaque[kkk])
score=setst(codeliste[-1]) # ici le vrai score
if score>=score_max:
atta.append(attaque[:])
poke.append(pokemon[:])
#code=codeliste[-1]
if score>score_max:
print(scoreliste[-1],iii) # ici le score avant évaluation dans setst()
print("#",score,codeliste[-1])
#print("#",setst(code))
print("# poke",poke[-1])
print("# atta",atta[-1])
print("")
score_max=score
for jjj in range(10):
pk(pokemon[jjj],0)
nb_chgt+=1
if nb_chgt==20:
#pokemon=poke[-1]
attaque=atta[-1]
Users browsing this forum: No registered users and 6 guests