1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| from random import *
# creation du tableau 11*11
Taille_grille = 11
def tab(Taille_grille):
tableau = [["0"]* Taille_grille for i in range(Taille_grille)]
#positionnement éléments
tableau[0][5]="S"
tableau[4][0]="S"
tableau[4][10]="S" #positionnement sorties
tableau[1][2]="W" #positionnement gardiens
tableau[1][8]="W"
tableau[2][4]="B"
tableau[2][5]="B"
tableau[2][6]="B" #positionnement bassin
tableau[3][4]="B"
tableau[3][5]="B"
tableau[3][6]="B"
tableau[8][4]="C"
tableau[8][5]="C"
tableau[8][6]="C"
tableau[9][3]="C"
tableau[9][4]="C" #positionnement chats
tableau[9][5]="C"
tableau[9][6]="C"
tableau[9][7]="C"
tableau[10][3]="C"
tableau[10][4]="C"
tableau[10][5]="C"
tableau[10][6]="C"
tableau[10][7]="C"
tableau[7][5]="ç" # positionnement chaf
# positionnement des robots
a= randint(0,len(tableau)-1)
b= randint(0,len(tableau)-1)
for i in range (9):
a=randint(0,len(tableau)-1)
b=randint(0,len(tableau)-1)
while tableau[a][b]!="0":
a=randint(0,len(tableau)-1)
b=randint(0,len(tableau)-1)
tableau[a][b]='R'
#affichage de tableau ligne par ligne
for i in range (len(tableau)):
print (tableau[i])
return tableau
#choix du chat
def depchats(tab):
for i in range (0,1):
print ("quel chat déplacez vous ?")
x=int(input("la coordonéée verticale = "))
y=int(input("la coordonée horizontale ="))
z=int(input("bas gauche (1), bas (2), bas droite (3), gauche (4), droite (6), haut gauche (7), haut (8), haut droite (9)"))
# print(tab[x][y])
if tab[x][y]=='C':
if z == 1 and tab[x+1][y-1] == "0":
tab[x+1][y-1]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==2 and tab[x+1][y] =="0":
tab[x+1][y]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==3 and tab[x+1][y+1] =="0":
tab[x+1][y+1]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==4 and tab[x][y-1] =="0":
tab[x][y-1]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==6 and tab[x][y+1]=="0":
tab[x][y+1]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==7 and tab[x-1][y-1]=="0":
tab[x-1][y-1]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==8 and tab[x-1][y]=="0":
tab[x-1][y]="C"
tab[x][y]="0"
else:
print ("pas possible")
if z==9 and tab[x-1][y+1]=="0":
tab[x-1][y+1]="C"
tab[x][y]="0"
else:
print ("pas possible")
return tab
tableau = tab(Taille_grille)
depchats(tableau)
print(tableau) |
Partager