# Cosmic Carnage — Data

来源：https://www.kaggle.com/competitions/cosmiccarnage/data

本地 Meta Kaggle 快照；不是本次实时页面。

# Dataset Description

####Since this is a Reinforcement Learning challenge, there are no downloadable data files. Instead, you must build the following 16 environments based exactly on these specifications

#Observation Array Mapping (16 Dimensions):
To properly slice or use the observation array in your `predict` function, here is the exact index layout of the 16 values provided by the judge:

* **[0, 1]:** Agent Position (X, Y)
* **[2, 3]:** Agent Velocity (X, Y)
* **[4, 5]:** Target/Goal Position (X, Y)
* **[6, 7]:** Enemy / Asteroid Position (X, Y)
* **[8, 9]:** Prey Velocity (X, Y)
* **[10, 11, 12, 13]:** State Flags (Used for level-specific mechanics like Fuel [10], Flare Timers [11], or Switch Unlocked status [10].Indices 12 and 13 are unused padding and will always output 0)
* **[14, 15]:** Agent's Previous Position (X, Y from the immediate last step, used for history)

# Level 1 : Inertia Navigation

**Name:** Inertia Navigation  

**Environment Design and Level Description:**  
The environment is a two-dimensional continuous space. The agent moves freely inside this space. Movement is not direct.  

The agent applies force, which affects velocity. The velocity gradually changes over time due to friction.  

The agent must navigate toward a randomly placed target and stop within its boundary. If the agent overshoots, it must correct its motion. The episode ends when the agent reaches the target or fails to reach it within the allowed duration.  

**Expected Outcome:**  
The agent learns smooth movement control and learns to slow down before reaching the target.  

**An Example:**  
If the agent starts at (0,0) and the target is at (5,0):

$$
v_{x} \leftarrow v_{x} + (a_{x} - \mu v_{x}) \Delta t
$$

$$
x \leftarrow x + v \Delta t
$$

Success occurs when:

$$
\text{distance to target} < 0.3
$$

**Specific Loss if Any:**  
Reward may be -0.01 per step and +10 on success.  

**Hint:**  
Penalizing velocity magnitude near the target can reduce overshooting.

---

# Level 2 : Toggle State

**Name:** Toggle State  

**Environment Design and Level Description:**  
The environment contains a switch region and a goal region. The goal region is initially inactive and provides no reward. The agent must first activate the switch region to unlock the goal. After activation, entering the goal completes the task. The agent must learn this correct order of actions.  

**Expected Outcome:**  
The agent learns to unlock the goal before attempting to complete it.  

**An Example:**  

$$
\text{is\_unlocked} \in \{0,1\}
$$

If the agent reaches the goal while:

$$
\text{is\_unlocked} = 0
$$

reward is zero.  

After entering the switch:

$$
\text{is\_unlocked} = 1
$$

and reaching the goal gives +20 reward.  

**Specific Loss if Any:**  
-0.01 per step and +20 on success.  

**Hint:**  
Ensure the unlocked state is included in observations.

---

# Level 3 : Static Projectile

**Name:** Static Projectile  

**Environment Design and Level Description:**  
The agent remains fixed at one location. A target appears at a random position. The agent selects a firing angle. A projectile is launched and follows gravity.  

The projectile either hits the target or lands on the ground. The agent must learn to choose the correct angle.  

**Expected Outcome:**  
The agent approximates the correct launch angle to hit the target.  

**An Example:**  
With initial speed 10 and gravity \( g = 9.8 \):

$$
x(t) = 10 \cos(\theta)t
$$

$$
y(t) = 10 \sin(\theta)t - \frac{1}{2} g t^{2}
$$

Reward = +30 if hit.  

**Specific Loss if Any:**  
Negative distance penalty if missed.  

**Hint:**  
Angles near \( \arctan(y/x) \) often perform well.

---

# Level 4 : Moving Target

**Name:** Moving Target  

**Environment Design and Level Description:**  
This level is similar to the previous one, but the target now moves continuously in a straight direction. The agent must consider the motion of the target before selecting the firing angle. The projectile still follows gravity. The challenge is to predict where the target will be.  

**Expected Outcome:**  
The agent learns interception instead of direct aiming.  

**An Example:**  
If target velocity is:

$$
(0.5, -0.2)
$$

the agent must compute a firing angle that meets the target's future position.  

**Specific Loss if Any:**  
Positive reward on hit, negative distance penalty on miss.  

**Hint:**  
Predict future target location before firing.

---

# Level 5 : Fuel Navigation

**Name:** Fuel Navigation  

**Environment Design and Level Description:**  
The agent navigates in a large map with limited fuel. Movement consumes fuel. Fuel stations are placed in the environment and refill fuel when reached. The agent must plan its movement carefully to reach the final goal without running out of fuel.  

**Expected Outcome:**  
The agent learns long-term resource planning.  

**An Example:**  
Fuel starts at 100. Each step reduces fuel by:

$$
1 + 0.1 \times \text{velocity}
$$

Reaching goal gives +50 reward.  

**Specific Loss if Any:**  
Failure if fuel reaches zero.  

**Hint:**  
Refueling strategy is important.

---

# Level 6 : The Ghost

**Name:** The Ghost  

**Environment Design and Level Description:**  
An enemy entity exists in the environment and continuously moves toward the agent's current position. The enemy movement is persistent and reactive. The agent must reach a goal while avoiding collision.  

**Expected Outcome:**  
The agent learns evasive movement strategies.  

**An Example:**  

$$
enemy \leftarrow enemy + 0.8 \times \frac{agent - enemy}{\|agent - enemy\|}
$$

Collision radius = 0.3.  

**Specific Loss if Any:**  
-100 on collision, +100 on success.  

