Exemplo n.º 1
0
def main(WIDTH, HEIGHT, SEARCHERS, RESCUERS, targets = 5):
    manager = mp.Manager()
    searchm = manager.list()
    rescuem = manager.list()
    mazem   = manager.list()
    comq    = mp.Queue()

    m = Maze(WIDTH, HEIGHT, targets)
    mazem[:] = m.maze
    m.maze = mazem
    display = GNUI(WIDTH, HEIGHT, "Map")
    display2 = GNUI(WIDTH, HEIGHT, "Maze")

    display.update(m.getMaze(), [])
    display2.update(m.getMaze(), [])

    db = DatabaseAgent("[email protected]", "secret")
    db.width = WIDTH
    db.height = HEIGHT
    time.sleep(1)
    db.start()
    time.sleep(1)

    searchers = mp.Process(target=searchmanager, args=(SEARCHERS, searchm, comq, m))
    rescuers = mp.Process(target=rescuemanager, args=(RESCUERS, rescuem, comq, m))
    pf = mp.Process(target=pathmanager, args=(comq,))
    supervisor = mp.Process(target=supermanager, args=(comq,))

    pf.start()
    supervisor.start()
    searchers.start()
    rescuers.start()

    try:
        for i in range(100000):
            display.update(db.map.getMap(), list(searchm), list(rescuem))
            display2.update(m.getMaze(), list(searchm), list(rescuem))
            time.sleep(.1)
            if isReady(db.map.getMap(), rescuem):
                print("FINISHED!")
                break
    except KeyboardInterrupt:
        pass
    except Exception, ex:
        print traceback.format_exc()
Exemplo n.º 2
0
from maze.maze import Maze
from gnui.gnui import GNUI
from map.map import Map
from astar.astar import Astar

import numpy as np

import time

originalMap = Maze(32, 16)
display = GNUI(32, 16)
pathPlanner = Astar()

print originalMap.getData(1, 1)

print np.array(originalMap.getMaze())


display.update(originalMap.getMaze(), [(1, 1)])


time.sleep(2)
Exemplo n.º 3
0
from gnui.gnui import GNUI
from agents.search import SearchAgent
from agents.db import DatabaseAgent
from agents.mothership import Mothership
from agents.pathfinder import PathFinder
from agents.display import DisplayAgent
from agents.rescuer import RescueAgent

WIDTH  = 32
HEIGHT = 16
SEARCHERS = range(3)
RESCUERS  = range(3)

if __name__ == "__main__":
    m = Maze(WIDTH, HEIGHT)
    display = GNUI(WIDTH, HEIGHT)

    display.update(m.getMaze(), [])

    da = DisplayAgent("[email protected]", "secret")
    da.start()

    try:
        print "Starting searchers"
        search = [SearchAgent("search{}@127.0.0.1".format(i), "secret")
                for i in SEARCHERS]
        for s in search:
            s.setMaze(m)
        print "Starting rescuers"
        rescue = [RescueAgent("rescue{}@127.0.0.1".format(i), "secret")
                for i in RESCUERS]