Download the code and create an environment with following packages:
pip install pygame
pip install numpy
- The simulator provides an environment as an N x N Tileworld, in which there are randomly generated walls as obstacles and randomly generated coins as rewards.
- No agents can walk through the walls or get outside of the Tileworld.
- Once generated, the walls are fixed through the game.
- Each coin will have a lifespan ranging from "1-5" seconds, and a value ranging from 1-9.
- If an agent successfully hits/collects a coin, it will get +coin.value (line 53 and 57 in
main.py
). - If two agents collide, each of the agents will get -100 (line 66 and 67 in
main.py
). - The goal for an agent is to compete with the other agent in order to make its own utility as high as possible. (line 76 or 77 in
main.py
).
- You only need to implement your design in
compAgent.py
, complete the two classesplayerA()
andplayerB()
. - In
main.py
, four cases are listed. One may change the case number to switch between cases. Initially "Case 0" is set (case = 0
). - Play with case 0 to get familiar with the environment and the rules.
Then try the rest cases:
- Case 1: two random agents in the Tileworld. This serves as the base case, in order that one may make comparison with their design.
- Case 2: one random agent and one self-designed agent in the Tileworld. Please design a rational agnet (at least it should be better than Case 1).
- Case 3: two self-designed agents in the Tileworld. Please design two competitive agents (at least it should work better than Case 2, i.e., playerB's utility should be better than playerA).
- You may change some variables in
env.py
, to experience different setup of the Tileworld (e.g. largerN
for a larger world, differentSEED
for a world with different obstacles and/or coin sets). - In
compAgent.py
, pay attention to theupdate
function (line 51). The simulator will automatically update the information of the world as time goes (all objects are saved inall_sprites
and updated, line 47 inmain.py
, although you didn't explicitly callupdate
of your player classes). At each time step, you can callpygame.time.get_ticks()
(line 56) to get the current time (note: pygame time works in millisecond), callget_coin_data()
to access current information of the coins on the map, callget_wall_data()
to get current information of the walls (You don't need to call it every time since the walls are fixed once generated).