Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you show me how to use iterative widening on a python project. The project is minecraft themed, and therefore movements and objects are based

Can you show me how to use iterative widening on a python project. The project is minecraft themed, and therefore movements and objects are based off it. Below I posted questions and answers I have so far. Please see comments marked TODO, I need help implementing those. Thanks.

Think about a recipe like making a stone pickaxe. Every possible planning state either satisfies its preconditions or doesn't. If this recipe were the only action, we could formulate the problem as a domain with just three abstract states---one without a pickaxe and without the needed supplies, one without a pickaxe and with the needed supplies, and one with a pickaxe (and it doesn't matter what else is in the state). If we had a domain with just two recipes (punch for wood and wood planks), what would be the abstract states in the sense used above? We can automate the intuition of (15) by transforming our states into combinations of propositions A proposition here is a logical fact entailed by the state; for example I have at least one piece of wood, I have at least two pieces of wood, I have at least one plank, and so on. Note that if we have two pieces of wood then we necessarily have one piece of wood as well! Iterated Widening is a planning algorithm which works by abstracting away differences between states and discarding states which are too similar to states which have been seen already in this iteration. Two states are similar if they share some number of propositions in common---so if the width measure is one, then when we have seen one state where we have at least one stick we subsequently ignore every other state we might find later with one or more sticks (we'll relax this a little to say "any sufficiently different state is worth exploring"---so if it has at least a few propositions that are unique with respect to all seen combinations of a given width, we will consider it). To regain completeness---to always find a solution if one exists---the size of the combinations of items considered in this similarity computation is gradually increased until a solution is found. Now we will define a Proposition of the form I have at least N of item INDEX Then we will define a function that takes in a state and propositionalizes it. E.g. If we have: items_by_index = ['wood', 'cobble', 'bench'] and our current state is: {'wood':5, 'bench':1} then propositionalized version should be a set of: Proposition(1,5), Proposition(1,4), Proposition(1,3), Proposition(1,2), Proposition(1,1), Proposition(3,1) i.e. we have at least 1,2,3,4, and 5 pieces of wood, and at least 1 bench. In [ ]: class Proposition(NamedTuple): item: int at_least: int def state_propositions(state: State) -> Set[Proposition]: propositions: Set[Proposition] = set() # TODO Do something for each item in state. Output all propositions entailed by the state's contents state_array = state.items items_by_index for index in range(len(items_by_index)): if(state_array[index] > 0): for at_least in range(state_array[index]): temp_tuple = Proposition(index,at_least+1) #print(temp_tuple) propositions.add(temp_tuple) return propositions

Now let's get the propositions from the recipes In [ ]: def recipe_to_propositions(recipe: Recipe) -> Set[Proposition]: propositions: Set[Proposition] = set() # TODO Do something with recipe.consumes, recipe.produces, and recipe.requires. # Emit, for this recipe, all the propositions entailed by the postconditions #and the _minimal_ set of propositions required for the preconditions #(i.e., don't need to output wood >= 2, wood >= 1, wood >= 0 if the recipe needs 2 wood.) consumes = recipe[1] requires = recipe[2] what_you_need = consumes+requires propositions = state_propositions(what_you_need) #print(propositions) return propositions

recipe_propositions = set() for r in recipes: recipe_propositions |= recipe_to_propositions(recipes[r]) #print(recipe_propositions)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago