Spodii / netgore

Cross platform online rpg engine using C# and SFML
http://www.netgore.com/
40 stars 17 forks source link

AI is faulty and not very... intelligent #341

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The basic path finding (I believe this is the culprit) is very poor in that it 
often tries to take short routes without taking into account obstacles that may 
be in the way. 

Consider to the two sample situations:

Problem #1: http://i.imgur.com/AyqBfcY.png
Problem #2: http://i.imgur.com/yMncBjF.png

I assume the path-finding right now really is just a 'attempt to move the 
shortest distance to the character' kind of AI.

Original issue reported on code.google.com by hilts.va...@gmail.com on 6 Feb 2013 at 9:10

GoogleCodeExporter commented 9 years ago
Isn't this the same as issue 118?

Original comment by darksumm...@gmail.com on 7 Feb 2013 at 1:05

GoogleCodeExporter commented 9 years ago
I'm not sure what APHRO was meaning there.. maybe we should check with him? 
There, he implies pathfinding exists but I can't see it. 

Original comment by hilts.va...@gmail.com on 8 Feb 2013 at 2:45

GoogleCodeExporter commented 9 years ago
Hey,

A long time ago I implemented an A• algorithm for pathfinding.  I have 
removed it as it was not performant.  It was also quite a long time ago, I'd 
probably find my old implementation laughable now :P.  I can find one 
implmentation from Marach 2010: 
http://code.google.com/p/netgore/source/browse/netgore/trunk/NetGore/World/Entit
ies/AI/PathFinder.cs?spec=svn2526&r=2526

The game designer marked out which grid cells were 'walkable' and then the 
pathfinding would do the rest.  I found this to be particularly slow and I 
wanted to figure out a way of optimising all this.  Perhaps that class would be 
a good starting point, however, I was a lot more of a 'noob' then when it comes 
to programming.

I had experimented with other methods and remember I had a really nice node 
graph drawn out on a map that showed jumping points, but I never committed 
this, but I do remember it worked by looking at the top left and top right 
positions of Wall entities.  It would then do some math for every wall entity 
that was `N` distance away, working out the jump location and distance to reach 
the other wall platform.  It was quite buggy so I don't think I committed this.

I'd planned to create a Navigator class that would us some implementation of 
the Pathfinder (using the strategy pattern) that the AI implementations could 
use.

Sam

Original comment by aphro.cag on 11 Feb 2013 at 10:23

GoogleCodeExporter commented 9 years ago
did not get to see the code shown above however I believe that to give a more 
intelligence npc suffice to put something when it hit the front with a interlo 
to divert the casso move sideways

Original comment by ianADMki...@gmail.com on 2 Oct 2013 at 11:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Pathfinding should be calculated in MapEditor and saved into file/sql.

when NPC want to move from X/Y to a destination X/Y he should check for 
available roots from this file, and chose one. In the attach file I try to give 
an example.

the semi-starts are identified "rootnodes" witch are calculated before. 
Red tiles are Blocks(Walls) 

in this example the NPC have 2 available roots from the initial position. and 
he move to the "rootnode" instead the target.

the example file to be saved its like X/Y intervals for each rootnode.

rootNode n | To Start X/Y | End X/Y | From Start X/Y | End X/Y

4,3  rootNode 1 | To 1,1 | 4,2  from 5,1 | 15,8 
7,3  rootNode 2 | To 7,1 | 11,2 from 1,3 | 6,8
4,3  rootNode 3 | To 1,8 | 3,8  from 1,1 | 15,7 
12,3 rootNode 4 | To 13,1| 15,2 from 1,1 | 11,8
12,3 rootNode 4 | To 14,1| 15,5 from 1,1 | 11,8
12,6 rootNode 5 | To 14,1| 15,5 from 1,1 | 11,8
12,3 rootNode 5 | To 13,7| 15,8 from 1,1 | 11,8
(this is just example with bad calculations)

the destination will return 2 rootNotes where the NPC need to chose and move 
from his position to rootnode Locations when he reach the location he starts to 
move to target.

Original comment by inza...@gmail.com on 1 Mar 2014 at 3:09

Attachments: