예제 #1
0
def maze_3():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	world = rrw.get_random_world(5, 5, num_agent=1, name='maze_3')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 15)]

	# Set Lander Location
	world.at[rrw.LANDER] = 15
	
	# Set Rover Location
	world.at['A1'] = 12
	world.visited['A1'] = set()
	world.visited['A1'].add(12)

	# Set Traps
	world.cost[4] = sys.maxint
	world.cost[7] = sys.maxint
	world.cost[8] = sys.maxint
	world.cost[13] = sys.maxint
	world.cost[18] = sys.maxint
	world.cost[17] = sys.maxint
	world.cost[22] = sys.maxint
	
	return world
예제 #2
0
def decompose_replan():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=1
	world = rrw.get_random_world(5, 6, num_agent=1)

	# Set Rover Location
	world.at['A1'] = 1
	world.visited['A1'] = set()
	world.visited['A1'].add(1)

	# Set Soil Locations
	world.at['S1'] = 14

	# Set Lander
	world.at[rrw.LANDER] = 28

	# Set Lab
	world.at[rrw.LAB] = 18

	# Set Goal
	world.goals['A1'] = [('get_a_soil_data', 'A1', 'S1')]

	# Add Uncertainties
	world.uncertainties = replan_decompose_1
	print_state(world)
	return world
예제 #3
0
def navigate_replan_team_6():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER='X'
	rrw.LAB = 'X'
	world = rrw.get_random_world(5, 9, num_agent=2, name='navigate_replan_team_6')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 27)]
	world.goals['A2'] = [('navigate', 'A2', 41)]

	# Set Lander
	world.at[rrw.LANDER] = 23
	world.at[rrw.LAB] = 23

	# Set Rover Locations
	world.at['A1'] = 19
	world.visited['A1'] = set()
	world.visited['A1'].add(19)
	world.at['A2'] = 5
	world.visited['A2'] = set()
	world.visited['A2'].add(5)

	traps = [23]
	for t in traps:
		world.cost[t] = sys.maxint

	world.uncertainties = replan_6_rand
	world.ID = "navigate_replan_team_6"
	return world
예제 #4
0
def navigate_replan_team_7():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER=''
	rrw.LAB = ''
	world = rrw.get_random_world(5, 9, num_agent=2, name='navigate_replan_team_7')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 45)]
	world.goals['A2'] = [('navigate', 'A2', 5)]

	# Set Lander
	world.at[rrw.LANDER] = 1
	world.at[rrw.LAB] = 1

	# Set Rover Locations
	world.at['A1'] = 37
	world.visited['A1'] = set()
	world.visited['A1'].add(37)
	world.at['A2'] = 41
	world.visited['A2'] = set()
	world.visited['A2'].add(41)

	world.cost[41] = 10

	world.uncertainties = replan_7_rand
	world.ID = "navigate_replan_team_7"
	return world
예제 #5
0
def navigate_replan_team_4p():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER='X'
	rrw.LAB = 'X'
	world = rrw.get_random_world(7, 7, num_agent=2, name='navigate_replan_team_4p')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 43)]
	world.goals['A2'] = [('navigate', 'A2', 49)]

	# Set Soil Location
	world.at['S1'] = 43
	world.at['S2'] = 49

	# Set Lander
	world.at[rrw.LANDER] = 15
	world.at[rrw.LAB] = 22

	# Set Rover Locations
	world.at['A1'] = 32
	world.visited['A1'] = set()
	world.visited['A1'].add(32)
	world.at['A2'] = 31
	world.visited['A2'] = set()
	world.visited['A2'].add(31)

	traps = [2, 4, 6, 38, 39, 15, 16, 19, 20, 22, 23, 26, 27, 29, 30, 33, 34, 36, 37, 40, 41]
	for t in traps:
		world.cost[t] = sys.maxint

	world.ID = "navigate_replan_team_4p"
	return world
예제 #6
0
def navigate_replan_team_5():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER='X'
	rrw.LAB = 'X'
	world = rrw.get_random_world(7, 7, num_agent=2, name='navigate_replan_team_5')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 43)]
	world.goals['A2'] = [('navigate', 'A2', 49)]

	# Set Soil Location
	world.at['S1'] = 43
	world.at['S2'] = 49

	# Set Lander
	world.at[rrw.LANDER] = 15
	world.at[rrw.LAB] = 22

	# Set Rover Locations
	world.at['A1'] = 1
	world.visited['A1'] = set()
	world.visited['A1'].add(1)
	world.at['A2'] = 31
	world.visited['A2'] = set()
	world.visited['A2'].add(31)

	traps = [15, 16, 19, 18, 22, 23, 26, 25, 29, 30, 33, 32, 36, 37, 40, 39]
	for t in traps:
		world.cost[t] = sys.maxint

	world.uncertainties = replan_5_rand
	world.ID = "navigate_replan_team_5"
	return world
예제 #7
0
def navigate_replan_team_3():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER='X'
	rrw.LAB = 'X'
	world = rrw.get_random_world(6, 6, num_agent=2, name='navigate_replan_team_3')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 31)]
	world.goals['A2'] = [('navigate', 'A2', 36)]

	# Set Soil Location
	world.at['S1'] = 31
	world.at['S2'] = 36

	# Set Lander
	world.at[rrw.LANDER] = 13
	world.at[rrw.LAB] = 19

	# Set Rover Locations
	world.at['A1'] = 1
	world.visited['A1'] = set()
	world.visited['A1'].add(1)
	world.at['A2'] = 21
	world.visited['A2'] = set()
	world.visited['A2'].add(21)

	traps = [7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 27, 28, 29]
	for t in traps:
		world.cost[t] = sys.maxint

	world.uncertainties = replan_3_rand
	world.ID = "navigate_replan_team_3"
	return world
