Forums

Using the robot class - implement robot battles.

Each player has 5 robots. People move the robots alternately, if the robots meet in one field, one takes part of the energy of the other (or all). When the robot's power runs out, a second robot automatically appears.

or implement a fully random battle

from typing import List, Tuple

class Robot:
    def __init__(self, name: str, place : List[int], start: Tuple[int, int] = (0,0), power: int = 9):
        self._name = name
        self._place = place
        self._start = start
        self._power = power

        # further assignments

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, value):
        if isinstance(value, str):
            self._name = value
        else:
            raise TypeError("must be a string")
    @property
    def place(self):
        return self._place

    @place.setter
    def place(self, value):
        if isinstance(value, list):
            self._start = value
        else:
            raise TypeErorr("must be a list")

    @property
    def start(self):
        return self._start

    @start.setter
    def start(self, value):
        if isinstance(value, tuple):
            self._start = value
        else:
            raise TypeErorr("must be a tuple")

    @property
    def power(self):
        return self._power

    @power.setter
    def power(self, value):
        if isinstance(value, int):
            self._start = value
        else:
            raise TypeErorr("must be a int")

    @property
    def check_power(self):
        if self._power <= 0:
            raise ValueError("No power")

    def up(self, value):
    #def left(self, value):
    #def right(self, value):
    #def down(self, value):

    def __str__(self):
        return "{} {} {}".format(self._name, self._place, self._power)

That's what I have so far........... And im stucked. Im just starting with python pls help

These are the forums for PythonAnywhere, an online Python development and hosting environment. While other users of our site might be able to help you out with problems you're having developing something on your own machine, you might have better luck getting an answer to a general programming problem at a programming Q&A site like Stack Overflow.