IA, Pathfinding like in a HoMM game

Started by Baguettator, Today at 05:28:00

Previous topic - Next topic

Baguettator

Hi,

I would like to ask how it would be difficult to (re)make a game in the mood of the Heroes of Might and Magic, using AGS ?

The two things I think about would be :

- create the IA : how the bot thinks, acts etc... for solo vs computer games. I believe IA is a lot of conditions leading to a choice (if/else priority leading to the best choice). I presume it could be very long and hard to code it in AGS ? It would require some knowledge...

- calculate the path for a character when he is moving. I want him to go there, there is the terrain grid, somewhere it needs more cost for movement, somewhere it costs less, but how calculate these kind of things smoothly and "instantly" ?

So, I'm not asking for volunteers to make it for me, just for interest to how these kind of things works (and perhaps, for motivation to make it !)

Crimson Wizard

#1
Since AGS does not provide any ready functions for this, then you have to script everything yourself from scratch, unless you find a script module written by someone (I don't recall any similar though). But then again, this is true for any generic engine out there, except if there's a engine specialized for turn-based strategy games.

From the performance perspective, I think that one issue that you may encounter in AGS is the lack of parallel execution support in script: you cannot explicitly ask some long calculation to be run in background (pathfinding or decision making). I've met this problem in another engine many years ago, and solved it by splitting long calculations into parts then running only one part per game tick.

Pathfinding on a tile-based map may be typically done using classic A* algorithm (read as  "A-star"). You may search for its explanation in the internet, there has to be numerous tutorials and code examples out there. I recall that it has a relatively compact code (but of course it may be not easy to understand at first, so just follow the tutorial). It may be written in any programming language, including AGS script. I believe that it may be easier to do in AGS 4 with its better scripting features, but possible to do in AGS 3 as well.

The enemy AI, on another hand, is such a broad topic that it's difficult to decide how to start discussing it... I think that typically it is based on factor "weights", where each kind of problem has its "weight" which defines priority. Tasks have to be divided on levels: a strategy level that declares big goals, then lower levels which declares goals for each group of units, then for an individual unit, and that unit must be appointed either a order that brings closer to a strategy goal, or an order that reacts to its immediate situation (like survival). Perhaps, think of it as a chain of command, where each sub-commander receives an order from above, and deals only with their surroundings.

If you did not do that before, then I might suggest starting small and make a simpler game or a series of games first.

For example:

1. Make a game without real terrain and movement at all, where player and AI choices are made only regarding spending resources, and the outcome depends on what was bought on these resources. This may be a economy or a management game, but also a sort of a jRPG-style combat scene, where actors don't move but choose which actions to use, and resources are their Health and Energy/Mana/Whatnot.

2. After that try one with pathfinding: make a turn based combat game where player and enemies are located on a small grid with obstacles and have to take better positions to attack.

3. An idea for learning to code an AI is a game where the human player is a leader, but units are controlled by computer (think old classics like "Settlers" for example). Human issues orders and units perform them as they see fit. That will narrow down work necessary for AI.

That's just some ideas for educational purposes.

SMF spam blocked by CleanTalk