Ejemplo n.º 1
0
 def evaluate2(self, state, player, action =None, quad_table_ext=None):
     '''
     @type state: loa_game.LinesOfActionState
     '''
     
     cmt = initialize(state.board)
     cmt.coord_repr
     EndTimer.check(name="cm_f")
     
     my_coord_list = cmt.coord_repr[player]
     cm = cmt.cm_dict[player]
     
     EndTimer.check(name="cm_g")
     
     GTimeStatistics.start_measure("sum_of_min_distances_ext2")
     rsmd = self.sum_of_min_distances_ext2(cm,my_coord_list)
     GTimeStatistics.stop_measure("sum_of_min_distances_ext2")
     
     smart_sum, smart_sum_count, dsum, dmin_sum, dmin, dmin_count = rsmd
     
     r1 = self.min_sum_res(smart_sum_count, smart_sum)
     r2 = self.min_sum_fix(dmin, dmin_count, len(my_coord_list))
     
     
     return r1, r2
Ejemplo n.º 2
0
def test5():
    ''' hash items()'''
    root = LinesOfActionState(10, 50)
    succs = root.getSuccessors().items()[0][1].getSuccessors()
    dd = {}
    
    def count(d):
        k,v = d.popitem()
        r = v.getSuccessors()
        d[k]=v
        sum = 0
        #for k in d.items():
        #    sum += 1
        return sum
    
    def counts():
        smax = -1
        smin = 10000000
        for _ in xrange(1000):
            sum = GTimeStatistics.measure_function(count,succs)
            smax = max(smax,sum)
            smin = min(smin,sum)
        return smax,smin
        
    smax,smin = GTimeStatistics.measure_function(counts)
    print GTimeStatistics
    print smax,smin
Ejemplo n.º 3
0
 def counts():
     smax = -1
     smin = 10000000
     for _ in xrange(1000):
         sum = GTimeStatistics.measure_function(count,succs)
         smax = max(smax,sum)
         smin = min(smin,sum)
     return smax,smin
Ejemplo n.º 4
0
 def utility(self, state, info_set):
     GTimeStatistics.start_measure("agent.utility")
     hv = self.evaluator.evaluate(state, self.player, info_set)
     GTimeStatistics.stop_measure("agent.utility")
     return hv
Ejemplo n.º 5
0
 def g():
     return GTimeStatistics.measure_function(f)
Ejemplo n.º 6
0
 def utility(self,state,info_set):
     GTimeStatistics.start_measure("heur")
     r = self.evaluator.evaluate(state, self.player,info_set)
     GTimeStatistics.stop_measure("heur")
     return r