**Hint:**  
Indirect paths can be safer.

---

# Level 7 : Gravity Well

**Name:** Gravity Well  

**Environment Design and Level Description:**  
A massive object at the center exerts gravitational pull.  

The closer the agent moves toward the center, the stronger the pull becomes. The agent must collect floating objects while avoiding falling into the center or drifting too far outward.  

**Expected Outcome:**  
The agent learns stable motion under nonlinear forces.  

**An Example:**  
Failure if:

$$
r < 1
$$

**Specific Loss if Any:**  

$$
F = \frac{G}{r^{2}}
$$

Penalty for moving too close to the center.  

**Hint:**  
Circular motion helps maintain stability.

---

# Level 8 : Noisy Navigation

**Name:** Noisy Navigation  

**Environment Design and Level Description:**  
The agent's observed position is noisy. The true position differs slightly from what the agent perceives. The agent must reach the goal despite imperfect information.  

**Expected Outcome:**  
The agent learns to filter noise across time.  

**An Example:**  

$$
X_{obs} = x + \mathcal{N}(0, 0.5)
$$

**Specific Loss if Any:**  
Standard goal-based reward.  

**Hint:**  
Memory-based models may improve performance.

---

# Level 9 : Predator-Prey

**Name:** Predator-Prey  

**Environment Design and Level Description:**  
Two agents exist: a predator and a prey. The prey attempts to escape by moving away. The predator must catch the prey.  

**Expected Outcome:**  
The predator learns strategic pursuit.  

**An Example:**  
Catching prey gives +200 reward.  

**Specific Loss if Any:**  
Small negative reward per step.  

**Hint:**  
Cornering is more effective than direct chasing.

---

# Level 10 : Sparse Maze

**Name:** Sparse Maze  

**Environment Design and Level Description:**  
The agent must navigate a long and complex maze. No reward is given during movement. Only reaching the exit provides reward.  

**Expected Outcome:**  
The agent learns exploration.  

**An Example:**  
Reward = 0 per step, +500 at exit.  

**Specific Loss if Any:**  
No intermediate reward.  

**Hint:**  
Curiosity-based exploration may help.

---

# Level 11 : Solar Laser Sweep

**Name:** Solar Laser Sweep  

**Environment Design and Level Description:**  
A rotating energy beam sweeps across the environment. Contact with the beam causes immediate failure. The agent must time its movement carefully to avoid the beam and reach the goal.  

**Expected Outcome:**  
The agent learns timing and pattern recognition.  

**An Example:**  

$$
\theta(t) = 0.1t
$$

Failure if:

$$
\text{distance to beam} < 0.2
$$

**Specific Loss if Any:**  
Large negative reward on collision.  

**Hint:**  
Observe periodic motion.

---

# Level 12 : Asteroid Field

**Name:** Asteroid Field  

**Environment Design and Level Description:**  
Asteroids enter from the boundary and move inward. The agent must navigate through these moving obstacles to reach the center safely.  

**Expected Outcome:**  
The agent learns dynamic obstacle avoidance.  

**An Example:**  
Asteroids spawn every 20 steps with speed 0.6.  

**Specific Loss if Any:**  
Failure on collision.  

**Hint:**  
Waiting may be safer than rushing.

---

# Level 13 : Adaptive Enemy

**Name:** Adaptive Enemy  

**Environment Design and Level Description:**  
An intelligent enemy predicts the agent's future movement based on recent motion history. It attempts interception rather than simple chasing.  

**Expected Outcome:**  
The agent learns unpredictability.  

**An Example:**  
Enemy predicts using last 5 states and moves at 0.95 of agent speed.  

**Specific Loss if Any:**  
Penalty for staying near boundary too long.  

**Hint:**  
Frequent direction change reduces predictability.

---

# Level 14 : Solar Flare with Fuel

**Name:** Solar Flare with Fuel  

**Environment Design and Level Description:**  
The environment periodically becomes hazardous except for a temporary safe zone. The agent also has limited fuel. The agent must plan movement carefully to survive flare cycles and reach the goal.  

**Expected Outcome:**  
The agent learns planning under combined constraints.  

**An Example:**  
Flare every 60 steps. Safe zone radius = 2. Fuel reduces by 1 per step.  

**Specific Loss if Any:**  
Failure if outside safe zone during flare.  

**Hint:**  
Move toward future safe areas early.

---

# Level 15 : Black Ice Pursuit

**Name:** Black Ice Pursuit  

**Environment Design and Level Description:**  
The environment contains regions with different friction properties. Some areas allow sliding with low resistance. A prey agent attempts to escape. The main agent must use terrain strategically to catch the prey.  

**Expected Outcome:**  
The agent exploits terrain physics.  

**An Example:**  
Normal friction \( \mu = 0.2 \), ice friction \( \mu = 0.01 \).  

**Specific Loss if Any:**  
Small per-step penalty.  

**Hint:**  
Low friction allows acceleration bursts.

---

# Level 16 : Curved Spacetime

**Name:** Curved Spacetime  

**Environment Design and Level Description:**  
The environment represents curved space inside a bounded region. Straight visual paths are not shortest paths. Distances expand rapidly near the boundary. The agent must reach a goal near the boundary without crossing it.  

**Expected Outcome:**  
The agent adapts to non-Euclidean geometry.  

**An Example:**  

$$
x^{2} + y^{2} < 1
$$

$$
d(u,v) = \operatorname{arcosh}\left(1 + \frac{2\|u - v\|^{2}}{(1 - \|u\|^{2})(1 - \|v\|^{2})}\right)
$$

**Specific Loss if Any:**  
Failure if crossing boundary.  

**Hint:**  
Euclidean intuition may fail.