Ejemplo n.º 1
0
def init_scene(agent):
    boats = []
    boats.append(
        buildBoat(os.path.join(os.path.dirname(__file__), "BoatConfig",
                               "dqnboat_training.txt"), {
                                   'pos': (100, 200),
                                   'angle': -90
                               },
                  targets=[(800, 200)],
                  name="Titanic"))
    boats.append(
        buildBoat(os.path.join(os.path.dirname(__file__), "BoatConfig",
                               "dqnboat_training.txt"), {
                                   'pos': (800, 200),
                                   'angle': 90
                               },
                  targets=[(100, 200)],
                  name="CDG"))
    for b in boats:
        b.boatList = boats
        b.set_agent(agent)
    return boats
Ejemplo n.º 2
0
from BoatConstructor import buildBoat
from SimDisplay import SimDisplay

# Display sim
display = True

# Environment definition
targets = [(800, 200), (200, 200)]
boats = []
boat1 = buildBoat("BoatConfig/LocTRBoat.txt",
                  {'pos': (100, 200), 'angle': -90}, [targets[0]], name="Titanic")
boat2 = buildBoat("BoatConfig/LocTRBoat.txt",
                  {'pos': (800, 200), 'angle': 90}, [targets[1]], name="CDG")
boats.append(boat1)
boats.append(boat2)
boat1.boatList = boats
boat1.boatList = boats

if display:
    scale_factor = 1 / 1
    screen_size = [900, 600]
    boatFile = "Images/boat2.png"
    disp = SimDisplay(screen_size, boatFile)
    disp.initDisplay(boats, scale_factor, targets)
    disp.runSim(1000)
Ejemplo n.º 3
0
# Display sim
display = True
nbBoat = 10
screen_rect = (100, 100, 700, 400)

# Environment definition
targets = []
boats = []
pos = evenly_spaced_points_on_edge(screen_rect, nbBoat)
for i in range(nbBoat):
    targets.append(random_point_on_edge(screen_rect))
    boats.append(
        buildBoat("BoatConfig/VectBoat.txt", {
            'pos': pos[i],
            'angle': np.random.random() * 360
        }, [pos[(i + nbBoat // 2) % nbBoat]],
                  name=str(i)))
for b in boats:
    b.boatList = boats

if display:
    from SimDisplay import SimDisplay
    scale_factor = 1 / 1
    screen_size = [900, 600]
    boatFile = "Images/boat2.png"
    disp = SimDisplay(screen_size, boatFile)
    disp.initDisplay(boats, scale_factor, pos)
    disp.runSim(100)
else:
    t = time.time()
Ejemplo n.º 4
0
from BoatConstructor import buildBoat
from SimDisplay import SimDisplay

# Display sim
display = True

# Environment definition
targets = [(800, 200), (200, 200), (500, 200)]
boats = []
boat1 = buildBoat("BoatConfig/LocTRBoat.txt", {
    'pos': (200, 300),
    'angle': -90,
    'gear': 3
}, [targets[0]],
                  name="Titanic")
boat2 = buildBoat("BoatConfig/LocTRBoat.txt", {
    'pos': (800, 300),
    'angle': 90
}, [targets[1]],
                  name="CDG")
boat3 = buildBoat("BoatConfig/LocTRBoat.txt", {'pos': (500, 600)},
                  [targets[2]],
                  name="USS Thomas")
boats.append(boat1)
boats.append(boat2)
boats.append(boat3)
boat1.boatList = boats
boat2.boatList = boats
boat3.boatList = boats

if display:
Ejemplo n.º 5
0
from SimDisplay import SimDisplay
from Utils import random_point_on_edge
import numpy as np

# Display sim
display = True
nbBoat = 8
scale_factor = 1 / 1
screen_size = [900, 600]
screen_rect = (100, 100, 700, 400)

# Environment definition
targets = []
boats = []
for i in range(nbBoat):
    targets.append(random_point_on_edge(screen_rect))
    boats.append(
        buildBoat("BoatConfig/LocTRBoat.txt", {
            'pos': random_point_on_edge(screen_rect),
            'angle': int(np.random.random() * 360 - 180)
        }, [targets[i]],
                  name=str(i)))
for b in boats:
    b.boatList = boats

if display:
    boatFile = "Images/boat2.png"
    disp = SimDisplay(screen_size, boatFile)
    disp.initDisplay(boats, scale_factor, targets)
    disp.runSim(1000)