# @Time : 2023/3/16 21:17
# @Autor : 菜皇
# @file : damo1.py
# @SOFTWARE : PyCharm
import sys
BOARD_SIZE = 15
# 初始化棋盘
def init_board():
board = [['.' for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]
return board
# 绘制棋盘
def print_board(board):
for row in board:
print(" ".join(row))
print()
# 检查是否有玩家获胜
def check_winner(board, player):
for x in range(BOARD_SIZE):
for y in range(BOARD_SIZE):
if board[x][y] == player:
# 水平方向
if y = 4 and y = BOARD_SIZE or y = BOARD_SIZE:
print("坐标超出范围,请输入0-14之间的数字。")
continue
if board[x][y] != '.':
print("该位置已有棋子,请重新输入。")
continue
board[x][y] = players[current_turn]
print_board(board)
if check_winner(board, players[current_turn]):
print("恭喜玩家 {} 获胜!".format(players[current_turn]))
break
current_turn = (current_turn + 1) % 2
if __name__ == "__main__":
main()[/mw_shl_code]
想搞成一个窗口小游戏,还不会搞,没学到