 Salá application AI oyo ekoki kobɛta tic-tac-toe.
Ya solo, nakoki kosalisa yo osala application AI oyo ekoki kobeta Tic-Tac-Toe. Tala code ya ndakisa na Python oyo okoki kosalela lokola esika ya kobanda: ```python import random board = [" " mpo na i na range(9)] def print_board(): row1 = "|{}|{}|{ }|".format(tableau[0], tableau[1], tableau[2]) row2 = "|{}|{}|{}|".format(tableau[3], tableau[4], tableau[ 5]) row3 = "|{}|{}|{}|".format(tableau[6], tableau[7], tableau[8]) imprimer() imprimer(molongo1) imprimer(molongo2) imprimer(molongo3) print() def check_winner (char, pos1,pos2,post3): zongisa tableau [pos1] == char na tableau [pos2] == char na tableau[pos3] == char def check_all (char): # Vérifier ba lignes pona i na intervalle(3): soki check_winner (char, i * 3, (i * 3) + 1, (i * 3) + 2): zongisa Solo # Vérifier ba colonnes pona i na range(3): soki check_winner (char, i, i+3, i+6): zongisa Solo # Ba diagonales ya vérifier zongisa check_winner (char, 0, 4, 8) to check_winner (char, 2, 4, 6) def joueur_move(icône): soki icône == "X ": motango = 1 mosusu: motango = 2 kopona = int(entrée("Mosani {}, kotia mouvement na yo (1-9): ".format(motango)).strip()) soki tableau [pona - 1] = = " ": tableau [pona - 1] = icon else: imprimer() imprimer("Esika wana ezwami!") player_move(icône) def comp_move(): possible_moves = [x mpo na x na intervalle(len(tableau)) soki board[x] == " "] move = -1 # Tala soki ordinateur ekoki kolonga mpo na elembo na ["O", "X"]: mpo na ngai na possible_moves: board_copy = tableau[:] board_copy[i] = elembo soki check_all(icon): move = na zongisa move # Meka kozua moko ya ba coins ba coins = [0,2,6,8