############################################################
# Testbench for player_L1 and player_L2
############################################################
Copyright By PowCoder代写 加微信 powcoder
import random
import itertools
from Tic_Tac_Toe import is_win, place, game_control, player_L0
############################################################
# player_L1() – Level 1 player program
############################################################
def player_L1(board, player):
c_poss = [i for i in range(9) if board[i] == 0]
assert c_poss != [], \
“At player_L0: No empty position!”
return random.choice(c_poss)
############################################################
# player_L2() – Level 2 player program
############################################################
def player_L2(board, player):
c_poss = [i for i in range(9) if board[i] == 0]
assert c_poss != [], \
“At player_L0: No empty position!”
return random.choice(c_poss)
############################################################
# Testbench for game_control() with sample programs
############################################################
import itertools
from Tic_Tac_Toe import game_control, player_L0
if __name__ == “__main__”:
players = [player_L0, player_L1, player_L2]
names = [p.__name__ for p in players]
for i, j in itertools.product((0,1,2),repeat=2):
print(“Players:”, names[i], “vs”, names[j])
game_control(1000, players[i], players[j], 0)
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com