Exemplo n.º 1
0
def tests():
    runTests(SlipstremingTester())
Exemplo n.º 2
0
        for (rider, path) in moves:
            self.animateMove(rider, path)

        sleep(self.clock * 2)
        for group in groups:
            sleep(self.clock * 2)
            self.animateGroup(group)

        for color in ["yellow", "red", "default"]:
            for rider in exhausted:
                self.display.setBackground(rider, color)
            self.display.update()
            sleep(self.clock)


    def animateMove(self, rider, path):
        for i in range(len(path) - 1):
            sleep(self.clock)
            self.display.move(rider, path[i], path[i + 1])
            self.display.update()

    def animateGroup(self, group):
        for (rider, end) in group:
            start = (end[0] - 1, end[1])
            self.display.move(rider, start, end)
        self.display.update()

import tkinter as tk
if __name__ == "__main__":
    runTests(AnimateTester(tk.Tk()))
Exemplo n.º 3
0
def tests():
    runTests(ExhaustTester())
Exemplo n.º 4
0
        self.move(1)
        assert_equals((0, 0), self.rider.position())


class Race():
    def __init__(self, length=100):
        self.obstacles = []
        self.length = length
        self.setAll("normal")

    def addRider(self, square, lane):
        self.obstacles.append((square, lane))

    def setAll(self, field):
        self.field = [field for i in range(self.length)]

    def set(self, field, square):
        self.field[square] = field

    def getRoadType(self, square):
        if square >= self.length:
            return "out"
        return self.field[square]

    def isFree(self, slot):
        return not slot in self.obstacles


if __name__ == "__main__":
    runTests(RiderTest())
Exemplo n.º 5
0
def tests():
    runTests(RaceTest())
Exemplo n.º 6
0
            RiderToken(3, 0),
            RiderToken(3, 1)
        ]
        obstacles = Obstacles(riders)
        assert_equals([(0, 0), (1, 1), (2, 0), (3, 2), (4, 0)],
                      findPath(obstacles, (0, 0), (4, 0)))


def findPath(obstacles, start, end):
    if start[0] == end[0]:
        return [end]

    next = findNextEmpty(obstacles, start, end)
    return [start] + findPath(obstacles, next, end)


def findNextEmpty(obstacles, start, end):
    nextSquare = start[0] + 1
    if nextSquare == end[0]:
        return end

    for lane in range(2):
        if obstacles.isFree((nextSquare, lane)):
            return nextSquare, lane

    return nextSquare, 2


if __name__ == "__main__":
    runTests(PathTester())
Exemplo n.º 7
0
def tests():
    runTests(TrackTest())
Exemplo n.º 8
0
def tests():
    runTests(PlayerTest())
Exemplo n.º 9
0
def runVisualTestsInWindow(testerClass):
    window = tk.Tk()
    runTests(testerClass(window))
    window.mainloop()
Exemplo n.º 10
0
def tests():
    runTests(CardsTester())