Esempio n. 1
0
def run(board, func):
    import cEngine as engine
    bag = model.Bag()
    rack = model.Rack()
    rack.fill(bag)
    score = 0
    while not rack.empty():
        moves = engine.generate_moves(board, rack.tiles)
        moves.sort(key=operator.attrgetter('score'), reverse=True)
        if not moves:
            break
        move = moves[0]
        print move
        board.do_move(move)
        rack.do_move(move)
        rack.fill(bag)
        score += move.score
        wx.CallAfter(func)
    print 'Score = %d' % score
Esempio n. 2
0
class Game(object):
    def __init__(self):
        self.board = Board()
        self.bag = Bag()
        self.players = [Player('Player %d' % (i + 1)) for i in xrange(2)]
        for player in self.players:
            player.rack.fill(self.bag)

if __name__ == '__main__':
    import cEngine as engine
    board = Board()
    bag = Bag()
    rack = Rack()
    rack.fill(bag)
    score = 0
    while not rack.empty():
        moves = engine.generate_moves(board, rack.tiles)
        moves.sort(key=lambda x:x.key)
        if not moves:
            break
        move = moves[0]
        print move
        board.do_move(move)
        rack.do_move(move)
        rack.fill(bag)
        score += move.score
    print
    print board
    print score