Esempio n. 1
0
File: move.py Progetto: bgnori/bglib
  def guess_your_multiple_partial_undoes(self, src, dest, b=None, available=None, mv=None):
    if b is None:
      b = self.board
    if available is None:
      available = AvailableToPlay(rolled=None, copy_src=self.available)
    if mv is None:
      mv = Move()

    assert isinstance(src, int)
    assert isinstance(dest, int)
    assert(src < dest)

    for pm in self.move.find(src):
      inverse = PartialMove(die=pm.die, src=pm.dest, dest=pm.src, is_hitting=pm.is_hitting)
      mv.append(inverse)
      if inverse.dest == dest:
        return mv
      elif inverse.dest < dest:
        b.make_partial_move(inverse)
        available.add(inverse.die)
        return self.guess_your_multiple_partial_undoes(inverse.dest, dest, b, available, mv)
      else:
        assert(inverse.dest > dest)
        return self.Error('Overrun, bad (src, dest)=(%s, %s)'%
                    (util.move_ntop(src), util.move_ntop(dest)))
    return self.Error('Not found, (src, dest)=(%s, %s)'%
                (util.move_ntop(src), util.move_ntop(dest)))
Esempio n. 2
0
 def t022_test(self):
   self.assertEqual(util.move_ntop(-1), 'off')
Esempio n. 3
0
 def t020_test(self):
   self.assertEqual(util.move_ntop(0), '1')
Esempio n. 4
0
 def t018_test(self):
   self.assertEqual(util.move_ntop(24), 'bar')
Esempio n. 5
0
 def t028_test(self):
   try: 
     util.move_ntop(25)
     self.assert_(False)
   except ValueError:
     pass
Esempio n. 6
0
File: move.py Progetto: bgnori/bglib
 def __str__(self):
   s = "%s/%s"%(util.move_ntop(self.src), util.move_ntop(self.dest))
   if self.is_hitting:
     s += '*'
   return s