예제 #8
0
def maze_5():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	world = rrw.get_random_world(num_agent=1, name='maze_5')

	# Set Lander Location
	world.at[rrw.LANDER] = 51
	
	# Set Rover Location
	world.at['A1'] = 67
	world.visited['A1'] = set()
	world.visited['A1'].add(67)

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 51)]

	# Set Traps
	world.cost[49] = sys.maxint
	world.cost[57] = sys.maxint
	world.cost[58] = sys.maxint
	world.cost[59] = sys.maxint
	world.cost[66] = sys.maxint
	world.cost[68] = sys.maxint
	world.cost[75] = sys.maxint
	world.cost[85] = sys.maxint
	world.cost[86] = sys.maxint
	world.cost[53] = sys.maxint

	return world
예제 #9
0
def maze_4():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	world = rrw.get_random_world(num_agent=1, name='maze_4')

	# Set Lander Location
	world.at[rrw.LANDER] = 78
	
	# Set Rover Location
	world.at['A1'] = 23
	world.visited['A1'] = set()
	world.visited['A1'].add(23)

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 78)]

	# Set Traps
	world.cost[43] = sys.maxint
	world.cost[34] = sys.maxint
	world.cost[25] = sys.maxint
	world.cost[37] = sys.maxint
	world.cost[47] = sys.maxint
	world.cost[57] = sys.maxint
	world.cost[67] = sys.maxint
	world.cost[77] = sys.maxint
	world.cost[87] = sys.maxint
	world.cost[97] = sys.maxint

	return world
예제 #10
0
def maze_0():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	world = rrw.get_random_world(3, 3, num_agent=1, name='maze_0')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 2)]

	# Set Lander Location
	world.at[rrw.LANDER] = 9
	
	# Set Rover Location
	world.at['A1'] = 9
	world.visited['A1'] = set()
	world.visited['A1'].add(9)
	
	return world
예제 #11
0
def dummy_world():
	rrw.NUM_ROCKS=4
	rrw.NUM_SOILS=4
	world = rrw.get_random_world(10, 10, num_agent=1)

	# Set Rover Locaitons
	world.at['A1'] = 85
	world.visited['A1'] = set()
	world.visited['A1'].add(85)
	world.at['A2'] = 85
	world.visited['A2'] = set()
	world.visited['A2'].add(85)

	# Set Soil Locations
	world.at['S1'] = 12
	world.at['S2'] = 34
	world.at['S3'] = 19
	world.at['S4'] = 37

	world.at['R1'] = 14
	world.at['R2'] = 32
	world.at['R3'] = 17
	world.at['R4'] = 39
	
	# Set Lander
	world.at[rrw.LANDER] = 62

	# Set Lab
	world.at[rrw.LAB] = 69

	# Set Goal
	world.goals['A1'] = [('get_soil_data', 'A1')]
	world.goals['A2'] = [('get_rock_data', 'A1')]

	# Set Traps
	world.cost[41] = sys.maxint
	world.cost[42] = sys.maxint
	world.cost[43] = sys.maxint
	world.cost[44] = sys.maxint
	world.cost[47] = sys.maxint
	world.cost[48] = sys.maxint
	world.cost[49] = sys.maxint
	world.cost[50] = sys.maxint

	return world
예제 #12
0
def navigate_replan():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	world = rrw.get_random_world(5, 5, num_agent=1, name='navigate_replan')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 15)]

	# Set Lander Location
	world.at[rrw.LANDER] = 15
	
	# Set Rover Location
	world.at['A1'] = 11
	world.visited['A1'] = set()
	world.visited['A1'].add(11)

	# Add uncertainties
	world.uncertainties = replan_1_rand
	return world
예제 #13
0
def test_exp_cost():
	rrw.NUM_ROCKS=0
	rrw.NUM_SOILS=0
	rrw.LANDER='X'
	rrw.LAB = 'X'
	world = rrw.get_random_world(3, 3, num_agent=2, name='test_exp_cost')

	# Set Goal
	world.goals['A1'] = [('navigate', 'A1', 2)]
	world.goals['A2'] = [('navigate', 'A2', 1)]

	# Set Rover Locations
	world.at['A1'] = 9
	world.visited['A1'] = set()
	world.visited['A1'].add(9)
	world.at['A2'] = 5
	world.visited['A2'] = set()
	world.visited['A2'].add(5)
	
	world.uncertainties = test_exp_cost_rand
	return world
예제 #14
0
def random(num_agent=2):
	return rrw.get_random_world(num_agent=num_agent, a_star=True)
예제 #15
0

def reconstruct_path(came_from, current):
    to_return = [current]
    while current in came_from:
        current = came_from[current]
        to_return.append(current)
    to_return.reverse()
    return to_return


def dist_between(current, neighbor):
    return 1


VERBOSE = True
if __name__ == "__main__":
    print("Testing a_star")
    world = random_rovers_world.get_random_world(10, 10)
    world.rand = False
    print("Random world: ")
    random_rovers_world.print_board(world)

    # pyhop.print_state(world)
    sink = random.choice(world.loc.keys())
    print("*** Navigating from {} to {} ***".format(world.at["A1"], sink))
    path = a_star(world, "A1", sink)
    print(path)
    for action in path:
        print("{}\t{}".format(action, world.cost_func(world, action)))