fromkandinskyimport*fromtimeimportsleepfromionimport*try:get_keys()color_pions=[(192,53,53),(255,183,52)]except:color_pions=[(255,183,52),(192,53,53)]plateau=['0202020202','2020202020','0202020202','2020202020','0000000000','0000000000','0101010101','1010101010','0101010101','1010101010']defcreate_plateau():# Crée un plateau en graphique 10x10 avec comme point de départ le point de coordonnées (10, 20) et avec chaque carré de taille 20x20
forjinrange(10,211,20):forxinrange(20,221,1):set_pixel(x,j,(0,0,0))foriinrange(20,221,20):foryinrange(10,211,1):set_pixel(i,y,(0,0,0))defdessin_pion(coord_pion,color):fill_rect(coord_pion[1]*20+21,coord_pion[0]*20+11,19,19,color)definit_pions():foriinrange(len(plateau)):forjinrange(len(plateau[0])):ifplateau[j][i]!='0':ifplateau[j][i]=='2':color_temp_pion=color_pions[1]elifplateau[j][i]=='1':color_temp_pion=color_pions[0]else:# si c'est une dame
passdessin_pion((j,i),color_temp_pion)defbouge_pion(coord_pion,new_coord):dessin_pion(coord_pion,(255,255,255))dessin_pion(new_coord,color_pions[0])defallume_pion(coord_pion):dessin_pion(coord_pion,(0,0,0))defeteint_pion(coord_pion):dessin_pion(coord_pion,color_pions[0])defchoix(liste_choix):id_choix=0whilenotkeydown(4):# tant que ok n'est pas appuyé
allume_pion(liste_choix[id_choix])ifkeydown(0):# touche gauche
sleep(0.25)eteint_pion(liste_choix[id_choix])ifid_choix==0:id_choix=len(liste_choix)-1else:id_choix-=1elifkeydown(3):# touche droite
sleep(0.25)eteint_pion(liste_choix[id_choix])ifid_choix==len(liste_choix)-1:id_choix=0else:id_choix+=1returnliste_choix[id_choix]defchoix_pion():temp_pions_joueur=[]foriinrange(10):forjinrange(10):ifplateau[i][j]=="1":temp_pions_joueur+=[(i,j)]choix(temp_pions_joueur)defchoix_deplacement_pion(coord_pion):liste_move=move_possible_pion_blanc(coord_pion)# liste_move est une liste de tuples ou chaque tuple est les coord d'un point possible où aller
choix(liste_move)create_plateau()init_pions()print(choix_pion())
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.