OpenKore / openkore

A free/open source client and automation tool for Ragnarok Online
http://openkore.com
Other
1.29k stars 1.05k forks source link

New pathfinding A* algorithm review #2871

Closed Henrybk closed 3 years ago

Henrybk commented 5 years ago

This is the reviewed and cleaned branch of the pathfinding algorithm changes.

Openkore uses an old A* code for pathfinding, it has a few problems:

1 - It is not capable of calculating diagonal movement.
2 - Uses only distance to walls to calculate cells weighting.
3 - Is not capable of dynamic weight changes of cells since the weight is hard coded in distance to walls.
4 - Is not guaranteed to find the shortest paths.
5 - runfromTarget, attackCheckLOS and AttackCanSnipe don't work.

This branch fixes a few isses.

Features:

1 - Uses new simplified fld2 files
2 - Uses .weight files based on .dist files instead of .dist files, allowing custom static or dynamic weight maps (avoid mvps, non-walking mobs, dangerous map areas)
3 - Correctly uses diagonals, using weight 1.4 that of ortogonal moving
4 - Uses diagonal distance heuristic, which is the most appropriate for ragnarok maps
5 - Is guaranteed to always find the shortest / best path since it does not limit openlist
6- Fixes runfromTarget, attackCheckLOS and AttackCanSnipe
7- Corretly predicts the time to walk a given distance, preventing a few timeouts

Edit: Most of the changes were ideas from here: http://forums.openkore.com/viewtopic.php?f=36&t=1350

this pull fixes #2546.

This pull is a continuation of #1684.

The code was based on Sven Konig publications (Father of most of the pathfinding algorithms used today): http://idm-lab.org/publications.html

Xmpeshka commented 4 years ago

fixed)

Henrybk commented 4 years ago

In the first video you are trying to attack a monster that is on the other side of the cliff, which yelds a very long route, this should be prevented by having attackCheckLOS in the config set to 0 (for meele characters). What is your attackCheckLOS setting?

Xmpeshka commented 4 years ago

yes - it was 1 ) changed to 0

alisonrag commented 4 years ago

i also have a feature request: adjust distance that random walk chose point to move + option don't calc a new route after killing mob before old point wasn't reached. For exaple start from one corner of map and move continiously about 300 cells way, killing mobs during this trip, then calc a new long route...

Now kore sometimes cals route like chaotic random ) and bot runing from point to point in one part of map, not like player wiil.

u can keep the old route in ai by reverting this pull request: https://github.com/OpenKore/openkore/pull/2261/files

but openkore will have a issue that when to many monster in screen openkore will move away then back to kill

this issue can be fixed if we add a "monstercheck" before route again

Xmpeshka commented 4 years ago

New bug =) poor novice stnad and eating pots, and do nothing image if i change attackmaxdist to 2 image

Henrybk commented 4 years ago

That one I have not yet been able to reproduce.

Xmpeshka commented 4 years ago

mon_control on fabre 0 and attack other mobs, so bot runing and collect agro fabre

Xmpeshka commented 4 years ago

image with one fabre

Henrybk commented 4 years ago

Oh, okay, got it

Henrybk commented 4 years ago

That last bug should be fixed by these last commits

hubertyang88 commented 4 years ago

what environment do this branch need ? I download this link https://github.com/OpenKore/openkore/tree/Remake-routing-review but can't run . first , I had XSTools problem , I copy XSTools from some older version , and then wxstart.exe will stuck at process maps can any one fix a manual about how to run this

alisonrag commented 4 years ago

what environment do this branch need ? I download this link https://github.com/OpenKore/openkore/tree/Remake-routing-review but can't run . first , I had XSTools problem , I copy XSTools from some older version , and then wxstart.exe will stuck at process maps can any one fix a manual about how to run this

i updated the dll's and gitignore, try again now

result: image

Cyanide0210 commented 4 years ago

It is still not opening, I tried with Perl and the wxstart.exe and start.exe

tried

alisonrag commented 4 years ago

@M45T3Ryu This version works only in perl 5.12 32 bits(x86)

Try this http://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0.msi

Just need to run in cmd cpan install Win32-Console

Then run openkore.pl

