The AI Brawl is a project I started to test/study different AI fighting strategies. It features two bots that fight each other using 3 techniques/strategies: Attack, Dodge, and Guard.
Each strategy also has 3 key attributes to it that affect the priority of the strategy as well as the player's frequency that it can choose a strategy. These attributes are: Base Priority, Min/Max range, and duration (aka cooldown).
A strategy's priority is what the Bot considers in order to decide which strategy it will do next. The priority of a strategy is also affected by the strategy's Min/Max range. The distance between the 2 bots are used to measure a multiplier that is calculated based on the Min/Max range. The closer the distance is to the min value, the closer the multiplier is to 125%. The closer the distance is to the max value, the closer the multiplier is to 25%.
For instance, if a bot is 5 units away from the other bot, and the range for a strategy it is calculating the final priority for is (Min: 0, Max: 10) and the basePriority is 0.4, the multiplier will be 75% and so the final value for that particular strategy's priority will be 0.4 * 0.75 (basePriority * multiplier).
The cooldown associated with each strategy affects how quickly the bot can choose another strategy. When a strategy is picked, the duration/cooldown associated with that strategy is assigned to a cooldown timer that the Bot must wait to expire before it may choose its next strategy. The attack duration is 9999; however it uses a flag to reset the cooldown timer as if the bot is not in range to attack, it must run to the other Bot in order to perform the attack.
Bot 1 Base Priorities:
- Dodge: 0.35
- Attack: 0.55
- Guard: 0.1
Bot 2 Base Priorities:
- Dodge: 0.55
- Attack: 0.35
- Guard: 0.1