Build a Player Interface - Build a Player Interface

Tell us what’s happening:

I am getting stuck at Test 11. I have seen many other people asking for help on this same test. None of the clues provided to them help. I have tested my code and it runs PERFECTLY. I created a Player, made several moves and the position is updated as expected. I have even added a test to check that the Player moves attribute is not empty before selecting a random move.

Test code:

p = Player()
p.make_move() # No moves available. Returns with position not updated.
p.moves = p.moves + [(1,3), (4,6)]
p.make_move()
p.make_move()
p.make_move()

Your code so far

from abc import ABC, abstractmethod
import random

class Player(ABC):
    def __init__(self):
        self.moves = list()
        self.position = (0, 0)
        self.path = [self.position]

    def make_move(self):
        if self.moves:
            move = random.choice(self.moves)
            new_position = (self.position[0] + move[0], self.position[1] + move[1])
            self.position = new_position
        return self.position

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0

Challenge Information:

Build a Player Interface - Build a Player Interface

Problem solved. It magically disappeared. I think it disappeared after I coded the Pawn class. Maybe this note at the very end of the Use Cases offers a clue: “Standard library modules should be imported without using aliases. Tests related to the Player class will fail until the Pawn class becomes instantiable.” That is nuts. Seems like it would be nice to test progress while coding (I adhere to the “code a little, test a little”) philosophy.

1 Like

it would be, yes, but you can’t do anything with abstract classes until they are inherithed, so there is that note, this is an issue to bring up with whomever created abstract classes

1 Like

I agree that you can’t do anything with an abstract class until inherited, but at the point where my code was “failing”, it was not truly abstract. It did not yet have any abstract methods. It only inherited from ABC, but that did not disallow it from being instantiated on its own.

this being a lab. the tests will run on all the code, always, so we can’t have tests that work when the class is empty with no methods, those will fail when you fill in the methods in the class, and you would never be able to pass the lab

once you create the abstract method you will always get this error
image

and that would make the test that instantiate the Player class always fail, so the tests on the Player class rely on Pawn existing

1 Like