C | 6542 | processLockMap(CoreLogic.pm)

This place is for Closed bug reports only. NOT for asking help!

Moderators: Moderators, Developers

Message
Author
realyigo
Noob
Noob
Posts: 2
Joined: 10 Apr 2008, 10:05

C | 6542 | processLockMap(CoreLogic.pm)

#1 Post by realyigo »

These two lines will keep the range in the upper right of the lock coordinate, But which should be around the lock coordinate.
$lockX += (int(rand($config{lockMap_randX}))+1) if ($config{lockMap_randX} ne '');
$lockY += (int(rand($config{lockMap_randY}))+1) if ($config{lockMap_randY} ne '');

I found this bug when I bot in ein_fild10, this map has two part(south part and north part) seperate by a river connect by a bridge. two part have different monster. I want bot int the north part. So I write this.
lockMap_x 400
lockMap_y 400
lockMap_randX 400
lockMap_randY 190
(400,400) is the upper right point of the map.
It works fine when you are in the map, But after you leave the map(like autobuy,autostorage...). You can't get back.
You get this message and you lockMap is set to none.
"Invalid coordinates specified for lockMap, coordinates are unwalkable"

The caculation in processRandomWalk is ok:
$randX = int($config{'lockMap_x'} - $config{'lockMap_randX'} + rand(2*$config{'lockMap_randX'}+1)) if ($config{'lockMap_x'} ne '' && $config{'lockMap_randX'} ne '');
$randY = int($config{'lockMap_y'} - $config{'lockMap_randY'} + rand(2*$config{'lockMap_randY'}+1)) if ($config{'lockMap_y'} ne '' && $config{'lockMap_randY'} ne '');

So I think we should change these lines in processLockMap
$lockX += (int(rand($config{lockMap_randX}))+1) if ($config{lockMap_randX} ne '');
$lockY += (int(rand($config{lockMap_randY}))+1) if ($config{lockMap_randY} ne '');

to
$lockX = int($config{'lockMap_x'} - $config{'lockMap_randX'} + rand(2*$config{'lockMap_randX'}+1)) if ($config{'lockMap_x'} ne '' && $config{'lockMap_randX'} ne '');
$lockY = int($config{'lockMap_y'} - $config{'lockMap_randY'} + rand(2*$config{'lockMap_randY'}+1)) if ($config{'lockMap_y'} ne '' && $config{'lockMap_randY'} ne '');

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: Bug in processLockMap(CoreLogic.pm)

#2 Post by Technology »

1) At first i want to point wrong usage of the configuration out.

With your current settings, the next formula applies in processRandomWalk:
$randX = int($config{'lockMap_x'} - $config{'lockMap_randX'} + rand(2*$config{'lockMap_randX'}+1)) if ($config{'lockMap_x'} ne '' && $config{'lockMap_randX'} ne '');

Lets see what the maxima of the coordinates for X & Y are with your current configuration:
for min number of rand: X = 400-400+2*0 = 0 ; Y = 400-190+2*0=210
for max number of rand: X = 400-400+2*400=800 ; Y = 400-190+2*190=590
That doesn't seem right does it?

But it actually works like this:
Lets say this is a map with min coordinates (0,0) & max coordinates (4,4)
Y
^
|
| x x x x x
| x x x x x
| x x x x x
| x x x x x
| x x x x x
---------------------------> X
(0,0)
(4,4)
(3,1)

Lets say we want the bot to stay on condition: x-coordinate > 1 AND y-coordinate < 3
then we set it up the config like this:
middle coordinates of our area
lockMap_x 3
lockMap_y 1

coordinates that define range from middle coordinates of our area
lockMap_randX 1
lockMap_randY 1


for max number of rand: X = 3-1+2*1 = 4 ; Y = 1-1+2*1 = 2
for min number of rand: X = 3-1+2*0 = 2 ; Y = 1-1+2*0 = 0

