Exemple #1
0
 def __init__(self, mouse):
     self.mouse = mouse
     self.isVisited = [[0 for i in range(self.mouse.mazeMap.width)]
                       for j in range(self.mouse.mazeMap.height)]
     self.isVisited[self.mouse.x][self.mouse.y] = 1
     self.network = NetworkInterface()
     self.network.initSocket()
Exemple #2
0
    def __init__(self, mouse, initPoint, num_bots):
        # print("INTIA")

        self.mouse = mouse
        self.num_bots = num_bots
        self.isVisited = [[0 for i in range(self.mouse.mazeMap.width)]
                          for j in range(self.mouse.mazeMap.height)]
        # print(self.isVisited)
        self.isVisited[self.mouse.x][self.mouse.y] = 1
        # print("made it past initialization")
        for i in range(1, self.num_bots + 1):
            if initPoint[str(i)] == (self.mouse.x, self.mouse.y):
                self.whoami = i
            self.neighbors_states[i] = {
                'robot': i,
                'x': initPoint[str(i)][0],
                'y': initPoint[str(i)][1],
                'direction': 'UP'
            }
            # print(self.neighbors_states[i])
            # print("whoami:%s"%self.whoami)

        self.starting_pose = initPoint[str(self.whoami)]
        self.network = NetworkInterface()
        self.network.initSocket()
        self.network.startReceiveThread()
	def __init__(self, id, \
				coordinate=[50, 50], \
				direction=[1, 1], \
				step_size=1, \
				robot_radius=10, \
				energy_level=100, \
				go_interval=0.5, \
				num_robots=1, \
				controlNet='172.16.0.254'):
		self.local_id = id
		self.local_coordinate = coordinate
		self.local_direction = direction
		self.local_step_size = step_size
		self.local_robot_radius = robot_radius
		self.local_energy_level = energy_level
		self.local_go_interval = go_interval
		self.global_num_robots = num_robots
		self.controlNet = controlNet
		self.network = NetworkInterface(port=19999)
		self.network.initSocket()
		self.network.startReceiveThread()
		# Debugger tool:
		self.local_debugger = COREDebuggerVirtual((controlNet, 12888), path='/home/rick/Documents/research/SRSS/log', filename=str(self.local_id))
		self.time_start = time.time()
		self.local_debugger.log_local('Start.', tag='Status')
		self.local_debugger.send_to_monitor({'id': self.local_id, 'coordinate': self.local_coordinate}, tag='Status')
	def __init__(self, id, \
				coordinate=[50, 50], \
				direction=[1, 1], \
				step_size=1, \
				go_interval=0.5, \
				num_robots=1, \
				controlNet='172.16.0.254'):
		self.local_id = id
		self.local_coordinate = coordinate
		self.local_direction = direction
		self.local_step_size = step_size
		self.local_go_interval = go_interval
		self.global_num_robots = num_robots
		self.controlNet = controlNet
		self.network = NetworkInterface(port=19999)
		self.network.initSocket()
		self.network.startReceiveThread()
		# Debugger tool:
		self.local_debugger = COREDebuggerVirtual((controlNet, 12888))
Exemple #5
0
 def __init__(self, mouse, numNeighbors, initLocations):
     self.weights = [0, 0, 0, 0]
     self.centroid = [-1, -1]
     self.groupCentroid = [-1, -1]
     self.stop = [-1, -1]
     self.mouse = mouse
     self.leader = self.mouse.id
     self.numNeighbors = numNeighbors
     for key, value in initLocations.items():
         if key is not self.mouse.id:
             self.neighborInfo[key] = {
                 'x': value[0],
                 'y': value[1],
                 'direction': 'UP'
             }
             if key < self.leader: self.leader = key
     self.visited = [[-1 for i in range(self.mouse.mazeMap.width)]
                     for j in range(self.mouse.mazeMap.height)]
     self.visited[self.mouse.x][self.mouse.y] = self.mouse.id
     self.network = NetworkInterface()
     self.network.initSocket()
     self.network.startReceiveThread()
Exemple #6
0
#!/usr/bin/env python3
from task import NetworkInterface
from map import Map
from map_painter import MapPainter

mazeMap = Map(8, 8, 40, 40)
mapPainter = MapPainter(mazeMap)
mapPainter.createWindow()
mapPainter.drawMap()
lastCell = mazeMap.getCell(2, 7)
mapPainter.putRobotInCell(lastCell, 'yellow')

network = NetworkInterface()
network.initSocket()
network.startReceiveThread()

while True:
    recvData = network.retrieveData()
    if recvData:
        otherMap = recvData
        cell = mazeMap.getCell(otherMap['x'], otherMap['y'])
        if otherMap['up']: mazeMap.setCellUpAsWall(cell)
        if otherMap['down']: mazeMap.setCellDownAsWall(cell)
        if otherMap['left']: mazeMap.setCellLeftAsWall(cell)
        if otherMap['right']: mazeMap.setCellRightAsWall(cell)
        mapPainter.drawCell(cell, 'grey')
        mapPainter.putRobotInCell(lastCell)
        mapPainter.putRobotInCell(cell, 'yellow')
        lastCell = cell
        print('(' + str(otherMap['x']) + ', ' + str(otherMap['y']) + ')  up:' +
              str(otherMap['up']) + ',down:' + str(otherMap['down']) +