I just simply don't know where should I even begin? I know my question is not very specific, but I guess I'm not even looking for specific answer. When I'm programming my AI actions should I simply think "what would I do" in one or other situation and code it in hundreds of different "if (..) else (..)" branches covering all possible scenarios?
You can break the AI problem into manageable pieces through abstractions:
- Fleet level AI gives very simple high level orders to ships: attack there, form a line here, etc.
- Every ships interprets orders and acts independently from the others: where do I want to go? Which enemies should I shoot? Am I on a potential collision course?
- Every ship maps a small set of objective types (e.g. arrive to a certain location with a certain angle and speed, shoot down a certain enemy, evade an incoming torpedo) to a small set of command types (turn and shoot guns, rudder, engine power) according to well-defined sensor inputs (e.g. see ships up to a certain very long distance).
- This mapping from objectives to commands can be further structured and constrained: with states, as rwilson1982 suggests, with exact geometric computations (for example to obtain shortest paths and deadlines to steer before projected collisions), with rules, evaluation functions and random choice to select plans (for example, closing in for broadside shooting vs retreating to use long-range weapons), with fixed scripts (for example, retreat after taking "enough" damage), with pockets of opaque machine-learned behaviour (for example, a neural network that selects enemy ships to shoot based on their type and position).
Well, in other words, let's say you want to implement a simple AI for sea battle game - that is, ship can move around and fire at enemy. What would be your concepts and thought on creating it? Again, I'm not asking for anything very specific, just a basic idea and abstract concepts how such things are usually done. Well, since I'm very lost at this point, any insights or suggestions are much appreciated.[/quote]
Every game type has its special concerns. In your case, ships:
- Are unable to move freely, requiring high quality and unusually long term path planning.
- Can collide with friendly units, requiring path planning to predict and avoid collisions. Compare with aircraft, which could realistically pass through each other in a 2D map by implicitly flying at slightly different height.
- Have limited shots and possibly long weapon reload times, requiring attacks to be optimized.
- Have very important weapon range and angle constraints, which need to be represented in detail and accounted for in order to attack and evade effectively. Compare with a FPS, where with few exceptions you can turn freely to shoot your only weapon at anything in sight.
- Can keep going after losing a number of subsystems (guns, engines, etc.), requiring the AI to adapt to reduced capabilities.
- Operate in formations, requiring some form of coordination (top-down with whole-fleet orders, bottom-up with rules applied by each ship, or both).