本文整理汇总了Python中xmlrpclib.ServerProxy.move方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.move方法的具体用法?Python ServerProxy.move怎么用?Python ServerProxy.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.move方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import move [as 别名]
class Client:
def __init__(self):
self.playerID = None
self.board = None
self.server = ServerProxy("http://localhost:8000")
def createGame(self):
self.playerID = self.server.createGame()
def startGame(self,playerLetter):
self.server.startGame(self.playerID,playerLetter)
def makeMove(self,move):
self.server.move(self.playerID,move)
def endGame(self):
self.server.endGame(self.playerID)
def inputPlayerLetter(self):
letter = ''
while not (letter == 'X' or letter == 'O'):
print('Do you want to be X or O?')
letter = input().upper()
return letter
def getPlayerMove(self):
# Let the player type in their move.
move = ' '
while move not in '1 2 3 4 5 6 7 8 9'.split():
print('What is your next move? (1-9)')
move = input()
return int(move)
def getBoard(self):
self.board = self.server.getBoard(self.playerID)
def drawBoard(board):
print(' | |')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
print(' | |')
print('-----------')
print(' | |')
print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
print(' | |')
def parse(self,response):
return True
示例2: ServerProxy
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import move [as 别名]
from AI import ReversiSimpleAI
game_server = ServerProxy("http://127.0.0.1:8006")
game_id = game_server.start_game('[email protected]')
ai = ReversiSimpleAI()
step = 0
while True:
print '==============================='
board = Board(game_server.get_board_state(game_id))
board.pprint()
x, y = ai.get_best_move(board, 1)
state = game_server.move(x, y, game_id)
step += 1
board = Board(game_server.get_board_state(game_id))
print '_______________________________'
board.pprint()
print state
if state[1] == 'game_over':
if board.score(1) > board.score(2):
print "YOU'VE WON!!!", 'in ', step, 'steps'
if board.score(1) == board.score(2):
print 'EQUAL SCORE', 'in ', step, 'steps'
if board.score(1) < board.score(2):
print "YOU'VE LOST", 'in ', step, 'steps'
示例3: raw_input
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import move [as 别名]
letter = raw_input('Choose any letter to start (O or X): ')
if letter.upper() != 'O' and letter.upper() != 'X':
continue
else:
command, result = parse_command(server.start(tid, letter))
if command == '201':
running = True
else:
print 'An error occured, please try again later.'
else:
board = parse_board(server.board(tid))
draw_board(board)
turn = server.turn(tid)
if turn == 'Human':
move = raw_input("It's your turn. Please enter a move (1-9)")
command, result = parse_command(server.move(tid, int(move)))
if command == '403':
print("You entered invalid move. ")
if command == '402':
print("FATAL1: Fatal error occured. Try to restart the game.")
break
if command == '405':
print("It is cpu's turn.")
elif command == '204':
command, result = parse_command(server.won(tid))
if command == '402':
print("FATAL3: Fatal error occured. Try to restart the game.")
break
if command == '206':
print 'You Won!'
again = None