Cyanide0210 commented 4 years ago

I found out that it gets stuck on long routes like it just stops doing everything, and does absolutelly nothing

alisonrag commented 4 years ago

@M4T3Ryu Vídeo? How to reproduce? Config? Server? AI sequence? Console debug?

hubertyang88 commented 4 years ago

@M45T3Ryu try to set
route_step 9

alisonrag commented 3 years ago

Route tests

Route Attack

Route Skill

Route Follow

Route Slave

Route others

Route Teleport

Route

TODO - Fix issues:

alisonrag commented 3 years ago

Stuck Log - FIXED

error while randomwalk sometime it stucks near from "objects" / walls / not walkable cells

Log: https://wtools.io/paste-code/b3NI

another stuck print: image

Meeting position Log - FIXED

Attack You (307 345) - target Monstro Red Mushroom (1) (308 343) is too far from us to attack, distance is 2, attack maxDistance is 1
Attack You (307 345) - moving to meeting position (308 344)

--------

move 308 344
Coords 308 344 are not walkable at map prt_fild08

where 308 344 is not walkable

ya4ept commented 3 years ago

@alisonrag don't forget to add a new parameter to the documentation "maxDist" (https://github.com/OpenKore/openkore/pull/2871/commits/be589b167e7eda448329b213aae4be0cf1412260)

alisonrag commented 3 years ago

@alisonrag don't forget to add a new parameter to the documentation "maxDist" (be589b1)

when everything has been tested and this pull request is ready i will add to documentation. add now can lead a people to use a no implemented feature but thanks for remember

alisonrag commented 3 years ago

last commit should fix the route stuck issue

ya4ept commented 3 years ago

изображение

let's update the documentation

alisonrag commented 3 years ago

https://openkore.com/wiki/Dist https://openkore.com/wiki/MaxDist

hubertyang88 commented 3 years ago

Congratulations! I am gonna try it Just need to download the latest master or still need to download Remake-routing-review?

alisonrag commented 3 years ago

Congratulations! I am gonna try it Just need to download the latest master or still need to download Remake-routing-review?

just download the master and dont use a old config.txt

hubertyang88 commented 3 years ago

something wrong with mon_control.txt when I set 1081 0 0 0 kore will leave Yellow Plant alone but when I set 黄草 0 0 0 #“Yellow Plant 0 0 0” kore will attck 1081 , something wrong with chinese name?

this also affect attackSkillSlot when use monsters but chinese name of some event monster works , kore didn't read monsters.txt only read new monsters ?

alisonrag commented 3 years ago

something wrong with mon_control.txt when I set 1081 0 0 0 kore will leave Yellow Plant alone but when I set 黄草 0 0 0 #“Yellow Plant 0 0 0” kore will attck 1081 , something wrong with chinese name?

this also affect attackSkillSlot when use monsters but chinese name of some event monster works , kore didn't read monsters.txt only read new monsters ?

Can u open a issue?

ya4ept commented 3 years ago

Please add a description of the new config parameters:

  1. attackRouteMaxPathDistance
  2. attackUpdateMonsterPos
  3. runFromTarget_maxPathDistance

As well as a description of the new timeouts:

  1. ai_attack_route_adjust
  2. ai_attack_failedLOS
alisonrag commented 3 years ago

Please add a description of the new config parameters:

  1. attackRouteMaxPathDistance
  2. attackUpdateMonsterPos
  3. runFromTarget_maxPathDistance

As well as a description of the new timeouts:

  1. ai_attack_route_adjust
  2. ai_attack_failedLOS
  1. https://openkore.com/wiki/AttackRouteMaxPathDistance
  2. https://openkore.com/wiki/AttackUpdateMonsterPos
  3. https://openkore.com/wiki/RunFromTarget_maxPathDistance
  4. https://openkore.com/wiki/Timeouts.txt#AI_Route
ya4ept commented 3 years ago

@Henrybk @alisonrag should we replace all distance () calls with blockDistance ()?

alisonrag commented 3 years ago

@Henrybk @alisonrag should we replace all distance () calls with blockDistance ()?

blockdistance seems more like client, but we need to check what happens with this change, how different openkore will act