Beispiel #1
0
    def main():
        print("Starting global program")

        #check to make sure we have the right number of arguments
        if len(sys.argv) != 4:
            print("Invalid arguments!")
            print(
                "usage: mouse.py PRODUCTION_MODE MAZE_TEXT_FILE MAZE_IMAGE_FILE"
            )
            print("PRODUCTION: 0=development, 1=production")
            print(
                "in development file paths are based off the local directory")
            print(
                "in production file paths are based off /home/core/code/mazeFiles"
            )
            return
        production = int(sys.argv[1])
        text_file = sys.argv[2]
        image_file = sys.argv[3]

        #Create the global map we will use to check for movement paths
        our_map = mapGlobal.mapGlobal(33, 33)
        if production == 0:
            input_file = text_file
        else:
            input_file = "/home/core/code/mazeFiles/" + text_file
        our_map.initialize_map(input_file)

        #create four mice and set
        mouseCount = 0
        mouse1 = mouseNodeServer.mouse(1, 1, 2, our_map, 1)
        mouse2 = mouseNodeServer.mouse(31, 1, 1, our_map, 2)
        mouse3 = mouseNodeServer.mouse(1, 31, 3, our_map, 3)
        mouse4 = mouseNodeServer.mouse(31, 31, 0, our_map, 4)

        #startup core
        core = coreStartup.coreStartupObj(production, 0, image_file)
        core.start()

        #set up a socket and listen for mice movement requests
        server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_socket.bind(("0.0.0.0", 1337))
        server_socket.listen(5)
        while 1:
            mouseCount += 1
            if mouseCount == 1:
                mouse = mouse1
            elif mouseCount == 2:
                mouse = mouse2
            elif mouseCount == 3:
                mouse = mouse3
            else:
                mouse = mouse4
            (client_socket, address) = server_socket.accept()
            clientThread = globalClientThread.globalClientThread(
                client_socket, mouse)
            print("Client oject created")
            clientThread.start()
            print("Client object started")
Beispiel #2
0
 def __init__(self, xstart, ystart, dstart, number, globalConnector):
     self.posStack = []
     self.xloc = xstart
     self.yloc = ystart
     self.dir = dstart
     #starting direction
     #0 up
     #1 right
     #2 down
     #3 left
     self.number = number
     self.globalConnector = globalConnector
     self.my_map = mapGlobal.mapGlobal(33, 33)
Beispiel #3
0
def main():
    solution = False
    #create map
    our_map = mapGlobal.mapGlobal(33,33)

    #initialize map with text file
    input_file = "file.txt"
    our_map.initialize_map(input_file)

    second_map = our_map
    second_map.getNode(5,10).options = 7

    our_map.blend_map(second_map)
    our_map.print_map()