Development > Newbie Coding
Artificial Intelligence
Duke:
hitch-22, rulesets are fine.
But the current AI is far away from using rulesets.
It's merely (in a nutshell):
Walk to the place where you can inflict the most damage and preferably hide afterwards, else close in on the nearest enemy. That's it.
Duke:
Oh, and to all those who consider randomness as the solution:
You have to figure out the *options* to randomly pick from first, don't you ?
DexCisco:
To answer the skill testing question: If you can see the sky, you are outside.
The AI really has 3 levels: Team tactics, individual tactics, and pathfinding.
To address the simplest, pathfinding, there are two types of pathing: physical pathing (moving from A to B) and visual pathing (I need to see/shoot what is over there). Perhaps some of the heavy lifting could be done beforehand during the compilation of the map. For instance, for visual pathing, for every given space, store the coords of every space that can be seen from there. Then when the AI decides that it needs to see a given unseen coord, it can select physical pathing destinations from the list of coords that can see the target.
For physical pathing, perhaps some pre-processing could identify pathing wayponts. Large, open areas could be identified by selecting points and testing pathfinding to all nearby spaces. The lowest overall pathing score gets chosen as a waypoint. Then test pathing out from those points to a pre-determined max waypoint distance. Anywhere that the pathing score exceeds a threshold amount are identified as further waypoints. Pathing tests that find other waypoints within their radius record a connection between those two waypoints. The network of waypoints is stored with the map and can then be used for larger scale pathing choices (like finding your way out of a building or Harvester).
Individual tactical AI is a bit more tricky, but might be helped by the visual data mentioned earlier. It would involve at least four steps: exploration to find targets, choosing a target, moving to a valid attack position, and then the TU usage in a given turn to move before attacking, attack, and return to cover if possible. This whole system might be aided by some sort of aggression variable used to determine how concerned with cover it is, etc.
Exploration would involve keeping track of everywhere the team can see and then choosing pathing destinations that can see the maximum number of unseen coords with the minimum move time.
Once one or more targets are available, the unit could either opt to continue exploring (e.g. if the target is too far away to be reasonably targeted), or to move to a firing position. Firing position would of course be limited to coords within the maximum effective range of the weapon. Negative modifiers would be given to positions exposed to enemy fire (determined by the visibility data attached to the map). Higher aggression units would weight these modifiers as less of an issue. Prime firing positions are determined as adjacent, pathable coords where one (cover) has low visibility of enemy units and the other (firing) has visibility of the target at an acceptable range. Turn-by-turn pathing destinations are chosen from the reachable coords based on distance to the next pathing waypoint, visibility of enemies and aggression. If there is no way to get to a good firing position, either the aggression is raised, a new target is chosen, or the unit goes back into explore mode to find another target or another way around.
Once the unit arrives at its firing position, its next turn can be used to move from the cover position to the firing position, fire, and return to cover if possible.
Team tactics could be very tricky, but perhaps it should be limited to concentration of fire (more than one unit choosing the same target), and spreading out (minimum distance between chosen firing positions). Perhaps coordinated fire (synchronizing attack to the same turn). The rest might just happen naturally as a result of using good cover and scouting tactics.
DexCisco:
The whole pre-processing thing is complicated by the fact that maps are built from smaller pieces, so map-wide visibility and pathing is not really possible. Waypoints could still be determined for each sub-map component and then linked when the map is assembled in game. Determining visibility into adjacent map components could not be done during map compiling. Depending on how long it takes it may be done after the map is assembled pre-mission.
Duke:
DexCisco, thx for your proposal :)
In short: some things you propose are not possible (eg. "for every given space, store the coords of every space that can be seen from there"=>calculate!) and the others are already in place (in the same or similar way => look at the code).
But one idea is good: to detect open areas from the pathfinding time. I'll have to think a bit more about this.
Thx again :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version