예제 #1
0
 def mvleft(self):
     if (globally.matrix[self.x][self.y - 4] == ' '):
         self.y -= 4
         Movement.move('\u001b[0;32mB\u001b[0m', self.x, self.y)
         if (globally.matrix[self.x][self.y +
                                     4] == '\u001b[0;32mB\u001b[0m'):
             Clear.clear(self.x, self.y + 4)
예제 #2
0
 def mvup(self):
     if (globally.matrix[self.x - 2][self.y] == ' '):
         self.x -= 2
         Movement.move('\u001b[0;32mB\u001b[0m', self.x, self.y)
         if (globally.matrix[self.x +
                             2][self.y] == '\u001b[0;32mB\u001b[0m'):
             Clear.clear(self.x + 2, self.y)
예제 #3
0
    def __init__(self, what, fromObj, toObj):
        # arguments (x,y,z)
        self.args = []

        # preconditions
        self.pre = []

        # add list
        self.add = []

        # delete list
        self.delete = []

        self.name = "Move"

        # the first argument (what is being moved); x in Move(x,y,z)
        self.what = what

        # the second argument (from where is it being moved); y in Move(x,y,z)
        self.fromObj = fromObj

        # the third argument (where is it being moved to); z in Move(x,y,z)
        self.toObj = toObj

        self.pre.append(On(what, fromObj))
        self.pre.append(Clear(what))
        self.pre.append(Clear(toObj))

        self.add.append(On(what, toObj))
        self.add.append(Clear(fromObj))

        self.delete.append(On(what, fromObj))
        self.delete.append(Clear(toObj))
예제 #4
0
    def __init__(self,what,fromObj,floorObj):
        # arguments (b,y)
        self.args = []

        # preconditions
        self.pre = []

        # add list
        self.add = []

        # delete list
        self.delete = []

        self.name = "MoveToFloor"

        # the first argument (what is being moved); b in MoveToFloor(b,y)
        self.what = what

        # the second argument (from where is it being moved); y in MoveToFloor(b,y)
        self.fromObj = fromObj

        # the floor object
        self.floorObj = floorObj

        self.pre.append(On(what,fromObj))
        self.pre.append(Clear(what))

        self.add.append(On(what,floorObj))
        self.add.append(Clear(fromObj))

        self.delete.append(On(what,fromObj))
예제 #5
0
 def flame(self):
     Clear.clear(self.x, self.y)
     if (globally.matrix[self.x][self.y - 4] == '\u001b[0;33me\u001b[0m'):
         Clear.clear(self.x, self.y - 4)
     if (globally.matrix[self.x][self.y + 4] == '\u001b[0;33me\u001b[0m'):
         Clear.clear(self.x, self.y + 4)
     if (globally.matrix[self.x - 2][self.y] == '\u001b[0;33me\u001b[0m'):
         Clear.clear(self.x - 2, self.y)
     if (globally.matrix[self.x + 2][self.y] == '\u001b[0;33me\u001b[0m'):
         Clear.clear(self.x + 2, self.y)
예제 #6
0
 def mv(self):
     if self.direction == 1:
         if globally.matrix[self.x][self.y + 4] == ' ' or globally.matrix[self.x][self.y + 4] == '\u001b[0;32mB\u001b[0m' or globally.matrix[self.x][self.y + 4] == '\u001b[0;36m0\u001b[0m':
             self.y += 4
             Movement.move('\u001b[0;31mE\u001b[0m', self.x, self.y)
             Clear.clear(self.x, self.y - 4)
         else:
             Enemy.rmv(self)
     elif self.direction == 2:
         if globally.matrix[self.x][self.y - 4] == ' ' or globally.matrix[self.x][self.y - 4] == '\u001b[0;32mB\u001b[0m' or globally.matrix[self.x][self.y - 4] == '\u001b[0;36m0\u001b[0m':
             self.y -= 4
             Movement.move('\u001b[0;31mE\u001b[0m', self.x, self.y)
             Clear.clear(self.x, self.y + 4)
         else:
             Enemy.rmv(self)
     elif self.direction == 3:
         if globally.matrix[self.x - 2][self.y] == ' ' or globally.matrix[self.x - 2][self.y] == '\u001b[0;32mB\u001b[0m' or globally.matrix[self.x - 2][self.y] == '\u001b[0;36m0\u001b[0m':
             self.x -= 2
             Movement.move('\u001b[0;31mE\u001b[0m', self.x, self.y)
             Clear.clear(self.x + 2, self.y)
         else:
             Enemy.rmv(self)
     else:
         if globally.matrix[self.x + 2][self.y] == ' ' or globally.matrix[self.x + 2][self.y] == '\u001b[0;32mB\u001b[0m' or globally.matrix[self.x + 2][self.y] == '\u001b[0;36m0\u001b[0m':
             self.x += 2
             Movement.move('\u001b[0;31mE\u001b[0m', self.x, self.y)
             Clear.clear(self.x - 2, self.y)
         else:
             Enemy.rmv(self)
