Navigating the Hex Universe

Project:

A Reinforcement Learning Exploration with Unity ML-Agents 

DigitalFUTURES 2022 Workshop

Date:

2022.7

Team:

Biru Cao, Maoran Sun

Keywords:

Reinforcement Learning, Unity

This project applies reinforcement learning (RL) in the vision of a meta-universe. A robot is placed in the space, which consists of debris in hexagons. Its goal is to avoid traps while reaching the targets. By training a reinforcement learning agent in a grid-based environment using Unity’s ML-Agents toolkit, the agent navigates a grid populated with targets and traps. 

Game Environment

portfolio_240101.jpg

Action: move to one of the six juxtaposed hexagons or stay still
Reward: reach target(+1), reach trap(-1), visit a location not the first time( 0.01), pass the boundary(-0.1)

The environment consists of a grid with a specified number of rows and columns. The agent, targets, and traps are placed on this grid. The positions of the targets and traps are randomly generated at the start of each episode to ensure a diverse range of experiences for the agent. The agent is trained using a policy that is updated based on the rewards it receives. The training process involves balancing exploration (trying out new actions) and exploitation (choosing the best-known actions). The agent’s performance is evaluated based on the mean reward over a series of episodes.

9

Agent and environment

Training

The project aims to demonstrate the capabilities of reinforcement learning in game-like environments and explore strategies for reward shaping and policy optimization.

RL framework

Reinforcement learning framework

The agent is rewarded based on its actions: The agent receives a reward of +1 for reaching a target. The agent is penalized with a reward of -0.5 for reaching a trap. The agent is penalized with a reward of -0.01 for staying still. The agent receives a reward of +0.01 for moving closer to a target. 
The current reward structure tries to encourage more exploration so the agent don’t stay still to avoid the traps. In multiple rounds of tests, we increased the penalty for staying still and provide a small reward for every step taken towards a target.  

1target_1trap_fixed
target1_trap1_fixed

1 Target and 1 trap with fixed locations

1target_1trap
target1_trap1

1 Target and 1 trap

2targets_2traps
target2_trap2

2 Targets and 2 traps

Results

10

Reinforcement learning framework

Agent behaviors