Example #1
0
    def setCell(self,
                x,
                y,
                typeCell,
                obs=False,
                delivery=False,
                isFree=False,
                marked=None,
                info=''):
        e = WorldObject.WorldObject(x, y, typeCell, obs, delivery, isFree,
                                    marked, info)
        world.objects[x][y] = e

        utils.setRect(x, y, self.surface, self.color)
Example #2
0
    def __init__(self, world_map, surface):
        super().__init__()
        self.buildings = []
        pos = 0
        for col, tiles in enumerate(world_map):
            for row, tile in enumerate(tiles):
                if tile == 'b':
                    pos+=1
                    b = type('obj', (object,), {'pos': pos, 'x': row, 'y': col, 'delivery': False})
                    #b = Building(pos, row, col, False)
                    self.buildings.append(b)

                    e = WorldObject.WorldObject(row, col, 'building', False, False, False, None, '')
                    world.objects[row][col] = e
                    utils.setRect(row, col, surface, constants.DARKSLATEGRAY)
Example #3
0
    def __init__(self, world_map, surface):
        super().__init__()
        self.walls = []

        for col, tiles in enumerate(world_map):
            for row, tile in enumerate(tiles):
                if tile == 'w':
                    w = type('obj', (object, ), {'x': row, 'y': col})
                    self.walls.append(w)

                    e = WorldObject.WorldObject(row, col, 'wall', False, False,
                                                False, None, '')

                    world.objects[row][col] = e
                    utils.setRect(row, col, surface, constants.BLACK)
Example #4
0
 def Execute(self):
     results = self._rayQuery.Execute()
     rv = []
     for entry in results:
         if entry.SceneObject is not None:
             if isinstance(entry.SceneObject.UserData, Multiverse.Base.ObjectNode):
                 existingObject = WorldObject._GetExistingWorldObject(entry.SceneObject.UserData)
                 rv.append(RaySceneQueryResult(entry.Distance, existingObject, None))
             else:
                 ClientAPI.Write("Skipping non-multiverse object: %s" % entry.SceneObject.UserData)
                 # ignore this object
                 pass
         elif entry.worldFragment is not None:
             rv.append(RaySceneQueryResult(entry.Distance, None, entry.worldFragment.SingleIntersection))
     return rv
 def Execute(self):
     results = self._rayQuery.Execute()
     rv = []
     for entry in results:
         if entry.SceneObject is not None:
             if isinstance(entry.SceneObject.UserData,
                           Multiverse.Base.ObjectNode):
                 existingObject = WorldObject._GetExistingWorldObject(
                     entry.SceneObject.UserData)
                 rv.append(
                     RaySceneQueryResult(entry.Distance, existingObject,
                                         None))
             else:
                 ClientAPI.Write("Skipping non-multiverse object: %s" %
                                 entry.SceneObject.UserData)
                 # ignore this object
                 pass
         elif entry.worldFragment is not None:
             rv.append(
                 RaySceneQueryResult(
                     entry.Distance, None,
                     entry.worldFragment.SingleIntersection))
     return rv
Example #6
0
def GetPlayerObject():
    if _worldManager.Player != None:
        return WorldObject._GetExistingWorldObject(_worldManager.Player)
    else:
        return None
Example #7
0
def GetPlayerObject():
    if _worldManager.Player != None:
        return WorldObject._GetExistingWorldObject(_worldManager.Player)
    else:
        return None
Example #8
0
#!/usr/bin/env python3
import time
import random
from WorldObject import *
from WorldRenderer import *
from ScanObject import *
from Scan import *
from brains.EcoDisasterBrain import EcoDisasterBrain
import numpy as np

# TODO add log class, use that for output instead of print

robot = WorldObject(object_type=ObjectType.ROBOT, x=1.1, y=0.4, radius=0.1125)
robot_brain = EcoDisasterBrain(robot=robot, speed=0.3, turning_speed=45)

TheWorld = [[WorldObject(object_type=ObjectType.UNKNOWN, x=i, y=j, radius=0.1, color='black') for i in range(25)] for j in range(25)]

TheWorld[11][4] = robot
TheWorld[5][21] = WorldObject(object_type=ObjectType.ZONE, x=0.5, y=2.1, radius=0.1, color='blue')
TheWorld[7][21] = WorldObject(object_type=ObjectType.ZONE, x=0.7, y=2.1, radius=0.1, color='blue')
TheWorld[9][21] = WorldObject(object_type=ObjectType.ZONE, x=0.9, y=2.1, radius=0.1, color='blue')
TheWorld[13][21] = WorldObject(object_type=ObjectType.ZONE, x=1.3, y=2.1, radius=0.1, color='darkgreen')
TheWorld[15][21] = WorldObject(object_type=ObjectType.ZONE, x=1.5, y=2.1, radius=0.1, color='darkgreen')
TheWorld[17][21] = WorldObject(object_type=ObjectType.ZONE, x=1.7, y=2.1, radius=0.1, color='darkgreen')

print(np.matrix(TheWorld))

# TheWorld[]
#
# # The walls around the arena, see https://i0.wp.com/piwars.org/wp-content/uploads/2019/07/EcoDisasterPlanLabelled.png
# # for walls, the radius is half the length