![Sourire :-)](./images/smilies/icon_e_smile.gif)
Tu peux donner ton code ?
Merci,
Zocipal a écrit:Qu'est-ce que du recuit simulé ?
def cartographie():
priorite=9
global pkcarto
pkcarto=[]
lgn=["ID","Points","nb de X","valeurs"]
#pkcarto.append(lgn)
for i in range(1,95):
pk(i,priorite)
# pkcarto.append(pkt)
t=""
for j in range(len(pkt)):
t+=str(int(pkt[j]))
if j!=len(pkt)-1:
t+=","
print("signature.append(["+str(t)+"]) #"+str(i))
pk(i,0)
return
#cas
import time
signature=[]
signature.append([1,1,1,1,0,0,0,1,1,1,0,1,0,1,0,1,1,0,1,0,0]) #1
signature.append([1,0,0,1,1,1,0,1,1,1,0,1,1,0,1,0,0,1,0,0,0]) #2
signature.append([0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,0,1]) #3
signature.append([1,1,0,1,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,1,0]) #4
signature.append([0,1,0,1,1,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1]) #5
signature.append([1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,1,0]) #6
signature.append([0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,1,1,1,0,0,1]) #7
signature.append([0,1,0,1,1,0,0,0,1,0,0,0,0,0,1,1,1,0,1,0,0]) #8
signature.append([0,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,0,1,0]) #9
signature.append([1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,1,0,1]) #10
signature.append([1,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0]) #11
signature.append([0,1,0,1,1,0,0,0,1,1,0,1,0,0,0,0,1,0,1,0,0]) #12
signature.append([0,1,1,0,1,0,0,0,1,1,0,0,1,0,0,0,0,0,1,1,1]) #13
signature.append([1,0,0,0,0,1,1,0,1,0,1,0,0,1,1,1,0,0,0,1,0]) #14
signature.append([1,0,1,1,1,1,0,1,1,0,0,0,1,0,0,0,1,1,0,1,0]) #15
signature.append([1,1,0,0,0,1,1,1,1,0,1,1,1,0,1,0,1,0,0,1,1]) #16
signature.append([1,1,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,0,0,0]) #17
signature.append([1,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,1,1,1,1]) #18
signature.append([0,1,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1]) #19
signature.append([1,1,1,0,0,0,1,1,1,1,0,0,1,0,0,1,1,1,1,0,0]) #20
signature.append([0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,0,1,1,1,0,1]) #21
signature.append([0,1,0,1,1,1,1,0,1,1,0,0,0,1,0,1,0,1,1,0,1]) #22
signature.append([0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,1,1,0,0]) #23
signature.append([1,1,0,0,1,0,0,1,0,1,0,0,0,0,1,0,0,1,1,1,1]) #24
signature.append([1,0,0,1,0,0,1,0,0,0,1,0,0,1,1,1,0,0,1,0,0]) #25
signature.append([1,0,0,0,1,0,0,1,1,1,0,1,1,1,0,0,1,1,1,0,0]) #26
signature.append([0,0,0,1,1,1,0,0,1,0,1,0,0,1,1,1,1,1,1,0,1]) #27
signature.append([0,1,0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,0,0,1,0]) #28
signature.append([0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,1,1,0,0,1,1]) #29
signature.append([1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0]) #30
signature.append([1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1]) #31
signature.append([0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,1,0,1,0,0,1]) #32
signature.append([1,1,1,1,1,0,1,0,0,1,0,0,1,0,1,0,1,1,0,1,0]) #33
signature.append([0,1,0,0,1,1,0,0,0,0,1,1,1,0,0,0,1,0,1,1,0]) #34
signature.append([1,1,1,0,1,1,0,1,0,1,0,0,1,0,1,0,0,1,1,0,1]) #35
signature.append([0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,1]) #36
signature.append([1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,1,1,0,1]) #37
signature.append([1,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1]) #38
signature.append([0,1,0,0,0,1,0,1,1,0,0,1,0,0,0,1,1,1,1,1,0]) #39
signature.append([1,0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1]) #40
signature.append([0,1,0,1,0,0,0,0,0,1,0,1,1,1,0,1,0,0,0,0,1]) #41
signature.append([1,0,0,1,0,1,1,0,0,1,1,0,1,1,0,1,1,0,1,0,0]) #42
signature.append([1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,0,0,1,0,1,0]) #43
signature.append([0,1,1,1,1,1,1,1,0,0,0,1,1,0,1,0,0,0,0,0,1]) #44
signature.append([0,1,1,1,0,1,1,1,1,0,0,0,0,1,1,0,0,1,0,0,0]) #45
signature.append([0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0]) #46
signature.append([0,0,1,0,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,0]) #47
signature.append([0,0,0,0,0,1,1,0,0,1,0,1,1,1,0,1,0,1,1,0,1]) #48
signature.append([1,0,1,0,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,0,0]) #49
signature.append([1,1,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,1,1,0]) #50
signature.append([1,1,1,1,1,1,0,0,1,0,1,0,1,1,0,0,1,0,0,1,0]) #51
signature.append([1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,0,1,1,0,0]) #52
signature.append([1,1,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0]) #53
signature.append([0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0]) #54
signature.append([0,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0]) #55
signature.append([1,0,1,1,0,1,0,1,1,1,1,0,1,1,1,0,0,0,1,0,0]) #56
signature.append([1,0,1,1,0,1,0,1,1,0,0,1,1,0,1,1,0,0,1,1,0]) #57
signature.append([1,1,0,1,0,1,1,1,0,1,0,1,1,0,0,0,1,1,1,0,0]) #58
signature.append([0,0,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,1]) #59
signature.append([1,0,0,1,0,0,0,0,1,1,1,1,1,1,0,0,0,1,0,1,0]) #60
signature.append([0,1,0,1,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,1]) #61
signature.append([1,1,1,0,0,1,0,1,1,0,0,1,0,1,1,1,1,0,1,0,1]) #62
signature.append([0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1]) #63
signature.append([0,0,1,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1]) #64
signature.append([0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,1]) #65
signature.append([0,1,1,0,1,0,0,1,1,0,0,1,1,1,1,1,0,1,0,1,0]) #66
signature.append([1,1,0,0,0,1,1,1,0,0,0,0,1,1,0,1,1,1,1,0,0]) #67
signature.append([1,1,1,1,0,0,1,0,0,0,1,1,1,1,0,0,0,1,1,1,0]) #68
signature.append([0,1,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,0,0,1,1]) #69
signature.append([0,1,0,1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,1,1,0]) #70
signature.append([1,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,0,1,0,0]) #71
signature.append([1,0,0,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1]) #72
signature.append([1,0,0,1,0,0,1,1,0,0,1,1,1,1,0,1,0,1,1,1,0]) #73
signature.append([1,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,1,0]) #74
signature.append([1,1,1,1,0,1,1,0,0,1,0,1,1,0,1,0,0,0,1,1,1]) #75
signature.append([1,0,1,1,0,1,0,1,0,1,1,1,0,0,1,0,1,0,1,0,1]) #76
signature.append([1,1,0,0,1,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0]) #77
signature.append([1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,1,0,0]) #78
signature.append([1,1,0,0,1,1,1,1,0,0,0,0,0,1,0,1,0,1,1,1,1]) #79
signature.append([0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,1]) #80
signature.append([0,1,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,1,1,0,1]) #81
signature.append([0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1,1,1,0]) #82
signature.append([0,1,1,1,0,1,0,0,1,0,1,1,1,1,0,1,0,1,0,0,0]) #83
signature.append([1,1,1,0,1,0,0,0,1,1,0,0,1,0,1,0,0,1,0,0,1]) #84
signature.append([1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,1,0]) #85
signature.append([0,0,0,1,1,1,0,1,1,1,1,0,0,1,1,0,1,0,0,0,1]) #86
signature.append([1,1,1,0,0,0,0,1,1,0,1,1,1,0,0,1,0,0,0,0,1]) #87
signature.append([1,1,1,0,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,0,1]) #88
signature.append([0,1,0,1,0,1,0,0,1,1,1,0,1,0,1,1,0,1,1,0,1]) #89
signature.append([1,0,0,0,0,0,1,1,1,0,0,1,1,0,1,1,1,1,1,0,0]) #90
signature.append([0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0]) #91
signature.append([0,0,0,1,1,0,1,0,1,1,1,0,1,0,1,1,0,1,1,1,0]) #92
signature.append([1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1]) #93
signature.append([0,0,0,1,1,0,1,0,1,0,1,1,1,0,0,1,1,1,0,0,1]) #94
"""
Tente d'être le meilleur le meilleur de tous les dresseurs
en relevant notre défi.
Ton but est simple, tu dois te constituer la main Pokémon
la plus puissante possible sachant que bien évidemment les Pokémons
ont des compétences différentes, et ce sous les seules règles suivantes :
seuls les Pokémon
n°1 à 94 sont autorisés
ta main ne peut contenir qu'un maximum de 10 Pokémons
tous les Pokémons
dans ta main doivent être différents
Pour cela, un script Python va offrir à ta calculatrice
la fonction pk(n,p) pour ajouter un Pokémon à ta main, avec :
n, le numéro de Pokémon
de 1 à 94
p, la priorité d'attaque que tu souhaites donner au Pokémon
en question (1 par défaut)
Cas particuliers; si le Pokémon est déjà dans ta main sa priorité d'attaque sera mise à jour;
et p=0 retire le Pokémon de ta main.
"""
from math import *
def mmod(a,b):
#modulo 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()
c=2**31-1
k=getplatform() #=-1 sur PC
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,[]
na=21
pkl=[]
#mrandmax,mrand,mfmax,nn,mp=2**31-1,0,93,getlinechars(True)-na,na//2
mrandmax=2**31-1
mrand=0
mfmax=93
nn=getlinechars(True)-na
mp=na//2 #quotien de la division entière, 21//2 = 10
def mround(f):
#renvoie l'entier le plus proche
# 0.5 --> 1
# 0.4 --> 0
#-0.4 --> 0
#-1.4 --> -1
#-1.5 --> -2
#-1.6 --> -2
d=mmod(abs(f),1) #resultat = 0.xxxxx
return (mfloor(abs(f))+(d>=.5))*(1-2*(f<0))
def mfloor(f):
#Arrondi -mfloor(-5.2)=-5
return round(f)-(round(f)>f)
def mceil(f):
#arrondi SUP
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 mf2f(n):
return float(n/mfmax) #mfmax=93
def mbit(a,b):
return mmod((a//(2**b)),2)
def getattack(p,pts):
#p=numéro de l'individu
#pts=l[2]/somme(l[2])
global pkt
# mseed(42) #mrand=42
# print(str(pts))
# for k in range(p+1):
# mrandom() #génère p+1 fois mrand
# a,pka=mrandint(1,mrandmax),""
# a=mrandint(1,mrandmax)
pka=""
npka=0
# print("p="+str(p))
# print(signature[p])
for j in range(na): #na=21
# if mbit(a,j)!=0:
if signature[p][j]==1:
pka+="X"
npka+=1
pkt[j]+=pts
else:
pka+=" -"[getplatform()>=5]
# print("pka="+pka)
return pka
def i2c(k):
return chr(k+33)
def c2i(c):
return ord(c)-33
def f2mf(f):
return mround(float(f*mfmax)) #mfmax=93
def clean():
#recalcule tous les l[2] des individus
global pkl #données des individus
# t,s=0,0
s=0
t=0
for l in pkl:
#t=somme(priorités)
t+=l[1] #t=t+l[1]
# print("t="+str(t))
for l in pkl:
l[2]=f2mf(l[1]/(t or 1)) #t or 1 pour eviter la division par 0
# l[2]=mround(float(l[1]/(t or 1)*93)) #mround = entier le plus proche
s+=l[2] #s=s+l[2] --> s= sommes des l[2]
if(l[2]<=0):
# print("-----")
# print("t="+str(t))
# print("remove "+str(l))
pkl.remove(l) #on enlève l'individu
return clean() #on reitère
return s #on renvoie
def pk_ORIGINE(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+" #"+str(l[0]+1)+" (f="+str(l[1])+")")
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 envoie code suivant a info@tiplanet.org :")
print(""+st)
return float(t)
def pk(n,p=1,d=2):
global pkt,pkl
global sign
#on décrémente de 1, la liste commence à 0
n-=1
if n>=0 and n<len(lnm):
#le n° correspond à un individu
new=True
for k in range(len(pkl)):
if pkl[k][0]==n:
#individu existant, on remplace sa priorité
new=False
pkl[k][1]=max(p,0) #nouvelle priorité
if new and len(pkl)<mp:
#nouvel individu et poignée de 10 non pleine
pkl.append([n,max(p,0),0]) #ajout de l'individu
#calcul des attaques
# ptt,pkt,t,st=clean(),[0 for k in range(na)],0,""
ptt=clean() #recalcule les l[2] et renvoie la somme des l[2]
pkt=[0 for k in range(na)] # [0 0 ... 0 0 0]
t=0
st=""
for l in pkl:
s=getattack(l[0],l[2]/ptt) #maximiser l[2]/ppt
if d:
sn=" "+lnm[l[0]]
if len(sn)>nn:
sn=sn[:nn]
st=i2c(l[0])+st+i2c(l[2])
for k in pkt:
if(k): #k<>0
t+=log(e+k*len(pkl)) #LN log neperien
# print(t,e,k,len(pkl))
# if(d):
# print(""+st)
sign=""+st
return float(t)
def setst(st):
s,pkl[:],n=0,[],len(st)//2
for k in range(n):
s=pk_ORIGINE(c2i(st[n-1-k])+1,c2i(st[n+k+len(st)%2]),k+1>=n)
return s
#print("pk(n,p) pour rajouter le Pokemon n a ta main avec p points d'attaque.")
# print(s+sn+" #"+str(l[0]+1)+" (f="+str(l[1])+")")
#
#
#
# ICI CODE PERSO
#
#
#
import csv
from random import randint
"""
if len(pkl)>9:
numPkARetirer=pkl[randint(0,len(pkl)-1)]][0]
pk(numPkARetirer,0)
"""
#ALGO de recherche
def affListe(listepkl):
for k in listepkl:
print(lnm[k[0]]+" #"+str(k[0]+1)+" (f="+str(k[1])+")" )
def brutforce():
global pkl
global pklMAX
global scoreMax
global score
#construction d'une liste de 10
for i in range(20):
numPk=randint(1,94)
force=randint(1,10)
score=pk(numPk,force)
scoreMax=score
print("===== Liste depart")
pkl=[[25, 1, 0], [81,1, 0], [46,1, 0], [19, 1, 0], [49, 1, 0], [50, 1, 0], [66, 1, 0], [34, 1, 0], [71, 35, 0], [62, 143, 0]]
pklMAX=list(pkl)
affListe(pklMAX)
#bouclage pour trouver meilleur score
for i in range(20000):
# print("\n************** Iterration="+str(i))
if i%1000==0:print(i)
# n=len(pkl)-1
# print(n)
# if n==9:
n=7 #onnenleve pas 72 ni 63
numPkARetirer=pkl[randint(0,n)][0]+1
# print("----- supprimer "+str(numPkARetirer))
pk(numPkARetirer,0)
# affListe(pkl)
while len(pkl)<10:
numPk=72
while numPk==72 or numPk==63:
numPk=randint(1,94)
# force=randint(1,10)
force=1
# print("+++++ Ajouter "+str(numPk))
score=pk(numPk,force)
# print("SCORE="+str(score))
# affListe(pkl)
if score>scoreMax:
scoreMax=score
pklMAX=list(pkl)
print("\nMAX --------------------------------")
print("score ="+str(scoreMax))
affListe(pklMAX)
else:
pkl=list(pklMAX)
return
def ScanStatPKi(numPkFixe):
global pkl
#on fixe 72 et 63
#pour chaque PKi de 1 à 93
# on tire n combinaisons aléatoires,
# on note le score pour le PKi
#à la fin on classe les PKi selon leur score
print(numPkFixe)
score=0
scoreMax=0
ctr=0
#on remplace l'élément
pkl[7][0]=numPkFixe-1
#teste si numPkFixe est dans la plage pkl de 0 à 6
for i in range(0,7):
if pkl[i][0]+1==numPkFixe:
boucler=True
while boucler:
n=randint(1,94)
if n!=numPkFixe and n!=72 and n!=63:
pkl[i][0]=n
boucler=False
boucle=2000
#bouclage pour trouver meilleur score
for i in range(boucle):
#if i%1000==0:print(i)
n=6 #onnenleve pas 72 ni 63, ni numPkFixe
del pkl[0]
boucler=True
while boucler: #len(pkl)<10:
numPk=randint(1,94)
boucler=False
for k in pkl:
if k[0]+1==numPk:
#il y a déjà un num
boucler=True
#on a un numéro
pkunit=[]
pkunit.append(numPk-1)
pkunit.append(1)
pkunit.append(1)
pkl.insert(6,pkunit)
score=pk(pkl[0][0]+1,1)
scoreMax+=score
score=scoreMax/boucle
data=[]
data.append(numPkFixe)
data.append(score) #Score
return data
def scanstat():
global pkl
start_time=time.time()
pkl=[[25,1,0],[81,1,0],[46,1,0],[19,1,0],[49,1,0],[50,1,0],[66,1,0],[34,1,0],[71,35,0],[62,143,0]]
d=[]
for i in range(1,95): #range(1,95) --> 1 à 94
if i!=72 and i!=63:
d.append(ScanStatPKi(i))
print("Temps d execution : "+str( (time.time() - start_time)))
sauve(d)
return d
#scanstat()
def init():
pk(3)
pk(43)
pk(85)
pk(75)
pk(71)
pk(62)
pk(16)
pk(6)
pk(72,35)
pk(63,143)
return
def scoreprio(pk1,pk2):
#max 186
data=[]
data.append(0)
data.append(pk1)
data.append(0)
data.append(pk2)
data.append(0)
smax=0
for p1 in range(1,177): #K186-8-1
for p2 in range(1,178-p1):
if p1<p2:
pk(pk1,p1)
s=pk(pk2,p2)
else:
pk(pk2,p2)
s=pk(pk1,p1)
if s>smax:
smax=s
data[0]=smax
data[2]=p1
data[4]=p2
# pkl=[]
pk(pk1,0)
pk(pk2,0)
return data
def duelprio():
start_time=time.time()
d=[]
for i in range(1,94):
for j in range(i,95):
d.append(scoreprio(i,j))
print("pk "+str(i)+" vs pk "+str(j))
print("Temps d execution : "+str( (time.time() - start_time)))
sauve(d)
# Affichage du temps d execution
return d
def duel(numpk,r):
#crée une ligne se scores du numpk vs chaque element dans r
priorite=1
pkduel=[]
pk(numpk,priorite)
for i in r:
if numpk!=i:
pkduel.append(pk(i,priorite))
pk(i,0)
else:
pkduel.append(0)
pk(numpk,0)
return pkduel
def matriceduel():
p=[]
r=range(1,95)
r=[16,23,62,69,71,75,88]
r=range(1,4)
r=range(1,95)
for i in r:
p.append(duel(i,r))
return p
def cartographie():
priorite=9
global pkcarto
pkcarto=[]
lgn=["ID","Points","nb de X","valeurs"]
#pkcarto.append(lgn)
for i in range(1,95):
pk(i,priorite)
# pkcarto.append(pkt)
t=""
for j in range(len(pkt)):
t+=str(int(pkt[j]))
if j!=len(pkt)-1:
t+=","
print("signature.append(["+str(t)+"]) #"+str(i))
pk(i,0)
return
def sauve(p):
#sauvegarde une matrice p en csv
#with open("L:/_Datas/11 - Arnaud/Python - DEFI/table.csv", "w") as f_write:
with open("d:/table.csv", "w") as f_write:
writer = csv.writer(f_write,delimiter=";")
writer.writerows(p)
return
def seek(id):
smax=0
for i in range(1,130):
s=pk(id,i)
if s>smax:
smax=s
priorite=i
score=pk(id,priorite)
print("pk("+str(id)+","+str(priorite)+")=" +str(score) )
return score
def valeur(priorite=1):
#renoie une liste de chaque score ID seul
l=[]
for i in range(1,95):
s=pk(i,priorite)
l.append(s)
pk(i,0)
print(s)
return
def estdanspkl(ID):
r=False
for p in pkl:
if p[0]+1==ID:
r=True
break
return r
def meilleurID(IDaexclure=0):
#renvoie le meilleur ID
priorite=1
IDmax=0
smax=0
if len(pkl)==10:
IDmax=0
else:
for ID in range(1,95):
if ID!=IDaexclure:
if not(estdanspkl(ID)):
#l'ID n'est pas dans la liste pkl
s=pk(ID,priorite)
if s>smax:
#score meilleur
smax=s
IDmax=ID
pk(ID,0)
return IDmax
def creermeilleurID():
ID=meilleurID()
if ID!=0:
pk(ID)
seekall()
return
def seekall():
for p in pkl:
score=seek(p[0]+1)
return score
def scan():
#max 186
#186-8 = 178
smax=0
f63=94
f72=0
f03=0
pk(63,f63)
for i in range(1,178-1):
for j in range(1,178-i):
# for k in range(1,178-i-j):
pk(3,i)
s=pk(72,j)
st=setst(""+sign)
if st>smax:
smax=st
# f63=i
f72=i
f03=j
print("MAX setst="+str(smax))
print("S="+str(s))
# print("Signature="+sign+" "+str(st))
print(" P72="+str(i)+" P03="+str(j))
pk(63,f63)
pk(72,f72)
pk(3,f03)
return
def combi(level,levelmax,pkpossibles,smax=0,pkdeb=0):
#on incrémente le niveau d'arbo
l=level+1
# print("l="+str(l))
if l>levelmax:
#on est arrivé en bas de l'arbo souhaitée
#on peut faire les calculs
s=seekall()
print("s="+str(s))
if s>smax:
smax=s
print("smax=",str(smax))
else:
# for i in pkpossibles:
for ii in range(pkdeb,len(pkpossibles)):
i=pkpossibles[ii]
#☺ if not(estdanspkl(i)):
#l'ID n'est pas déjà dans la liste
# print("id="+str(i))
#on ajoute l'individu
pk(i)
#on descend en arbo
smax=combi(l,levelmax,pkpossibles,smax,ii+1)
pk(i,0) #on eneleve l'individu
return smax
def trouvecombi():
pkpossibles=[16,62,71,23,69,75,88]
pkpossibles=[16,62,71,23,69]
smax=combi(0,3,pkpossibles)
return smax
#
#
# RESULTATS
#
#
def initamiga():
#amiga68000
#record à battre = 49,31730
#49.31975298152274
pk(3,1)
pk(62,1)
pk(71,1)
pk(16,1)
pk(43,1)
pk(85,1)
pk(47,1)
pk(51,1)
pk(72,32)
pk(63,128)
#la somme des priorités <=186
return
"""
transmis le 14/10/19 via amiga68000
XXXXX XXXXXXXXX X Florizarre
XXX X XX X XXXX X X Tartard
XX X XXXXX XXXX X Empiflor
XX XXXX XXX X X XX Roucool
XXXX XXX XXXXX X X Mystherbe
X XXXXXXXX XXX XX Dodrio
X XXX XXXXXX XXXX Parasect
XXXXXX X X XX X X Triopikeur
X XXXX X XXXXX XXX X Tentacool
XXXX XXXXXXXXXX XXXX Abra
Bon score ? Si oui
envoie code suivant
a info@tiplanet.org :
_hSOuK0g^#""""""""3h
49.31975298152274
"""
def initk():
#record à battre = 49,31730
#49.32078546995182
pk(3,1)
pk(62,1)
pk(71,1)
pk(16,1)
pk(43,1)
pk(85,1)
pk(47,1)
pk(51,1)
pk(72,35)
pk(63,143)
#la somme des priorités <=186
return
"""
XXXXX XXXXXXXXX X Florizarre
XXX X XX X XXXX X X Tartard
XX X XXXXX XXXX X Empiflor
XX XXXX XXX X X XX Roucool
XXXX XXX XXXXX X X Mystherbe
X XXXXXXXX XXX XX Dodrio
X XXX XXXXXX XXXX Parasect
XXXXXX X X XX X X Triopikeur
X XXXX X XXXXX XXX X Tentacool
XXXX XXXXXXXXXX XXXX Abra
Bon score ? Si oui
envoie code suivant
a info@tiplanet.org :
_hSOuK0g^#""""""""3i
49.32078546995182
"""
def init5():
#record à battre = 49,31730
#49.28269871690558
pk(16,1)
pk(51,1)
pk(58,1)
pk(62,1)
pk(71,1)
pk(76,1)
pk(5,1)
pk(6,1)
pk(72,35)
pk(63,143)
return
def init4():
#record à battre = 49,31730
#49.138894711933105
pk(85,1)
pk(89,1)
pk(69,1)
pk(73,1)
pk(90,1)
pk(86,1)
pk(88,1)
pk(87,1)
pk(72,35)
pk(63,143)
return
def init3():
#record à battre = 49,31730
#
pk(63,64)
pk(3,1)
pk(72,16)
pk(62,1)
pk(71,1)
pk(16,1)
pk(43,1)
#13 X
pk(23,1)
pk(16,1)
pk(75,1)
return
def init21():
#record à battre = 49,31730
#49.274636982498805
pk(63,61) #56
pk(3,1)
pk(72,16)
pk(5,1)
pk(43,1)
pk(47,1)
pk(85,1)
#17.0724019377368
pk(16,1)
# pk(62,1)
# pk(71,1)
pk(23,1)
# pk(69,1)
# pk(75,1)
pk(88,1)
# seek(63)
# seek(72)
return
def init1():
#record à battre = 49,31730
#49.28984977976379
pk(63,61) #56
pk(3,1)
pk(72,16)
pk(5,1)
pk(43,1)
pk(47,1)
pk(85,1)
#17.0724019377368
# pk(16,1)
# pk(62,1)
pk(71,1)
# pk(23,1)
pk(69,1)
pk(75,1)
# pk(88,1)
# seek(63)
# seek(72)
return
def init2():
#record à battre = 49,31730
#49.31571202586076
pk(3,1)
pk(5,1)
pk(43,1)
pk(47,1)
pk(85,1)
#17.0724019377368
pk(16,1)
pk(62,1)
pk(71,1)
# pk(23,1)
# pk(69,1)
# pk(75,1)
# pk(88,1)
pk(72,35)
pk(63,143) #56
return
#algo()
"""
print("\nMAX --------------------------------")
print(scoreMax)
affListe(pklMAX)
"""
print("--------------------------------")
print("pk(n,p) pour rajouter\nle Pokemon n a ta main\navec p points d'attaque.")
#end
for a in range(94):
pk(a,1)
s=st
print("score final =",setst(s))
if setst(s)>49.3:
print(f" OK pour a = {a}, s={setst(s)} pour {st}")
pk(a,0)
for a in range(150):
pk(62,a)
s=st
print("score final =",setst(s))
if setst(s)>49.3:
print("OK !")
print(a,setst(s),"pour",st)
pk(62,0)
Tituya a écrit:J'ai pris le sujet à l'envers pour en tirer le plus possible avec ma petite échelle de lycéen lambda... J'ai surtout passé énormément de temps à chercher des choses en tous genres, essayer d'automatiser des bouts de code, je pense sincèrement que ce concours m'a pris plus d'une vingtaine d'heures !
Entre désillusions, avec des tentatives de bruteforce de plusieurs heures sans succès. Ou la joie de voir mon petit programme renvoyer soudainement un "OK pour cette valeur" !
Au final, ce concours m'a permis d'améliorer grandement ma maitrise en python ! Et étonnamment, réussir à obtenir une place sans comprendre une ligne du script fourni :E. Comme quoi, avec le temps et la persévérance on peut réussir même sans tout comprendre !
Bien joué à tous/toutes pour ce concours ! Et particulièrement à Cent20 qui m'a poussé sans le savoir à une compétition personnelle entre lui et moi!
lc = [None,"!","!","!","!","!","!","!","!","!","!"]
carac = '!"#$%&'+"'"+'()*+^;_,-./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
def cons(liste):
global cc
cc = ""
for j in range(len(liste)):
cc = cc+liste[j]
def turboBoost(pokemons,vitesse=1,style=1):
lc[0]=pokemons
for l in range(vitesse+3):
for i in range(1,11):
global cc
cons(lc)
scores = [0]
for k in range(len(carac)):
lc[i] = carac[k]
cons(lc)
score = setst(cc)
scores.append(score)
lc[i] = carac[scores.index(max(scores))-1]
cons(lc)
if style:
print(int((l+1)*100/(vitesse+3)),"%")
if vitesse == 1:
print("====="*(l+1)*2+"....."*(8-(l+1)*2))
if vitesse == 2:
print("===="*(l+1)*2+"...."*(10-(l+1)*2))
score = setst(cc)
print(cc+" :",score,": "+code)
def chasseAuxPokemons(vitesse=1):
lcp = ["!","!","!","!","!","!","!","!","!","!"]
for l in range(vitesse+3):
for i in range(10):
global cc
cons(lcp)
scores = [0]
for k in range(len(carac)):
lcp[i] = carac[k]
cons(lcp)
turboBoost(cc,1,0)
score = setst(cc)
scores.append(score)
lcp[i] = carac[scores.index(max(scores))-1]
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 179 invités