- Prof. Dancy's Site - Course Site -

Project 1: Simple agents in Malmo

Program screenshot

Obligatory...
READ THE DIRECTIONS!

This assignment will give you an opportunity to practice working with:

Problem Overview

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.)

Provided Files

Java 8

Getting Started with Malmo

Create a virtual Environment for the Python dependencies that you'll install for the project:

1. On any platform (Mac/Linux/Windows)

Create a virtual environment called malmoEnv

username$ python3 -m venv malmoEnv

2a. On a Mac/Linux machine, in the terminal

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

2b. On a Windows machine, in cmd

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

You should see the name of your env next to your command line in the terminal/shell now, this is how you know that your virtual environment is activated

Install the dependencies needed with pip

(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

Running the Malmo/Minecraft server

Running your agent

username$ python MainPhase1.py

Hint:

Phase 1: A simple agent

+ **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!!!

Receiving information from the server

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.

The goal for your agent: Collect all the items and "cook" a rabbit!

MalmoAgent class

Has at least three attributes (I've filled these in for you already :-))

Must have an update_inv method that updates the internal representation of the inventory based on a list supplied as an argument (see code for more detail)

Action class

Item Class


Phase 2: A simple agent with his own mind

- **Due:** Friday, 27-September, 11:55pm
- **Submission:** Submit your MalmoAgent.py and any files needed to run your version of the system to Google Classroom

For 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

Adding subclasses

Item agency rules

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

These rules should be applied left to right (slot 0 to slot n)

If an item gets modified, then we change the color of that item and any item near it according to the following Rules

If the item to the right of the modified item is the same type of item w/ a different variant, change the color of the item to the right to the color of the modified item
- 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
If the item is a RedFlower AND the color of that item is WHITE AND there is a RedFlower of another variant to the left of the RedFlower, change the color of the modified flower to BLUE
BEFORE: red_flower poppy WHITE red_flower dandelion WHITE (modified)
**AFTER: ** red_flower poppy WHITE red_flower dandelion BLUE
If the item is a RedFlower and the color of that item is WHITE, change the color to RED
BEFORE: red_flower dandelion WHITE (modified) Planks spruce WHITE
**AFTER: ** red_flower dandelion RED Planks spruce WHITE
If the item is a RedFlower and the color of that item is RED, change the color to WHITE
BEFORE: red_flower dandelion RED (modified) Planks birch BROWN
**AFTER: ** red_flower dandelion WHITE Planks birch BROWN

Output to log

As before all items should be output to the log. Now you should make sure you also include the created & modified attributes

Algorithm analysis

Do an algorithm analysis on your update_inv method in your MalmoAgent class

Creativity

Grading for phase 2

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

Appendix

WHAT SHOULD PHASE 1 EVEN LOOK LIKE?

wtf...