-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Code Combat: (Coded Circles Combat Competition Construct) A Java Applet By: Robert Meade, Richard Bowser, Josh Carson, Jared Glaser, Brian Domin, Dalton Decerio, Derek Weast, Matthew Jahn, Abraham Shin, Jack Bakay
- Introduction Code Combat is an extensible Java Applet based framework that is designed to allow for experimentation with machine learning algorithms in virtual combat. The project was completed in a 19 day period by the group of aforementioned Spring-Ford High School students.
1.1 Objectives provide an arena in which simulated robots can fight each other with the goal of maximizing kills and accuracy whilst minimizing deaths Implement simulated robots using custom designed algorithms and AI techniques as applicable
2 Implementation Code combat is implemented as a world object which holds sprite objects (including circle bots) that is periodically updated inside of a JApplet. The world is painted and updated at regular intervals and manages consecutive regular updating of aggregate sprites. Constants and World Instance specific settings are parsed from .txt files into a HashMap and then used to initialize values as necessary.
2.1 Development Tools Eclipse- used to write/debug the code Github- used for version control Google Drive- used to collaborate documentation ArgoUML- used for documentation
2.2 Architecture Code combat was developed in java using Swing and the JApplet framework. It runs on all architectures. Figure 2.2.1: Use Case Diagram 2.3 Design
Package Structure: app - applet, jframe, main, and ui functionality bots - circle minds lib - custom utils for parsing files and vector math library world - implementation of world and aggregate sprites
Sprite Data Structure and Functionality: 2 Dimensional Vector Data Types: Position (updated based on avg vel from pre and post tick vel) Velocity (updated by adding accel) Acceleration (const) Functions to interface with world Paint Update Other required functionality Copy Collision Behaviors *sprite was decided as abstract
Sprite Lifecycle: instantiated life and death (still alive) The isAlive() method is used to tell whether or not to update and/or draw the sprite, not discard it from memory usage existence terminated Once existence is set to false, the sprite is to be discarded from memory (substitute for lack of destructors in java -> set all references null)
World Tick (managed in applet): Update all positions and discard sprites marked for memory reallocation Sprite ticks are different according to the type of sprite: Circle - update based on mind input; slide on obstacles Shield and Mine- move in circle and shield or kill Circles as applicable; do not interact with obstacles Obstacle - exist and remain immobile when other objects collide with obstacle Check for collisions using AABB and correct positions as necessary Collisions are managed differently per sprite type: Circle - slide walls; slide obstacles; slide circles; detect shields; die projectiles Shield - attach to circles; die projectile Mine - die projectile; die circle; die mine Obstacle - slide obstacles; slide walls Paint world
Collision Behaviors: Bounce - set velocity component perpendicular to plane of collision and slide Slide - set position outside colliding sprite SlideWalls - set positions inside wall boundaries *note: deep copy passed for collide method fixes infinite false updating
3.Software Development Process Development Phases: Brainstorming World concept with Sprite aggregates postulated Applet framework suggested Applet embedded in JFrame proposed Framework building The JApplet and surrounding JFrame were rushed into production in order to support the rendering of the virtual world The world was developed in a series of 48 minute (1 class period) and all night sprints Bot Implementation Bots were implemented during the last 3 days of the project and it was all merged together on the final day 3.1.1 Functional Requirements The app must compute and render a game that allows Robot AIs to fight against each other and avoid obstacles, mines, and pick up powerups to help boost the AI’s chance of winning. The stats of each bot are collected and displayed on a leaderboard to determine the best robot.
3.1.2 Analysis and Test The program was tested via manual runtime evaluation, bugs were listed and scheduled for fixing during the next sprint. JUnit testing was used for the Vector2 API.
3.1.3 Future Plans Implementing actual machine learning algorithms to analyze and counter enemy robots may be explored during the future.
3.2 Person Hours
Person Hours Tasks Robert Meade 30 hours Applet and JFrame framework Lib package World framework Bug Patching CommitBot TestBot Collisions In View Calculation
Richard Bowser 20 hours Applet and JFrame framework Bug Patching RicardoBot
Josh Carson 20 hours Applet and JFrame framework World framework ZekeBot Test and Quality Assurace (manual) Collision Management Collision Detection
Brian Domin 16 hours Shields ZekeBot JFrame and JApplet research
Jared Glaser 18 hours JFrame and JApplet JardBot
Dalton Decerio 17 hours scuBOT
Derek Weast 15 hours scuBOT
Matthew Jahn 16 hours JacknJahnBot Collision Detection
Abraham Shin 15 hours JacknJahnBot
Jack Bakay 15 hours JacknJahnBot
-
External Resources Java Collections Framework JApplet and JFrame
-
References
Java 8 API: https://docs.oracle.com/javase/8/docs/api/
- Additional Information
scuBOT (Derek and Dalton): Avoids mines completely Remembers locations of all sprites but forgets locations of projectiles, circles, shields, and mines after a given amount of time Runs away when another circle is facing it Attacks a circle if it is not facing it Avoids obstacles and frees itself it it gets stuck Wins.
JacknJahnBot (Matt and Jack): (Matt and Jack): Creates a priority queue based on visible information to make decisions based on the current situation. Will decide to take actions including acquiring shields, avoiding obstacles and mines, and hunting other circles, based on criteria such as distance and the presence of obstacles.
ZekeBot(b (Brian and Josh): Intended to remember where everything was, but everything broke and we ended up with a glorified testbot.
CommitBot (Robbie): Performs the following tasks in order exiting at the first action taken: Compiles HashMap of seen and updates as applicable to track positions of other sprites Predict location of possible target (1. Circle in front with CommitBot in its sights and clear path || 2. Closest Circle with clear path) Attack target if Circle target Avoid mines if mines at close range Dodge incoming projectiles Turn to face Circle behind CommitBot with CommitBot in its sightes Avoid Obstacles
6.1 User Instructions:
Configure the game using the menu or the the keyboard commands as necessary. Config values will be updated on restart. Optional Keyboard Controls: d - debug m - menu p - pause r - restart
The Original Work of Spring-Ford High School's 2015/2016 AP Computer Science Class