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


Python GameState.parseInput方法代码示例

本文整理汇总了Python中GameState.parseInput方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.parseInput方法的具体用法?Python GameState.parseInput怎么用?Python GameState.parseInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameState的用法示例。


在下文中一共展示了GameState.parseInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import parseInput [as 别名]
class PostMatchHistoryGenerator:
    def __init__(self):#, fileName):
        #self.fileName = fileName
        self.game = GameState()
        self.archive = PostMatchHistory()
        self.history = ParseMatchHistory(1000)

        #self.history.parseHistory(fileName)

    def run(self):
        self.history.packets.reverse()

        while len(self.history.packets) > 0:
            data = self.history.packets.pop()

            self.game.parseInput(data[0] + "\n")

            if self.game.state == NEWGAME:
                self.archive.reset(self.game)
            elif self.game.state == HANDOVER:
                self.game.leftOpp.holeCard1 = data[1][0]
                self.game.leftOpp.holeCard2 = data[1][1]
                self.game.rightOpp.holeCard1 = data[2][0]
                self.game.rightOpp.holeCard2 = data[2][1]
                self.archive.update(self.game)

    def plotBets(self):
        #fig = plt.figure()
        for pname in self.archive.history.keys():
            for s in range(RIVER+1):
                #t = RAISE
                for t in self.archive.history[pname][s].keys():
                    #print s,t
                    ys = [int(a.amount) for a in self.archive.history[pname][s][t]]
                    xs = [a.ev[0] for a in self.archive.history[pname][s][t]]
                    ps = [a.potAmount for a in self.archive.history[pname][s][t]]
                    bs = [a.betAmount for a in self.archive.history[pname][s][t]]
                    if len(xs) == 0:
                        continue
                    print "potamt:%.3f %.3f" % (min(ps),max(ps)),
                    print "betamt:%.3f %.3f" %(min(bs),max(bs))
                    #print xs,ys
                    plt.figure()
                    plt.title(pname)
                    if min(ys) == max(ys):
                        zs = [0 for i in range(1001)]
                        for y in xs:
                            zs[y] += 1
                        x = []
                        y = []
                        for i,z in enumerate(zs):
                            if z>0:
                                x+=[i]
                                y+=[z]
                        plt.scatter(x,y)
                        plt.xlabel("HandStrength")
                        plt.ylabel("Frequency of "+ACTION_TYPES[t]+":"+str(min(ys)))
                    elif min(xs)==max(xs):
                        zs = [0 for i in range(201)]
                        for x in ys:
                            zs[x] += 1
                        x = []
                        y = []
                        for i,z in enumerate(zs):
                            if z>0:
                                x+=[i]
                                y+=[z]
                        plt.scatter(x,y)
                        plt.ylabel("Frequency of EV="+str(min(xs)))
                        plt.xlabel(ACTION_TYPES[t] + ".absAmount")
                    else:
                        plt.hexbin(xs,ys,mincnt=1)
                        plt.axis([0,1000,0,205])
                        plt.xlabel("Hand Strength")
                        plt.ylabel(ACTION_TYPES[t] + ".absAmount")
                        cb = plt.colorbar()
                        cb.set_label('counts')
                    plt.savefig(pname + "-" + STREET_TYPES[s]+"-"+ACTION_TYPES[t] + ".png")
开发者ID:oderby,项目名称:pokerbots,代码行数:80,代码来源:PostMatchHistoryGenerator.py

示例2: GameState

# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import parseInput [as 别名]
    fs = s.makefile()

    game = GameState()

    while 1:
        # block until the engine sends us a packet
        # data = s.recv(4096)
        data = fs.readline()
        # if we receive a null return, then the connection is dead
        if not data:
            print "Gameover, engine disconnected"
            break
        # Here is where you should implement code to parse the packets from
        # the engine and act on it.
        ##        print data
        game.parseInput(data)

        # When appropriate, reply to the engine with a legal action.
        # The engine will ignore all spurious packets you send.
        # The engine will also check/fold for you if you return an
        # illegal action.
        # When sending responses, you need to have a newline character (\n) or
        # carriage return (\r), or else your bot will hang!

        if game.timebank < 0:
            print "RUN OUT OF TIME"

        if game.state == "GETACTION":
            s.send("CALL\n")
    # if we get here, the server disconnected us, so clean up the socket
    s.close()
开发者ID:oderby,项目名称:pokerbots,代码行数:33,代码来源:CallPlayer.py


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