grapher.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:TetrisAI 作者: bbergrobots 项目源码 文件源码
def drawGraph( self ):
        graph = gui.Surface( ( 300, 200 ) )
        graph.set_colorkey( ( 0, 0, 0 ) )
        gens = len( self.genScores )
        for genome in range( 40 ):
            pointlist = [ ( 0, 200 ) ]
            for generation in range( gens ):
                x = int( 300 * ( generation+1 ) / gens )
                y = 200 - int( 200 * self.genScores[ generation ][ genome ] / self.highScore  )
                pointlist.append( ( x, y ) )
            if genome in [ 0, 19, 39 ]:
                gui.draw.lines( graph, ( 0, 0, 255 ), False, pointlist, 2 )
            else:
                gui.draw.lines( graph, ( 112, 108, 90 ), False, pointlist, 1 )
        pointlist = [ ( 0, 200 ) ]
        for generation in range( gens ):
            x = int( 300 * ( generation+1 ) / gens )
            y = 200 - int( 200 * np.average( self.genScores[ generation ] ) / self.highScore  )
            pointlist.append( ( x, y ) )
        gui.draw.lines( graph, ( 255, 0,  0 ), False, pointlist, 2 )

        self.lastGraph = graph
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号