示例#1
0
import bot_movement as bm

try:
    bm.up()
except:
    print "cleaning ptest.py"
finally:
    print "done execution"
示例#2
0
def anomaly_find_path(cx, cy):
    global mapp
    print mapp
    rows = len(mapp)
    columns = len(mapp[0])
    mapp[cx][cy] = 0
    while True:
        if cx - 1 >= 0:
            if (mapp[cx - 1][cy] == 3 or mapp[cx - 1][cy] == 5):
                bm.up()
                cx -= 1
                callibrate(rows, columns, cx, cy, mapp)
                if mapp[cx][cy] == 5:
                    mapp[cx][cy] = 0
                    print "up"
                    break
                else:
                    mapp[cx][cy] = 0
                    print "up"
                    continue
        if cx + 1 < rows:
            if (mapp[cx + 1][cy] == 3 or mapp[cx + 1][cy] == 5):
                bm.down()
                cx += 1
                callibrate(rows, columns, cx, cy, mapp)
                if mapp[cx][cy] == 5:
                    mapp[cx][cy] = 0
                    print "down"
                    break
                else:
                    mapp[cx][cy] = 0
                    print "down"
                    continue
        if cy + 1 < columns:
            if (mapp[cx][cy + 1] == 3 or mapp[cx][cy + 1] == 5):
                bm.right()
                cy += 1
                callibrate(rows, columns, cx, cy, mapp)
                if mapp[cx][cy] == 5:
                    mapp[cx][cy] = 0
                    print "right"
                    break
                else:
                    mapp[cx][cy] = 0
                    print "right"
                    continue
        if cy - 1 >= 0:
            if (mapp[cx][cy - 1] == 3 or mapp[cx][cy - 1] == 5):
                bm.left()
                cy -= 1
                callibrate(rows, columns, cx, cy, mapp)
                if mapp[cx][cy] == 5:
                    mapp[cx][cy] = 0
                    print "left"
                    break
                else:
                    mapp[cx][cy] = 0
                    print "left"
                    continue
    else:
        return "you have reached your destination"  # put a different kind of result
示例#3
0
文件: ptest.py 项目: Autonomi/NLMS
import bot_movement as bm

try:
	bm.up()
except:
        print "cleaning ptest.py"
finally:
        print "done execution"
示例#4
0
def find_path(cx, cy):
	global mapp
	print mapp
	rows = len(mapp)
        columns = len(mapp[0])
	if mapp[cx][cy] == 5:
		return True
	else:
		mapp[cx][cy] = 0
	while True:
		if cx-1 >= 0:
			if (mapp[cx-1][cy] == 3 or mapp[cx-1][cy] == 5):
				if bm.up() == True:
                                        cx -= 1
                                        callibrate(rows, columns, cx, cy, mapp)
                                        if mapp[cx][cy] == 5:
                                            mapp[cx][cy] = 0
                                            print "up"
                                            break
                                        else:
                                            mapp[cx][cy] = 0
                                            print "up"
                                            continue
                                else:
                                        return False
                                
		if cx+1 < rows:
			if (mapp[cx+1][cy] == 3 or mapp[cx+1][cy] == 5):
				if bm.down() == True:
                                        cx += 1
                                        callibrate(rows, columns, cx, cy, mapp)
                                        if mapp[cx][cy] == 5:
                                            mapp[cx][cy] = 0
                                            print "down"
                                            break
                                        else:
                                            mapp[cx][cy] = 0
                                            print "down"
                                            continue
                                else:
                                        return False
                                
		if cy+1 < columns:
			if (mapp[cx][cy+1] == 3 or mapp[cx][cy+1] == 5):
				if bm.right() == True:
                                        cy += 1
                                        callibrate(rows, columns, cx, cy, mapp)
                                        if mapp[cx][cy] == 5:
                                            mapp[cx][cy] = 0
                                            print "right"
                                            break
                                        else:
                                            mapp[cx][cy] = 0
                                            print "right"
                                            continue
                                else:
                                        return False
                                
		if cy-1 >=0:
			if (mapp[cx][cy-1] == 3 or mapp[cx][cy-1] == 5):
				if bm.left() == True:
                                        cy -= 1
                                        callibrate(rows, columns, cx, cy, mapp)
                                        if mapp[cx][cy] == 5:
                                            mapp[cx][cy] = 0
                                            print "left"
                                            break
                                        else:
                                            mapp[cx][cy] = 0
                                            print "left"
                                            continue
                                else:
                                        return False
	else:
		return True
