def __init__(self) -> None:
        self._action_spec = array_spec.BoundedArraySpec(shape=(),
                                                        dtype=np.int32,
                                                        minimum=0,
                                                        maximum=3,
                                                        name="action")
        self._observation_spec = array_spec.BoundedArraySpec(
            shape=(8, ), dtype=np.float32, minimum=0, name="observation")

        self.circuit = circuit.fromJSON("circuits/BONK_CIRCUIT.json")
        self.agent = Car(self.circuit.startingPoint.x,
                         self.circuit.startingPoint.y)
        self._episode_ended = False
        self.discount = 0.9925
        self.stepCountingCounter = 0

        self.viewer = None
              [1070, 90]]
indexSpot = [
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0
]
blindSpotPoints = [Vector2D(i[0], i[1]) for i in blindSpots]

circuit_checkpoints = []
for i, checkpoint in enumerate(checkpoints):
    circuit_checkpoints.append([])
    for point in checkpoint:
        circuit_checkpoints[i].append(Vector2D(point[0], point[1]))

dir_path = os.path.dirname(os.path.realpath(__file__))
path = dir_path + '/' + 'circuits/BONK_CIRCUIT_GACHECKPOINTS.json'
circ = circuit.fromJSON(path,
                        window=window.get_size(),
                        method="fromFullPoints")
world = World(50,
              circ.startingPoint.x,
              circ.startingPoint.y,
              window=window.get_size())
world.addBlindSpot(blindSpotPoints, indexSpot)
batch = pyglet.graphics.Batch()

running = True

key = pyglet.window.key
key_handler = key.KeyStateHandler()

checkpointNumber = len(circuit_checkpoints)
Beispiel #3
0
#    circuit_checkpoints.append([])
#    for point in checkpoint:
#        circuit_checkpoints[i].append(Vector2D(point[0],point[1]))

dir_path = os.path.dirname(os.path.realpath(__file__))
path = dir_path + '/' + 'circuits/SIGMA_FALLS_GA.json'

batch = pyglet.graphics.Batch()
topper = pyglet.graphics.OrderedGroup(3)
foreground = pyglet.graphics.OrderedGroup(2)
background = pyglet.graphics.OrderedGroup(1)
circuitLayer = pyglet.graphics.OrderedGroup(0)

running = True

circ = circuit.fromJSON(path, window=[1920,1080], method="fromFullPoints")

car = Car(circ.startingPoint.x,circ.startingPoint.y)
car.position = circ.startingPoint

backGround = pyglet.sprite.Sprite(circ.background, x=0,y=0, batch=batch, group=circuitLayer)
foreGround = pyglet.sprite.Sprite(circ.backgroundTopper, x=0,y=0, batch=batch, group=topper)

key = pyglet.window.key
key_handler = key.KeyStateHandler()
speed = 1.0

@window.event
def on_close():
    running = False