Astraeus Player's Guide
CHOOSING WHEN TO STRIKE
Avoid Streaming Units
Your starting team doesn't really have an overall strategy - each unit simply moves on its own. As a result, when a unit is built it immediately tries to charge forward at the enemy fleet.
Unfortunately, this means that each unit is operating alone and is often outnumbered.
You'll want to make a strategy for your units to begin in a defensive mode then shift to attacking.
Keeping Track Of Strategy
In your player class, make a variable that stores your team's current plan. The simplest option here is to use a String, but if you're comfortable with the syntax an enumeration is even better.
In the strategy method, you change this variable based on the state of the game. To start, simply start with a label like defense or guard.
Reminder: Use Your Unit Superclass
We're going to be adding a lot of code to handle this behavior within units. I strongly suggest you write helper methods in your main unit class. Beyond that, remember that your unit superclass has its own action method. You can use inheritance to have each subclass call super.action() to handle general behaviors before they peform unit-specific actions.
How To Defend?
Often you may want to build up units without attacking the enemy fleet right away. To do so, you can send units to a rally point where they all agree to meet up. Or you could defend the base. But what about your workers?
Consider a few options below. As always, you can start simple and move to move complex algorithms as time goes on.
★ Stay At Base Ship
While you're in defense mode, simply move to the base ship or circle it. This isn't a bad place to start, but you're giving up control of the entire map.
★ Fixed Rally Point
You could pick a specific point on the map you want to move to. For most of your fleet I recommend a common location. You could vary this a bit by unit, making your tanks in front and damage dealers in the back. If you're using fast-moving skirmishers you can use rally points to flank around the sides of the enemy.
★★ Dynamic Rally Point
You could change your rally point based on the state of the game. Some examples:
When I have more units, move my rally point closer to the enemy ship to gain map control.
My skirmishers rally at a set point, unless there are enemies nearby. Then they rally at a different location that is safer.
★★★ Most Forward Worker
Write a method to determine which worker is closest to the enemy. Then, have your fleet rally at that worker's location.
★★★★ Escort System
Create a system to pair up units with workers. Each worker tracks which units are guarding it, and your system tries to find the worker that is most in need of more guardians and assigns that job to newly created combat units.
To make this work even better, consider factors like unit speed and the relative danger a worker is in. For instance, workers near the front may need more guards than those in the back.
ENGAGING NEARBY ENEMIES
Don't Rally Blindly
The problem with defending is that your units can be attacked before you decide to strike. It's important that they have some sort of trigger to spring into action.