示例#5
0
def first_find_path(cx, cy):
	global mapp
	print mapp
	rows = len(mapp)
        columns = len(mapp[0])
	mapp[cx][cy] = 0
	while True:
		if cx-1 >= 0:
			if (mapp[cx-1][cy] == 3 or mapp[cx-1][cy] == 5):
				bm.up()
				cx -= 1
				callibrate(rows, columns, cx, cy, mapp)
				if mapp[cx][cy] == 5:
                                    mapp[cx][cy] = 0
				    print "up"
                                    break
                                else:
                                    mapp[cx][cy] = 0
                                    print "up"
                                    continue
		if cx+1 < rows:
			if (mapp[cx+1][cy] == 3 or mapp[cx+1][cy] == 5):
				bm.down()
				cx += 1
				callibrate(rows, columns, cx, cy, mapp)
				if mapp[cx][cy] == 5:
                                    mapp[cx][cy] = 0
				    print "down"
                                    break
                                else:
                                    mapp[cx][cy] = 0
                                    print "down"
                                    continue
		if cy+1 < columns:
			if (mapp[cx][cy+1] == 3 or mapp[cx][cy+1] == 5):
				bm.right()
				cy += 1
				callibrate(rows, columns, cx, cy, mapp)
				if mapp[cx][cy] == 5:
                                    mapp[cx][cy] = 0
				    print "right"
                                    break
                                else:
                                    mapp[cx][cy] = 0
                                    print "right"
                                    continue
		if cy-1 >=0:
			if (mapp[cx][cy-1] == 3 or mapp[cx][cy-1] == 5):
				bm.left()
				cy -= 1
				callibrate(rows, columns, cx, cy, mapp)
				if mapp[cx][cy] == 5:
                                    mapp[cx][cy] = 0
				    print "left"
                                    break
                                else:
                                    mapp[cx][cy] = 0
                                    print "left"
                                    continue
	else:
		return "you have reached your destination" # put a different kind of result
示例#6
0
def find_path(cx, cy):
    global mapp
    print mapp
    rows = len(mapp)
    columns = len(mapp[0])
    if mapp[cx][cy] == 5:
        return True
    else:
        mapp[cx][cy] = 0
    while True:
        if cx - 1 >= 0:
            if (mapp[cx - 1][cy] == 3 or mapp[cx - 1][cy] == 5):
                if bm.up() == True:
                    cx -= 1
                    callibrate(rows, columns, cx, cy, mapp)
                    if mapp[cx][cy] == 5:
                        mapp[cx][cy] = 0
                        print "up"
                        break
                    else:
                        mapp[cx][cy] = 0
                        print "up"
                        continue
                else:
                    return False

        if cx + 1 < rows:
            if (mapp[cx + 1][cy] == 3 or mapp[cx + 1][cy] == 5):
                if bm.down() == True:
                    cx += 1
                    callibrate(rows, columns, cx, cy, mapp)
                    if mapp[cx][cy] == 5:
                        mapp[cx][cy] = 0
                        print "down"
                        break
                    else:
                        mapp[cx][cy] = 0
                        print "down"
                        continue
                else:
                    return False

        if cy + 1 < columns:
            if (mapp[cx][cy + 1] == 3 or mapp[cx][cy + 1] == 5):
                if bm.right() == True:
                    cy += 1
                    callibrate(rows, columns, cx, cy, mapp)
                    if mapp[cx][cy] == 5:
                        mapp[cx][cy] = 0
                        print "right"
                        break
                    else:
                        mapp[cx][cy] = 0
                        print "right"
                        continue
                else:
                    return False

        if cy - 1 >= 0:
            if (mapp[cx][cy - 1] == 3 or mapp[cx][cy - 1] == 5):
                if bm.left() == True:
                    cy -= 1
                    callibrate(rows, columns, cx, cy, mapp)
                    if mapp[cx][cy] == 5:
                        mapp[cx][cy] = 0
                        print "left"
                        break
                    else:
                        mapp[cx][cy] = 0
                        print "left"
                        continue
                else:
                    return False
    else:
        return True