(self)
| 64 | |
| 65 | class Snake: |
| 66 | def __init__(self): |
| 67 | self.length = random.randint(MIN_SNAKE_LENGTH, MAX_SNAKE_LENGTH) |
| 68 | |
| 69 | coloration = random.choice(['solid', 'stripe', 'random']) |
| 70 | if coloration == 'solid': |
| 71 | self.colors = [random.choice(ALL_COLORS)] * self.length |
| 72 | elif coloration == 'stripe': |
| 73 | color1 = random.choice(ALL_COLORS) |
| 74 | color2 = random.choice(ALL_COLORS) |
| 75 | self.colors = [] |
| 76 | for i in range(self.length): |
| 77 | self.colors.append((color1, color2)[i % 2]) |
| 78 | elif coloration == 'random': |
| 79 | self.colors = [] |
| 80 | for i in range(self.length): |
| 81 | self.colors.append(random.choice(ALL_COLORS)) |
| 82 | |
| 83 | x = random.randint(0, WIDTH - 1) |
| 84 | y = random.randint(0, HEIGHT - 1) |
| 85 | self.body = [] |
| 86 | for i in range(self.length): |
| 87 | self.body.append((x, y)) |
| 88 | x, y = getRandomNeighbor(x, y) |
| 89 | |
| 90 | def moveNorth(self): |
| 91 | headx, heady = self.body[0] |
nothing calls this directly
no test coverage detected