I'm implementing a version of Lode Runner (this version), but I'm not sure as to how reproduce the effect of minions working cooperatively to corner the player, can it be done using A*, or is there a better approach? Is there a better algorithm for cooperativity between minions (e.g. boids), or the best solution is to simply apply an algorithm separately for each of them?
-
Where did you net out on this? Beginning a Lode Runner implementation myself, and I have the same question :) – Andrew Rubin Jul 09 '20 at 15:40
3 Answers
Lode Runner Web Game
Source code for your reference: https://github.com/SimonHung/LodeRunner
You can look on lodeRunner.guard.js: Enemy's AI algorithm, porting from C language, original by Douglas E. Smith.
hope can help you !

- 61
- 2
Paths are linear lines that entities of your game follow, so in a game like Lode Runner you'd have some extremely simple paths.
Firstly, I suggest that you write some kind of Plan object that can be passed to any entity (except the player) in your entity buffer and can be executed accordingly. It could be just an array of instructions, like ['left', 'up', 'right']
or a valid coordinate that the minion must travel to. Of course this coordinate would have to be parsed for validity in terms of the paths you have loaded for your minions to travel on.
Secondly, you need prediction. You need to predict all the (extreme) positions where the player could possibly end up and the time that it would take them to get there. For example, if the player goes as fast as he can down path route X to end up at coordinate Y, it would take him Z seconds. Of course if the player doesn't make it their in optimal time the minions will adjust, and, destroy the player.
Thridly, difficulty. You may need to write your code so that the code in your AI prediction and pathing becomes more complex with a greater difficulty. I'm sure you've heard of artificial difficulty, which is just the modification of the values in pathing and prediction.
Lastly and most importantly, cooperation. It's basically just an algorithm that takes all the minion's positions into account relative to the player's position and organizes them to cut off all possible paths at the time he'll reach them. This can be written many ways and I can't really provide an example here because I don't know what language you're using.

- 31
- 2
Most code I see follow a simple algorithm.
If player is to the left and you can go right, go right.
else if player is to the left and you can go left, go left.
else if player is to the left and you can go up, go up.
else if player is to the left and you can go down, go down.
else if you can move, then move in random direction.
else don't move.
Making the monks move contrary to this, as in Load Runner Online, you need checkpoints where another algorithm forces them to move differently.