7 self._shutable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
13 self._diced = [random.randint(0, 6), random.randint(0, 6)]
14 for rods in [ self._dice,
15 [ abs(self._dice[0] - self._dice[1]) ],
16 [ self._dice[0] + self._dice[1] ] ]:
17 if self._can_be_shut(rods):
18 self._options.append(rods)
21 if self._is_valid_option(rods):
23 self._shutable.remove(rod)
27 def is_game_over(self):
28 return len(self._shutable) == 0 or \
29 ( self._diced and len(self._options) == 0 )
31 def _can_be_shut(self, rods):
32 shutable = self._shutable.copy()
39 def _is_valid_option(self, rods):
40 for option in self._options:
41 if set(option) == set(rods):