- Prof. Dancy's Site - Course Site -
There are 3 major projects in this course. For this project (as well as future projects), it is strongly recommended that you work with a partner. However, you will need to work with a different partner for each project.
Obligatory...
Your task is to write python files that will be used with supplied files so that an intelligent agent can roam a Minecraft environment, collect certain items, and use those items to cook a rabbit. (Don't worry non-meat eaters...this is just a digital rabbit in Minecraft world.)
MalmoAgent
objectinventory
represented as a python list
inventory
should be an Item
objectactions
represented as a dictionary that represents goal-action pairs
Action
objectsMainPhase1.py
either run this file in IDLE or enter python MainPhase1.py
in a terminal to run the programMalmoAgent.py
This is the file where you'll do all of your coding
def update_inv(self, inv_list):
exactly as it is provided)!actions.txt
This file should not be edited, you will read it in and process it using your MalmoAgent classThe Malmo/Minecraft software
This is the software that you'll need to run a Minecraft server on your machine.java -version
if you see java 8 or java 1.8, you should be fine.Create a virtual environment called malmoEnv
username$ python3 -m venv malmoEnv
Activate environment called testEnv
username$ source malmoEnv/bin/activate
(Do not do this until you want to not use your virtual environment anymore)
To deactivate any virtual environment you are in
$ deactivate
Activate environment called malmoEnv
malmoEnv\Scripts\activate.bat
(Do not do this until you want to not use your)
To deactivate any virtual environment you are in
deactivate
(malmoEnv) Labcomputer:project user1234$
which python
in terminal or where python
in cmd, you should see the path to your virutal environment listed first)(malmoENV) username$ python -m pip install gym lxml numpy pillow
Congrats, you should all you need installed! Now let's move on to getting the files you need
~/malmo/
)Minecraft
& Schemas
folders are located (the folders contained in the zip)Minecraft\launchClient.bat -port 9000 -env
username$ sh Minecraft/launchClient.sh -port 9000 -env
username$ module load java/1.8
username$ sh Minecraft/launchClient.sh -port 9000 -env
username$ python MainPhase1.py
Hint:
ctrl+c
ctrl+c
to restart/rebuild the Minecraft server!!!**Due:**
Wednesday, 18-September, 11:55pm**Submission:**
Submit your MalmoAgent.py and nothing else to Google Classroom**Group-Work:**
You can only work either in groups of 2 or individually. No groups of 3!!!The agent will receive periodic updates about its environment from the Server. It is up to you to make it so the Agent object can store that information internally and the main program can use the information as needed.
inventory
represented as a python list
inventory
should be an Item
objectgoals
represented as a dictionary that represents goal-action pairs
Action
objectsupdate_inv
method that updates the internal representation of the inventory based on a list supplied as an argument (see code for more detail)The agent must keep a log (external file named ItemLog.txt
) of the inventory and create a new line for the inventory when it changes (e.g., see the example video provided)
the inventory list provided as an argument is a list of Item objects that looks like the following:
[Item1, Item2, ...]
Must have a get_actions
method that gets the actions dictionary
Must have a get_item
method that gets a specified item given an input index (an integer)
Must have an in_inventory
method that checks whether there exists an item in the inventory with an input name (a string)
Must have a set_actions
method that takes in the action file, opens it, and assigns each goal-action pair to the actions
dictionary that you created
Constructor must read in a file that specifies the agents available actions (provided)
No duplicates should be in the inventory list, there should be one item per space in the inventory
- This means that if you have an inventory that simply has a new "size", you should not add a new Item to the list, but instead find a way to update the Item itself
'"move'
or '"turn'
)
'0"'
or '" + str(current_yaw_delta)'
)comm + " " + value
'"move 0"'
or '"move " + str(current_yaw_delta)'
)print(action)
or str(action)
update_inv
method**Due:**
Friday, 27-September, 11:55pm**Submission:**
Submit your MalmoAgent.py and any files needed to run your version of the system to Google ClassroomFor this phase, we are going to extend our item class so that as the agent picks up items, the attributes of those items change according to certain rules.
The items will have agency as they'll change as a function of the items adjacent to them.
You'll also need to create new children classes. Lastly, you'll complete an algorithm analysis on some of your code
We now want to add subclasses for our items
Planks
and RedFlower
class that are subclasses of your Item class
All items have a modified
and created
attribute that records the date and time of the attribute (what each attribute represents is self explanatory)
note that these rules mean that if you were using color as an attribute to test whether items were the same, you have to take that aspect of your test out
- Note that all of these rules modify the item and you must, in turn, change the `modified` attribute for that particular item
BEFORE: | Planks birch BROWN (modified) | Planks spruce WHITE |
---|---|---|
**AFTER: ** | Planks birch BROWN | Planks spruce BROWN |
BEFORE: | red_flower poppy WHITE | red_flower dandelion WHITE (modified) |
---|---|---|
**AFTER: ** | red_flower poppy WHITE | red_flower dandelion BLUE |
BEFORE: | red_flower dandelion WHITE (modified) | Planks spruce WHITE |
---|---|---|
**AFTER: ** | red_flower dandelion RED | Planks spruce WHITE |
BEFORE: | red_flower dandelion RED (modified) | Planks birch BROWN |
---|---|---|
**AFTER: ** | red_flower dandelion WHITE | Planks birch BROWN |
As before all items should be output to the log. Now you should make sure you also include the created & modified attributes
Do an algorithm analysis on your update_inv
method in your MalmoAgent
class
Each line shows its Big O analysis in update_inv()
, including every method that update_inv()
calls:
my_list[x+4] = w # O(1)
self.num = 2 # O(1)
Each loop shows the reps and the body and multiplies them:
for x in range (n-1): # n-1 reps
y = 2 # O(1)
# reps * body = (n-1) * 1 = O(n)
if/elif/else
show the overall Big O (the max of each branch). Each branch has a big O.
if x.isA(“Planks”): # O(1) test
list[y] = 4 # O(1)
# test + body = 1+1=O(1)
elif isinstance(x, RedFlower): # O(1) test
list[y] = x # O(1)
# test + test + body = O(1)
else:
for i in range(n): # n reps
print('it works') # O(1)
# reps * body = (n-1) * 1 = O(n)
# test + test + body = O(n)
# max(1,1,n) = O(n)
ALL methods/functions that update_inv()
calls have Big O analysis done.
Overall Big O analysis for update_inv()
, including the math
def update_inv(): # 1 + 1 = O(1)
my_list[v] = my_list[n] # O(1)
x = y # O(1)
Grade item | Points |
---|---|
GENERAL RUNNING AND OUTPUT (25 PTS) | |
Agent completes Task (cooks rabbit) | 10 |
ItemLog.txt is produced | 5 |
ItemLog.txt prints out items with at least the name, size, color, and variant attributes | 5 |
RULES (50 PTS) | |
The item list is still only printed out when an item is created or modified | 10 |
When an item is modified: | |
Rule1: If the item and a item to the right have the same name, but a different variant => the item to the right gets the color of the modified item | 10 |
Rule 2: If the item is a red_flower AND it has a color of white AND the item to the left is a red_flower of another variant => the modified item gets the color BLUE; -3 if it happens with any red_flower (regardless of color), -4 if it happens with a non-variant of red_flower to the left; -3 if it happens with any other item type | 10 |
Rule 3: If the item is a red_flower AND it has a color of WHITE => change the color of the item to RED | 10 |
Rule 4: If the item is a red_flower AND it has a color of RED => change the color of the item to WHITE | 10 |
CLASS DESIGN (11 PTS) | |
Created and Modified are represented in the Item(s) class design | 3 |
Information hiding principles are preserved (attributes are not directly accessed from outside the class) | 3 |
General class design - some of the complexity of the update_inv function is reduced via methods in the class | 5 |
ALGORITHM ANALYSIS (14 PTS) | |
Each line shows its Big O Analysis in update_inv(), including every method update_inv() calls. | 2 |
Each loop shows the reps and the body and multiplies them | 3 |
if/elif/else show the overall Big O() (this includes a max of each branch). Each branch has a Big O | 3 |
Overall O answer for update_inv, including the math | 3 |
All functions that update_inv calls have O analysis done | 3 |
Program Crashes | -5 |