This document summarizes an intelligent Battlecode agent called twoface. It includes 3 sections:
1. Feature overview which describes the agent's blackboard system for communication, task-based approach, and macromanagement techniques like opponent modeling and adaptive strategies.
2. Pathfinding algorithms including A* search, dynamic pathfinding, and agile approaches for squads.
3. Testing results showing the agent beats a reference player on 9 maps but is inferior to 2014 finalists. Areas for future improvement are also outlined.
1. twoface - an intelligent
Battlecode Agent
Final presentation - 23rd January 2015
1
2. Battlecode final presentation - Group n.2
• Feature Overview
• Communication
• Blackboard
• Tasks
• Macromanagement
• Opponent modeling
• Strategy decision
• Scouting
• Squad Team
• Guards
Outline
2
• Micromanagement
• Pathfinding
• Building period
• Dynamic pathfinding
• Agile pathfinding
• Testing
• Experimental setup
• Score measure
• Experimental results
• Conclusion and future
improvements
3. Battlecode final presentation - Group n.2 3
Blackboard
● Task-oriented modeling of the
game actions
● Public visible tasks
● Dedicated tasks
Micromanagement
● Enhanced individual attack
and defence
● Retreat calculation
Macromanagement
● Opponent model
● Adaptive behavior
● Scouts for distributed sensing
● Enemy position representation
● Leader guided squads for attack
● Guarding groups for defence
Pathfinding
● A* approach with map coarsening
● Alternative bug pathing algorithm
with I.D.
● Follow or flee from target algorithm
● Determining good locations to build
PASTRs
Feature overview: twoface
intelligent and adaptive Battlecode playing agent
4. Battlecode final presentation - Group n.2
• Central aspect in battlecode
• Essential for macromanagement
• Example: coordination of units according to strategy
• Exchanged data can be complex
⇒ Blackboard system with tasks
Communication
4
6. Battlecode final presentation - Group n.2
• Task Interface
• Defines only the most necessary methods
• Serialize the task object to the broadcast array
• Deserialize the task object from the broadcast array
• Task type to get the matched Implementation
• Allows a flexible way to define strategic commands
• Can be used to outsource calculations to robots
Communication - Tasks
6
7. Battlecode final presentation - Group n.2
• Implemented tasks:
• ComputePASTRSpotTask
• CreateMapTask
• GuardPositionTask
• ScoutAroundTask
• SingleLocationTask
• SquadTask
Communication - Tasks
7
8. Battlecode final presentation - Group n.2
Macromanagement - Opponent Modelling
8
INPUT
● Amount of Milk
● No. of PASTRs
● No. of killed units
● Braodcasting units
● Position of enemies
● No. of flocks
OUTPUT
● HerdingConfidence:
likelihood the enemy is
focusing on collecting milk
● AttackConfidence: likelihood
the enemy is preparing for an
attack;
Opponent behaviour classification in the class
BehaviourControl.java
called every 25 rounds (=1 timespan)
}with scouts
10. Battlecode final presentation - Group n.2
Defending Mode
• PASTR built immediately
• Guards are placed around PASTR
Attacking Mode
• Squad team is formed
• Enemy PASTRs are always attacked
• Enemy HQ is blocked
• PASTR building is postponed
Macromanagement - Strategy Decision
10
Confindence timer to
prevent frequent
switches
11. Battlecode final presentation - Group n.2
• Detect enemy location and movement → opponent
modeling
• Two approaches
a. senseBroadcastingRobots: most complete and fastest if radio
is used regularly by opponent
b. soldier exploring area in map (senseNearbyGameObjects):
• slower
• useful if no radio used by opponent
• number of units is limited → reduced attacking power
Macromanagement - Scouting
11
12. Battlecode final presentation - Group n.2
• Implementation
• Task blackboard system
• announced at start of match
• scout in area between two given locations
• if incoming attack detected: scouts help defending
• enemy info broadcasted to radio channels:
• location
• enemy ID
• round number enemy detected
• Scout trajectory: 3 locations between HQ and enemy
HQ
Macromanagement - Scouting 2
12
14. Battlecode final presentation - Group n.2
• Formulated as a Task
• Contains a channel
• Same channel equals same team
• Leader
• Leader sub-task automatically taken
• Complex pathfinding
• Detects blockades and reacts
• Follower
• Will follow the leader as close as possible
• Simple pathfinding
• Complex pathfinding when lost
Macromanagement - Squad Team
14
15. Battlecode final presentation - Group n.2
• Formulated as a Task
• Contains a location and a channel
• Same channel equals same team
• Communication
• Broadcast information about nearby enemies
• Support broadcaster
• Rallying
• Rally around the goal
• Maintain a distance to the goal
• More defenses in direction of enemy HQ
Macromanagement - Guards
15
16. Battlecode final presentation - Group n.2
• When enemies are encountered
• Four Modes: Attack, Approach, Await, Retreat
• Consider global and local advantages
• Attack
• If in attack range and advantage is given
• Or if in attack range and situation is hopeless
• Await
• If slightly out of attack range and advantage is given
• Approach
• If not awaiting and advantage is given
• Retreat
• else (enemies nearby, no advantage, but not considered hopeless)
Micromanagement
16
17. Battlecode final presentation - Group n.2 17
• A* search
• Coarsened map
• Advantages
• Fast pathfinding
• Disadvantages
• Long graph building period
• No navigation during
building
• No dynamic obstacle
avoidance
Pathfinding
18. Battlecode final presentation - Group n.2 18
• Graph is serializable
• Outsource to SOLDIER using task system
• Solves:
• Immobility during build period
• Does not solve:
• Pathfinding during build period
Pathfinding - Building Period
19. Battlecode final presentation - Group n.2 19
• Search graph only incorporates walls
• Solution: Bugging Algorithm
• Solves:
• Dynamic Pathfinding
• Pathfinding during build period
• Simply use greedy approach
• Avoid walls when necessary
• Fails at long walls, nearby robots moving
• Solution: “Iterative deepening bugging”
Pathfinding - Dynamic Pathfinding
21. Battlecode final presentation - Group n.2 21
• Squads and Micromanagement need faster pathfinding
• Completeness is not an issue
• Two new Methods:
• Simple bug pathing, as seen at MIT
• Following, as greedy as possible
• Sophisticated and fast pathfinding by dynamically
switching between methods
Pathfinding - Agile Pathfinding
22. Battlecode final presentation - Group n.2
• 5 opponent players (reference player, 2014 finalists)
• 9 maps (used to gain MIT course credit)
• each player alternates between Team A and Team B
• score measure
Testing - Experimental Setup
22
23. Battlecode final presentation - Group n.2
mA
: amount of milk by team A at end of match
mB
: amount of milk by team B at end of match
mmax
: amount of milk to win the game (107
)
nend
: number of rounds to finish the game
nmax
: maximum number of rounds allowed
η : penalty factor [0,1] : sets lower bound on “rounds” feature
Testing - Score measure
23
“milk” feature “rounds” feature
24. Battlecode final presentation - Group n.2
• beats reference player in all of the 9 maps
• inferior to 2014 finalists
• results of games against reference player:
Testing - Experimental Results
24
25. Battlecode final presentation - Group n.2
• Ad hoc data structures for saving bytecodes
• Improve the blackboard
• More cooperation at micro-level
• Improve the exploitation of the opponent modelling
• More HQ modes (now only attacking and defending)
• Define the conditions when to call the scouts
• ...
Conclusion - Future improvements
25