当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.move方法代码示例

本文整理汇总了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
开发者ID:skanca,项目名称:SWE545_TERMPROJECT,代码行数:53,代码来源:Client.py

示例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'
        
开发者ID:korobool,项目名称:reversid,代码行数:32,代码来源:client.py

示例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
开发者ID:OrkunKocyigit,项目名称:SWE545_Project,代码行数:33,代码来源:SimpleClient.py


注:本文中的xmlrpclib.ServerProxy.move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。