Logo Search packages:      
Sourcecode: uligo version File versions  Download package

def uligo::App::setup (   self,
  n = '',
  changeOri = 1,
  co = None,
  ori = None 

Set up initial position of problem. 

Definition at line 425 of file uligo.py.

00425                                                               :
        """ Set up initial position of problem. """

        self.noMovesMade = 0

        # Choose colors and orientation (i.e. mirror/rotate the board) randomly

        if co is None: co = randint(0,1)
        if ori is None: ori = randint(0,7)

        if changeOri:
            self.invertColor = co * self.options.allowInvertColorVar.get()
            self.orientation = ori * self.options.allowRotatingVar.get()

        if self.invertColor: bColor, wColor = 'W', 'B'
        else:                bColor, wColor = 'B', 'W'

        # display problem name
        pbmName = ''
        if c.currentNode().has_key('GN'): pbmName = c.currentNode()['GN'][0][:15]
        if n: pbmName = pbmName + n
        # look for first relevant node
        while not (c.currentNode().has_key('AB') or c.currentNode().has_key('AW') \
                   or c.currentNode().has_key('B') or c.currentNode().has_key('W')): c.next()

        # and put stones on the board
        while not (c.currentNode().has_key('B') or c.currentNode().has_key('W')):
            if c.currentNode().has_key('AB'):
                for x in c.currentNode()['AB']:
                    self.board.play(self.convCoord(x, self.orientation), bColor)
            if c.currentNode().has_key('AW'):
                for x in c.currentNode()['AW']:
                    self.board.play(self.convCoord(x, self.orientation), wColor)

        if c.currentNode().has_key('B'):   self.board.currentColor = self.inputColor = bColor
        elif c.currentNode().has_key('W'): self.board.currentColor = self.inputColor = wColor
        self.cursor = c

    def nextMove(self, p):

Generated by  Doxygen 1.6.0   Back to index