Créer un compteSe connecter
import random

# Initialisation du plateau de jeu
board = [ [" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "]
]

# Initialisation des pièces
pieces = {
"p": "♟",
"r": "♜",
"n": "♞",
"b": "♝",
"q": "♛",
"k": "♚"
}

# Placement des pièces sur le plateau
for i in range(len(board)):
board[1][i] = pieces["p"] # Pions noirs
board[6][i] = pieces["p"] # Pions blancs

board[0][0] = pieces["r"] # Tours noires
board[0][7] = pieces["r"]
board[7][0] = pieces["r"] # Tours blanches
board[7][7] = pieces["r"]

board[0][1] = pieces["n"] # Cavaliers noirs
board[0][6] = pieces["n"]
board[7][1] = pieces["n"] # Cavaliers blancs
board[7][6] = pieces["n"]

board[0][2] = pieces["b"] # Fous noirs
board[0][5] = pieces["b"]
board[7][2] = pieces["b"] # Fous blancs
board[7][5] = pieces["b"]

board[0][3] = pieces["q"] # Reine noire
board[7][3] = pieces["q"] # Reine blanche

board[0][4] = pieces["k"] # Roi noir
board[7][4] = pieces["k"] # Roi blanc

# Affichage du plateau
def print_board():
for i in range(len(board)):
print(" ".join(board[i]))

# Tour de jeu
def play():
# Déplacement aléatoire d'une pièce
from_row, from_col = random.randint(0, 7), random.randint(0, 7)
to_row, to_col = random.randint(0, 7), random.randint(0, 7)

# Vérification que le déplacement est possible
piece = board[from_row][from_col]
if piece == " ":
return "No piece to move"
elif board[to_row][to_col] != " ":
return "Move not possible"
else:
board[from_row][from_col] = " "
board[to_row][to_col] = piece
return "Moved " + piece + " from " + str(from_row) + "," + str(from_col) + " to " + str(to_row) + "," + str(to_col)

# Boucle de jeu
while True:
print_board()
print(play())
input()


alors ? Image
il y a 4 ans
Où est l'IA ?
:hap:
il y a 4 ans