Exemple #1
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.colors = np.zeros([num_players, 3], dtype=np.uint8)
     self.dark_colors = np.zeros([num_players, 3], dtype=np.uint8)
     ci = 0
     for hue in xrange(0, 360, 360/num_players):
         light_color = np.array(
             [int(color) for color in hsv2rgb(hue/360.0, 0.75, 1)]
         )
         dark_color = np.array(
             [int(color) for color in hsv2rgb(hue/360.0, 0.75, 0.75)]
         )
         self.colors[ci] = light_color
         self.dark_colors[ci] = dark_color
         ci += 1
     genVoronoi.init_cache()
     self.points = np.zeros([num_players, num_moves, 2], dtype=np.int)
     self.points.fill(-1)
     self.image = QtGui.QImage(
         board_size/scale,
         board_size/scale,
         QtGui.QImage.Format_RGB888
     )
     ptr = self.image.bits()
     ptr.setsize(self.image.byteCount())
     self.imagenp = np.asarray(ptr).reshape(board_size/scale, board_size/scale, 3)
     self.current_player = 0
     self.move = 0
     self.initUI()
 def __init__(self, GUIOn, delay):
     self.GUIOn = GUIOn
     self.delay = delay
     super(MainWindow, self).__init__()
     self.colors = np.zeros([num_players, 3], dtype=np.uint8)
     self.dark_colors = np.zeros([num_players, 3], dtype=np.uint8)
     ci = 0
     for hue in xrange(0, 360, 360/num_players):
         light_color = np.array(
             [int(color) for color in hsv2rgb(hue/360.0, 0.75, 1)]
         )
         dark_color = np.array(
             [int(color) for color in hsv2rgb(hue/360.0, 0.75, 0.75)]
         )
         self.colors[ci] = light_color
         self.dark_colors[ci] = dark_color
         ci += 1
     genVoronoi.init_cache()
     self.points = np.zeros([num_players, num_moves, 2], dtype=np.int)
     self.points.fill(-1)
     self.player_names = []
     if self.GUIOn:
         self.image = QtGui.QImage(
             board_size/scale,
             board_size/scale,
             QtGui.QImage.Format_RGB888
         )
         ptr = self.image.bits()
         ptr.setsize(self.image.byteCount())
         self.imagenp = np.asarray(ptr).reshape(board_size/scale, board_size/scale, 3)
         self.initUI()
     else:
         # generate_voronoi_diagram needs this
         self.imagenp = np.zeros([board_size/scale, board_size/scale, 3], dtype=np.uint8)
Exemple #3
0
    def __init__(self, name, idx, numMoves):
        Client.__init__(self, name)
        self.numMoves = numMoves
        genVoronoi.init_cache()
        self.points = np.zeros([2, numMoves, 2], dtype=np.int)
        self.points.fill(-1)
        self.colors = np.zeros([2, 3], dtype=np.uint8)  # Dummy data to run score script
        self.playerIdx = idx
        self.oppIdx = idx ^ 1
        self.board = np.zeros([1000, 1000], dtype=np.uint8)
        self.board.fill(-1)
        self.myMoves = 0
        self.oppMoves = 0

        """
Exemple #4
0
 def __init__(self, name, numMoves):
   Client.__init__(self, name)
   self.numMoves = numMoves
   genVoronoi.init_cache()
   self.points = np.zeros([2, numMoves, 2], dtype=np.int)
   self.points.fill(-1)
   self.colors = np.zeros([2, 3], dtype=np.uint8) #Dummy data to run score script
   self.myMoves = set([])
   self.oppMoves = set([])
   self.myIdx = 1
   self.oppIdx = 0
   self.myCnt = 0
   self.oppCnt = 0
   self.time = time.time()
   self.timeUsed = 0
   self.rng = np.random.RandomState()
Exemple #5
0
  def __init__(self, name, idx, numMoves):
    Client.__init__(self, name)
    self.numMoves = numMoves
    genVoronoi.init_cache()
    self.points = np.zeros([2, numMoves+1, 2], dtype=np.int)
    self.points.fill(-1)
    self.colors = np.zeros([2, 3], dtype=np.uint8) #Dummy data to run score script
    self.playerIdx = idx
    self.oppIdx = idx ^ 1
    # self.board = np.zeros([1000, 1000], dtype=np.uint8)
    self.board = np.zeros([1000, 1000])
    self.board.fill(-1)
    self.myMoves = 0
    self.oppMoves = 0

    self.max_time = datetime.timedelta(seconds=1)
    self.C = 1.4
    self.wins = {0: {}, 1: {}}
    self.plays = {0: {}, 1: {}}
    self.states = []

    '''
if __name__ == '__main__':
    num_players, num_moves = tuple(int(n) for n in raw_input().split())
    points = np.zeros([num_players, num_moves, 2], dtype=np.int)
    points.fill(-1)

    # Can put any garbage here. Not using this in the end.
    image = np.zeros([10, 10, 3], dtype=np.uint8)
    colors = np.zeros([num_players, 3], dtype=np.uint8)

    for p in xrange(num_players):
        player, actual_move_count = tuple(int(n) for n in raw_input().split())
        for m in xrange(actual_move_count):
            x, y = tuple(int(n) for n in raw_input().split())
            points[p, m, 0] = x
            points[p, m, 1] = y
    genVoronoi.init_cache()

    # Important to put GUIOn as false
    genVoronoi.generate_voronoi_diagram(num_players, num_moves, points, colors, image, 0, 1)

    scores, colors_index = genVoronoi.get_color_indices_and_scores(num_players, num_moves, points)
    for i in range(num_players):
        print scores[i]
    for i in range(1000):
        for j in range(1000):
            n = colors_index[i,j,0]
            print n,
            for k in range(1, n+1):
                print colors_index[i,j,k],
            print