Build a Player Interface - Build a Player Interface

Tell us what’s happening:

Can someone give me a hint as to why my code is failing at step 11? I am pretty sure I am creating the tuple correctly

Your code so far

from abc import ABC, abstractmethod

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

    def make_move(self):
        move = random.choice(self.moves)
        #print(f"{move}")
        new_position = (self.position[0] + move[0], self.position[1] + move[1])
        self.position = new_position
        self.path.append(self.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/145.0.0.0 Safari/537.36

Challenge Information:

Build a Player Interface - Build a Player Interface

Hi @niladrideb

Tests related to the Player class will fail until the Pawn class becomes instantiable.

Happy coding

How about now? I have updated the code and it fails only steps 11-13.

Also what is the command for adding python snippets in the forum (like using ```py or something to include a section in your reply/comment to include python code)

from abc import ABC, abstractmethod

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

    def make_move(self):
        move = random.choice(self.moves)
        #print(f"{move}")
        new_position = (self.position[0] + move[0], self.position[1] + move[1])
        self.position = new_position
        self.path.append(self.position)
        return self.position
    
    @abstractmethod
    def level_up(self):
        pass

class Pawn(Player):
    def __init__(self):
        super().__init__()
        self.moves = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    
    def level_up(self):
        self.moves.append((1, 1))
        self.moves.append((1, -1))
        self.moves.append((-1, 1))
        self.moves.append((-1, -1))

removed by moderator

That is what I needed

Seriously how do we format sections of comments/replies in the forum to include Python code? There was a command with back ticks (like ``` py) or something that I can’t remember

Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Ok thanks but wasn’t there a shortcut to languages like that too (like three back ticks and then py or py followed by three back ticks to start writing text in a block in that respective programming language)?

Hi @niladrideb

Just type three backticks (```) then type or paste your code.

Happy coding