from random import randint
def apple(player):
"""Returns a new unoccupied position (tuple). Used to spawn a new `apple` at
that position. Microbit LED 5x5"""
Args:
player (list of tuples): List of player coordinates
Returns:
A new unoccupied position (tuple)
"""
apple = list((0,0))
# loop to get each tuple, as list
for i in range(0, len(player)):
p = list(player[i])
dot[0] = randint(0,4)
dot[1] = randint(0,4)
if x!= p:
return tuple((dot))
if i run the function with
player = [(0,0), (1,0), (2,0), (3,0), (4,0), (0,1), (1,1), (2,1), (3,1), (4,1), (0,2), (1,2), (2,2), (3,2), (4,2), (0,3), (1,3), (2,3), (3,3), (4,3), (0,4), (1,4), (2,4), (3,4),]
it should give me (4,4), but it doesent work. The whole function ignores my unequal statment :(
Aucun commentaire:
Enregistrer un commentaire