chosencharacters / squidBounties

Haxe(Flixel) and OpenFL bounties to help glorious progress of flixelkind
15 stars 0 forks source link

$150 - Basic Platformer Pathfinding AI for HaxeFlixel #5

Open chosencharacters opened 3 years ago

chosencharacters commented 3 years ago

A pathfinding algorithm that, given:

Will output a list of AIMovements with one of these possibilities:

So that when fed into any game AI, it'll know to move and jump at certain times.

The real life use case of this would be the Bandit in Renaine, which chases the player but currently gets stuck on certain ramps.

This AI should be able to update in regular intervals.

Bonus Bounties (i.e. things I really need done for Renaine but will make things harder)

nanjizal commented 2 years ago

@chosencharacters I believe my demo here could be adapted easily for your needs ( from my old repo ).

https://rawgit.com/Justinfront/hxDaedalus-NME-OpenFL-Examples/master/hxDaedalus-NME-OpenFL-Examples/06-Multilayer/bin/html5/bin/index.html

uses polygonal.ai which I don't think is anymore online and hxDaedalus, you just provide with black and white images for each layer and a list of portals between points on each layer. I guess further work could be done to automate between layers even more.

please get intouch if you require more assistance.

nanjizal commented 2 years ago

hxDaedalus now supports Flixel will look into integration of polygonal.ai to provide weighted graph that can be mixed with Daedalus.

https://github.com/hxDaedalus/hxDaedalus-flixel

Geokureli commented 2 years ago

@nanjizal this is really cool, but the bulk of the work here is applying pathfinding to a platformer game, not a topdown game. If you think you can get you're pathfinder code working with platformer physics and a FlxTilemap (bonus for FlxTilemapExt with slopes) then let me know. I'm currently working on this with my own tile-based pathfinder, and the "bulk" of the work is definitely going to be traversing with gravity and converting path data to npc movement instructions.

gamedevsam commented 2 years ago

I'll double the bounty if the solution is released open source as a HaxeFlixel addon.

BNTFryingPan commented 2 years ago

im going to be adding AI to my platform fighter. its a bit more complex than this i think, but also more specific to a platfighter, but once i do get it working i might be able to adapt it to be a bit more generic.

does this need to output a final path or should it instead output its 'inputs' for every tick? i feel like it might be more difficult for someone to implement a way to follow the moves rather than just accepting inputs similar to a human player, and it would allow it to recalculate its path if something interrupts its movement. also i feel like this would make more sense than a calculated set of inputs if the destination would be moving as it is in the given example.

last thing, how would this handle being unable to reach the target destination? for 'chasing' its probably not too a big concern depending on the enemy, but what if a player manages to get it stuck in a hole or something?

IADenner commented 2 years ago

https://www.youtube.com/watch?v=2-2m-af48PI&ab_channel=Minicology

Hey, threw together a video showing off how minicology handles platformer pathfinding. I'm a little busy to put together a library for it, but if someone else wants to use the basic concepts explained here to create a haxeflixel addon, feel free.

very basically, though, the concept is to use the astar algo, but mark any nodes without ground underneath them as inaccessible/or very high cost. Then, take the path and flatten it so that each node is on the ground. Then, determine inputs depending on the relative position of the next node to the node we just reached (i.e., if the node we just reached is down from the next node, do a jump.) Uses astar found here: https://gitlab.com/haath/astar/-/tree/master/src/astar

I go into how to incorporate both solutions to @LeotomasMC question about being 'unable to reach the target destination' (marking high jump areas as walls for 'no chase' behavior, marking them as high cost tiles for 'chase' behaviour)