Example #1
0
    def nextmove(self):
        #assert self.game.next == self.side
        if self.game.next != self.side:
            # opponent did pass
            self.game.switch_user()

        actions = self.game.get_possible_actions()
        if not actions:
            self.game.switch_user()
            return ('PASS', None, None)
        pos, color = montecarlo_ucb(actions, self.game)
        self.game.print_map()
        print pos, color
        pos, color = input('(pos, color)>>>')
        put(self.game, pos, color)
        self.game.switch_user()
        x, y = pos
        if color == self.side:
            ret = ('MOVE', (y, x), self.side_s)
        else:
            ret = ('MOVE', (y, x), 'WHITE')

        if VERBOSE:
            print 'nextmove called, returns:', ret
            self.game.print_map()
        return ret
Example #2
0
 def move(self, pos, color):
     assert self.game.next == self.opposite
     if color == 'WHITE':
         color = reverse(self.opposite)
     elif color == 'PASS':
         if VERBOSE:
             print 'move called:', pos, color
             self.game.print_map()
         self.game.switch_user()
         return
     else:
         color = self.opposite
     y, x = pos
     put(self.game, (x, y), color)
     if VERBOSE:
         print 'move called:', pos, color
         self.game.print_map()
     self.game.switch_user()
     if OUTPUT_IMAGE:
         renderer.draw(self.game.map)