Builder-Neekhil commited on
Commit
2da101c
Β·
verified Β·
1 Parent(s): aac21c2

Update README with v2 adaptive features

Browse files
Files changed (1) hide show
  1. README.md +63 -78
README.md CHANGED
@@ -1,123 +1,108 @@
1
- # πŸ›Έ Orbit Wars - Kaggle Competition Agent
2
 
3
- **Competition:** [Orbit Wars](https://www.kaggle.com/competitions/orbit-wars) ($50,000 prize pool)
4
- **Deadline:** June 23, 2026
 
5
 
6
  ## Overview
7
 
8
- This is a highly competitive rule-based agent for the Orbit Wars Kaggle competition β€” a real-time strategy game where 2 or 4 AI agents compete to conquer planets orbiting a central sun in continuous 2D space.
9
 
10
- ### Game Rules Summary
11
- - **Board:** 100Γ—100 continuous 2D space with a sun at center (radius 10)
12
- - **Planets:** Produce 1-5 ships/turn; inner ones orbit the sun, outer ones are static
13
- - **Fleets:** Speed scales logarithmically with size; crossing the sun destroys them
14
- - **Comets:** Spawn at steps 50/150/250/350/450 as temporary extra planets
15
- - **Win condition:** Most total ships (on planets + in flight) at step 500, or last player standing
16
-
17
- ### Agent Actions
18
- Each turn, the agent returns: `[[from_planet_id, angle, num_ships], ...]`
19
 
20
  ## Architecture
21
 
22
- This agent is a **composite super-agent** that combines the best strategies from the top-rated public agents, enhanced with novel features:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- ### Base: tamrazov-starwars (LB 1224)
25
- - Gang-up attacks on weakened planets
26
- - Weakest enemy targeting (focus fire in 4P)
27
- - Elimination missions with high bonus
28
- - Aggressive endgame total-war mode
29
- - Exposed planet exploitation
30
 
31
- ### Enhancements from ykhnkf (#1 LB)
32
- - **Hostile reinforcement prediction**: When attacking enemy planets, estimates how many reinforcement ships the enemy could send from nearby planets within a time window after our arrival. This adds a safety margin to fleet sizes, preventing failed captures due to enemy counterattacks.
33
- - Higher finishing hostile send bonus (5 vs 3)
 
 
 
 
 
34
 
35
- ### Enhancements from pascal (v14)
36
- - **4-source swarm attacks**: Can coordinate 4 separate fleets to arrive simultaneously at a heavily defended target (40+ ships)
37
- - Expanded multi-source consideration (top 8 vs top 5)
38
 
39
- ### Parameter Tuning
40
- - Extended simulation horizon (130 vs 110) for better long-range planning
41
- - Earlier late-game transition (70 remaining turns)
42
- - Stronger elimination drive (bonus 55 vs 28)
43
- - More aggressive enemy weakness detection (threshold 110 vs 45-60)
44
- - Enhanced proactive defense ratios for 4-player games
 
 
45
 
46
  ## Performance
47
 
48
- Local testing results:
49
  | Opponent | Win Rate | Notes |
50
  |----------|----------|-------|
51
- | Random | 100% | Eliminated by step ~180 |
52
- | Nearest-Sniper | 100% | Eliminated by step ~140 |
53
- | 3Γ— Random (4P) | 100% | All eliminated by step ~120 |
54
- | Mixed seeds as P1/P2 | 83%+ | Consistent across positions |
55
 
56
  ## Usage
57
 
58
  ### Direct Kaggle Submission
59
- Download `submission.py` and submit to the Orbit Wars competition:
60
-
61
  ```bash
62
- # Download
63
  wget https://huggingface.co/Builder-Neekhil/orbit-wars-agent/resolve/main/submission.py
64
-
65
- # Or use the Kaggle API
66
- kaggle competitions submit orbit-wars -f submission.py -m "Enhanced composite agent"
67
  ```
68
 
69
  ### Local Testing
70
  ```python
71
  from kaggle_environments import make
72
-
73
- # Load agent
74
  exec(open('submission.py').read(), globals())
75
 
76
- # Run a game
77
  env = make("orbit_wars", configuration={"seed": 42}, debug=False)
78
  env.run([agent, "random"])
79
-
80
- # Check results
81
  final = env.steps[-1]
82
  print(f"P0: {final[0].reward}, P1: {final[1].reward}")
83
  ```
84
 
85
- ### 4-Player Testing
86
- ```python
87
- env = make("orbit_wars", configuration={"seed": 42}, debug=False)
88
- env.run([agent, "random", "random", "random"])
89
- ```
90
-
91
- ## Key Strategic Components
92
-
93
- ### 1. Target Selection (Multi-Phase)
94
- - **Opening:** Prioritize high-production neutral planets
95
- - **Mid-game:** Score-based selection considering production, distance, defense cost
96
- - **Late-game:** Aggressive elimination targeting with strong bonus
97
 
98
- ### 2. Fleet Routing
99
- - Sun-avoidance with safe detour angles
100
- - Orbital prediction with lead-aim for moving targets
101
- - Multi-step intercept search for rotating planets
102
 
103
- ### 3. Multi-Source Coordination
104
- - 2/3/4 source synchronized swarm attacks
105
- - ETA tolerance matching for coordinated arrival
106
- - Optimal ship allocation across sources
107
 
108
- ### 4. Defense
109
- - Proactive defense horizon scanning
110
- - Reinforcement missions to threatened planets
111
- - Doomed planet evacuation with retreat routing
112
- - Crash exploit detection (capturing planets after enemy fleet collisions)
113
 
114
- ### 5. Endgame
115
- - Total war mode with focused weakest-enemy targeting
116
- - Rear planet forwarding to frontline
117
- - Ship count optimization for final scoring
 
 
118
 
119
  ## Files
120
- - `submission.py` β€” The complete agent (single-file, no dependencies beyond kaggle-environments)
 
 
121
 
122
  ## License
123
  MIT
 
1
+ # πŸ›Έ Orbit Wars - Kaggle Competition Agent (v2 Adaptive)
2
 
3
+ **Competition:** [Orbit Wars](https://www.kaggle.com/competitions/orbit-wars) ($50,000 prize pool)
4
+ **Deadline:** June 23, 2026
5
+ **Current ELO:** ~1100 and climbing
6
 
7
  ## Overview
8
 
9
+ This is a highly competitive **adaptive** agent for the Orbit Wars Kaggle competition β€” a real-time strategy game where 2 or 4 AI agents compete to conquer planets orbiting a central sun in continuous 2D space.
10
 
11
+ **v2 adds real-time in-match opponent profiling and adaptive parameter tuning β€” the agent learns opponent playstyle during each game and adjusts its strategy accordingly.**
 
 
 
 
 
 
 
 
12
 
13
  ## Architecture
14
 
15
+ ### Core: Composite Rule-Based Engine
16
+ Combined from the **5 top public agents** on the leaderboard:
17
+
18
+ | Source | LB Rating | Key Feature |
19
+ |--------|-----------|-------------|
20
+ | tamrazov-starwars (base) | LB 1224 | Gang-up attacks, weakest enemy targeting, elimination missions |
21
+ | ykhnkf | LB #1 | Hostile reinforcement prediction |
22
+ | pascal v14 | High-rated | 4-source coordinated swarm attacks |
23
+ | pilkwang | LB ~1000 | Structured decision architecture |
24
+ | yuriygreben | Architect | Physics-aware multi-phase strategy |
25
+
26
+ ### v2: In-Match Opponent Profiling & Adaptation
27
+
28
+ New adaptive layer that monitors opponent behavior in real-time:
29
+
30
+ **What it tracks (EMA-smoothed):**
31
+ - **Aggression** β€” fleet launch frequency (how often they attack)
32
+ - **Expansion rate** β€” planet capture speed
33
+ - **Relative strength** β€” ship/planet differential
34
 
35
+ **How it adapts:**
 
 
 
 
 
36
 
37
+ | Opponent Style | Agent Response |
38
+ |---------------|---------------|
39
+ | Very aggressive (aggression > 0.6) | ↑ defense ratios, ↑ reinforcement priority, ↓ attack aggression |
40
+ | Passive/turtle (aggression < 0.3) | ↑ attack multipliers, ↑ elimination bonus, ↑ expansion pressure |
41
+ | We're ahead | Play safe, consolidate, higher attack cost weighting |
42
+ | We're behind | Take risks, ↑ snipe values, ↑ finishing bonuses, lower defense |
43
+ | Enemy expanding fast | Contest neutrals more aggressively, ↓ target margins |
44
+ | Late game (step > 350) | Maximum elimination drive, ↑ finishing multipliers |
45
 
46
+ **20 parameters dynamically tuned** during each match based on game state.
 
 
47
 
48
+ ### Key Technical Features
49
+
50
+ 1. **Hostile Reinforcement Prediction** β€” estimates enemy counterattack potential before committing fleets
51
+ 2. **4-Source Coordinated Swarms** β€” synchronizes 4 fleets to overwhelm defended targets
52
+ 3. **Multi-Phase Target Selection** β€” opening expansion β†’ mid-game optimization β†’ late-game elimination
53
+ 4. **Sun-Aware Fleet Routing** β€” avoids solar destruction with safe detour angles
54
+ 5. **Crash Exploit Detection** β€” captures planets weakened by enemy fleet collisions
55
+ 6. **Doomed Planet Evacuation** β€” retreats from unsaveable positions to useful targets
56
 
57
  ## Performance
58
 
 
59
  | Opponent | Win Rate | Notes |
60
  |----------|----------|-------|
61
+ | Random | **100%** (3/3) | Eliminated by step ~94-150 |
62
+ | Nearest-Sniper | **100%** (4/4) | Eliminated by step ~88-152 |
63
+ | 3Γ— Random (4P) | **100%** | All eliminated by step ~123 |
 
64
 
65
  ## Usage
66
 
67
  ### Direct Kaggle Submission
 
 
68
  ```bash
 
69
  wget https://huggingface.co/Builder-Neekhil/orbit-wars-agent/resolve/main/submission.py
70
+ kaggle competitions submit orbit-wars -f submission.py -m "v2 adaptive agent"
 
 
71
  ```
72
 
73
  ### Local Testing
74
  ```python
75
  from kaggle_environments import make
 
 
76
  exec(open('submission.py').read(), globals())
77
 
 
78
  env = make("orbit_wars", configuration={"seed": 42}, debug=False)
79
  env.run([agent, "random"])
 
 
80
  final = env.steps[-1]
81
  print(f"P0: {final[0].reward}, P1: {final[1].reward}")
82
  ```
83
 
84
+ ## Self-Play PPO Training (Optional)
 
 
 
 
 
 
 
 
 
 
 
85
 
86
+ The repo includes a PPO self-play training pipeline for further improvement:
 
 
 
87
 
88
+ ```bash
89
+ pip install torch numpy pyyaml kaggle-environments huggingface_hub
 
 
90
 
91
+ # Train (requires GPU for reasonable speed, ~10h on T4)
92
+ TOTAL_UPDATES=500 EPISODES_PER_UPDATE=4 python train_efficient.py
93
+ ```
 
 
94
 
95
+ **Training approach** (based on the Artificial Generals Intelligence paper, arXiv:2507.06825):
96
+ - **Phase 1 (0-20%)**: Train vs random opponents (fast, learn basics)
97
+ - **Phase 2 (20-50%)**: Train vs baseline agent (harder, learn tactics)
98
+ - **Phase 3 (50-100%)**: Self-play with opponent pool (N=3, argmax opponents)
99
+ - **Reward**: Potential-based shaping (planets + ships + production differential)
100
+ - **Architecture**: 128-d MLP controller that outputs 20 parameter adjustments
101
 
102
  ## Files
103
+ - `submission.py` β€” Complete adaptive agent (single-file, ready for Kaggle)
104
+ - `train_efficient.py` β€” PPO self-play training script
105
+ - `generate_submission.py` β€” Packages trained controller into submission file
106
 
107
  ## License
108
  MIT