print('エラーが発生しました。') exit() data = r.json() roomid = data['id'] player = data['player'] board = [] payload = {} if (player == 1): payload = {'player': player} r = requests.post(base_url + "wait_for_player/" + roomid, data=payload, headers=headers) data = r.json() OthelloLogic.printBoard(json.loads(data['board'])) board = json.loads(data['board']) moves = json.loads(data['moves']) else: OthelloLogic.printBoard(json.loads(data['board'])) rev_board = json.loads(data['board']) board = json.loads(data['board']) for x in range(len(rev_board)): for y in range(len(rev_board)): board[x][y] = rev_board[x][y] * -1 moves = json.loads(data['moves']) action = json.dumps(OthelloAction.getAction(board, moves)) payload = {'action': action, 'player': player} while (True):
board[int(size/2)-1][int(size/2)-1] = 1; board[int(size/2)][int(size/2)-1]=-1; board[int(size/2)-1][int(size/2)]=-1; board[int(size/2)][int(size/2)]=1; player = -1 moves = OthelloLogic.getMoves(board,player,size) while(True): if(player == -1): action = OthelloAction.getAction(OthelloLogic.getReverseboard(board),moves) else: action = OthelloAction.getAction(board,moves) if(not (action in moves)): print(board) print('合法手ではない手が打たれました' + action) exit() board = OthelloLogic.execute(board,action,player,size) OthelloLogic.printBoard(board) print('現在の合法手一覧') print(moves) moves = OthelloLogic.getMoves(board,player*-1,size) if(len(moves) == 0): moves = OthelloLogic.getMoves(board,player,size) if(len(moves) == 0): break else: player = player * -1 input("Press Enter key to next....") print('正常に終了しました。')