예제 #7
0
    def __init__(self):
        self.name = "BlocksWorld"

        # define objects
        A = Object("A")
        B = Object("B")
        C = Object("C")
        floor = Object("Fl")
        blocks = [A, B, C]

        self.A = A
        self.B = B
        self.C = C
        self.floor = floor

        # define goal (C on B on A on floor)
        goalLiterals = []
        goalLiterals.append(On(A, floor))
        goalLiterals.append(On(B, A))
        goalLiterals.append(On(C, B))

        self.goal = State(goalLiterals)

        # define initial state (C on B, B on floor, A on floor)
        initStateLiterals = []
        initStateLiterals.append(On(C, B))
        initStateLiterals.append(On(B, floor))
        initStateLiterals.append(On(A, floor))
        initStateLiterals.append(Clear(A))
        initStateLiterals.append(Clear(C))

        self.initialState = State(initStateLiterals)

        # create actions
        self.actions = []
        for b in blocks:
            for bprime in blocks:
                if not (bprime == b):
                    # move to floor
                    self.actions.append(MoveToFloor(b, bprime, floor))
                    # move from floor
                    self.actions.append(Move(b, floor, bprime))

                for bpp in blocks:
                    if not (bprime == b) and not (bprime
                                                  == bpp) and not (b == bpp):
                        self.actions.append(Move(b, bprime, bpp))
예제 #8
0
파일: crond.py 프로젝트: simyy/dinglive
def task(env):
    print green('-> 开始抓取 %s' % current())
    count = SPIDER_COUNT.get(env)
    for key, crawler in crawlers.items():
        try:
            crawler.run(count)
        except Exception as e:
            print "crawl error", key, e
    Clear().run(env)
    print green('-> 完成抓取 %s' % current())
예제 #9
0
def sched_task(env):
    print green('-> 开始抓取 %s' % current())
    period = SPIDER_PERIOD.get(env)
    count = SPIDER_COUNT.get(env)
    for key, crawler in crawlers.items():
        try:
            crawler.run(count)
        except Exception as e:
            print "crawl error", key, e
    Clear().run(env)
    print green('-> 完成抓取 %s' % current())
    schedule.enter(period, 0, sched_task, (env, ))
    def generate_maze(self):
        maze = [[0 for x in range(self.length)] for x in range(self.length)]

        for row in range(self.length):
            for column in range(self.length):
                maze[row][column] = Wall(row, column)

        maze[0][0] = Clear(0, 0)
        maze[0][1] = Clear(0, 1)
        maze[0][2] = Clear(0, 2)
        maze[1][2] = Clear(1, 2)
        maze[2][2] = Clear(2, 2)
        maze[3][2] = Clear(3, 2)
        maze[3][3] = Goal(3, 3)

        return maze
예제 #11
0
def enter():
    global guy, bg, wall, map, death, portal, clear, deathcount

    deathcount = 0
    guy = Guy()
    portal = Portal()
    map = create_map()
    bg = Background()
    death = Death()

    clear = Clear()
    guy.set_bg(bg)
    bg.set_guy(guy)
    death.set_bg(bg)
    death.set_guy(guy)
    clear.set_bg(bg)
    clear.set_guy(guy)
    portal.set_bg(bg)
    for wall in map:
        wall.set_bg(bg)
예제 #12
0
 def __init__(self,toPath,filetype):
     Clear.__init__(self,toPath,filetype)
     self.pattern = compile(r'\.zip$')
예제 #13
0
 def setUp(self):
     self.test_clear = Clear(0, 0)
예제 #14
0
    args = parser.parse_args()
    operation = args.operation
    app_folder = args.app_folder or os.getcwd()

    # 需要考虑安装路径被用户删除,前台界面下发卸载指令的操作
    # if not os.path.exists(app_folder):
    #     print app_folder, 'is not exits'
    #     sys.exit(1)
        
    cur_path = os.path.dirname(os.path.abspath(sys.argv[0]))
    APP_BASE = os.path.dirname(os.path.dirname(cur_path))
    if operation == 'monitor':
        from monitor import Monitor
        m = Monitor(APP_BASE, install_path=app_folder, debug=args.debug)
        m.run()
    elif operation == 'clear':
        from clear import Clear
        c = Clear(APP_BASE, install_path=app_folder, debug=args.debug)
        c.run()
    else:
        if operation == 'init':
            code, msg = init_pkg(app_folder, args)
            if code:
                print msg
            else:
                easyops = pkgOp(APP_BASE, install_path=app_folder)
                easyops.main('which')
        else:
            easyops = pkgOp(APP_BASE, install_path=app_folder, debug=args.debug)
            easyops.main(operation)
예제 #15
0
    if floor > 0 and floor % x == 0:
        colCount += 2
        rowCount += 2
        #TODO: startCell and endCell should be shifted.  Goal being to keep the center point in the center rather than growing towards, for eg, the north-east
        endCell = (endCell[0] + 1, endCell[1] + 1)

    grid = Grid(colCount, rowCount)

    if floor > 0:
        startCell = endCell

    Algorithm.On(grid, startCell)

    #TODO: endCell should be a dead end from the current grid, preferably far away from startCell
    endCell = grid.randomDeadend().coord()
    while endCell == startCell:
        endCell = grid.randomDeadend().coord()

    grid[startCell].content = "S"
    grid[endCell].content = "E"

    Clear()
    print("Floor " + str(floor))
    print(grid)
    grid.Draw("output/Floor_" + str(floor))

    i = input("Press enter for next floor, or type 'exit' to quit: ")
    if i == "exit":
        run = False

    floor += 1