2) i will look into processLockMap later ok?
In your case, you only want to bot above a certain y
i don't see why you should set lockMap_randX
because look at this:
$lockX = int(rand($field{width}) + 1) if (!$config{lockMap_x} && $config{lockMap_y});

don't have time to work on this atm, but it could be that there is a mistake in processLockMap.
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

realyigo
Noob
Noob
Posts: 2
Joined: 10 Apr 2008, 10:05

Re: Bug in processLockMap(CoreLogic.pm)

#3 Post by realyigo »

My config may not be efficient, but it is not wrong.
When it exceeds the map area, openkore will re-caculate a coordinate until the bot could reach that point.
When I write:
lockMap_x 400
lockMap_y 400
lockMap_randX 400
lockMap_randY 190
I know it will exceed the map. But it is easy to config. Otherwise I will caculate the center point of the bot area:
In your example, it is:
lockMap_x 3
lockMap_y 1
and the radius:
In your example, it is:
lockMap_randX 1
lockMap_randY 1

I will follow your instructions, my config is inefficient. 3/4 of its caculation is useless.
So it may look like:
lockMap_x 200
lockMap_y 305
lockMap_randX 200
lockMap_randY 95

But which should be pointed out:
lockMap_x 400
lockMap_y 400
lockMap_randX 400
lockMap_randY 190
is not wrong.
Because the specific is:
If lockMap, lockMap_x, and lockMap_y are set, and you set these two options, Kore will always try to stay at a random spot inside the lockMap within an area lockMap_randX distance to the left or to the right of lockMap_x, and lockMap_randY distance above or below lockMap_y.

and processLockMap is wrong.
Because the caculation result will only be the right and above of the (lockMap_x,lockMap_y)

BTW, are you VCL.
The style you talk is really similar to VCL, clear and reasonable.
Are you participate in other bot project? Bring me please.
Ro is good, but out of ages. And bot some kind of ruins it.
I live in a country where more than 40,000,000 people playing online game. And the market is 3 billion USD and it is still increase.
The top 3 online game company second-quarter earnings report(million USD)
NYSE Grand total Net income
SNDA 122,1 40,8
NTES 104,0 63,9
GA 73,6 51,1
They are trade at Nasdaq, but they are totally local company.

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: Bug in processLockMap(CoreLogic.pm)

#4 Post by Technology »

I am not VCL.
If I was him, then for what reason would I be hiding my identity? :D

Btw, i have looked into the processLockMap function.
Now I see why your configuration isn't giving you the desired results.

Next formula's apply for your configuration:
$lockX = int($config{lockMap_x}) if ($config{lockMap_x} ne '');
$lockX += (int(rand($config{lockMap_randX}))+1) if ($config{lockMap_randX} ne '');

The smallest X coordinate outcome is 400+1 and this coordinate is ofcourse not walkable.

I was bored, so I went to that map myself to check out the 'optimal' coordinates.
-top walkable y coordinate: 372
-bottom walkable of the north island y coordinate: 240
If we get the arithmetical mean of these coordinates we get the middle y coordinate of the northern island: (372+240)/2 = 306
Then we need the distance from this coordinate to first 2 coordinates: 306-240=66

Try next configuration without any modification to the source, i'm almost certain that it will work like how it is supposed to.
lockMap_x
lockMap_y 306
lockMap_randX
lockMap_randY 66


Tough, there is not much buggless code thats any more complex than: print "Hello World\n";
So by looking at the code i actually found a very very tiny bug in it.

Every coordinate calculation in these two function blocks is similar to this:
int(rand($field{max}) + 1);
This piece of code has a minimal output of 1 !
But what about coordinate 0?
RANGE: 1- $field{max}-1+1

the code should be like this instead:
int(rand($field{max}+1));
RANGE: 0 - $field{max}

http://perldoc.perl.org/functions/rand.html
Going to commit this to SVN.

[EDIT 1]
you are right about that bug btw, for route calculation in the lockmap:
for y it only adds up to the top
for x it only adds up to the right
going to change that aswell soon.

[EDIT2]
The route calculation in lockMap is fixed now.
in svn
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

Post Reply