|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 15, 2014 11:40 PM |
|
|
Salamandre, try these coordinates x = 14, y = 13, z = 0 and say what R1 will you have?
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 15, 2014 11:40 PM |
|
|
Ok, it seems to work very well, under 50 I always get upgraded, over 50 not upgraded. here is the final script, changed to trigger when you click on monster.
ZVSE
!?CM0;
!!CM:P?y2/?y3/?y4; get location of click
!!OBy2/y3/y4:T?y5;
!!FU&y5<>54:E; exit if not monster
;R1 = a*x + b*y + c*z + d
!!VRy5:S196143423*y2;
!!VRy6:S928924629*y3;
!!VRy7:S348991063*y4;
!!VRv2:Sy5+y6+y7+2148842073;
;R2 = R1 / 65536 (integer division here!)
!!VRv3:Sv2:65536;
!!VRv3&v3<0:+65536;
;R3 = R2 % 32768
!!VRv4:Sv3%32768;
;R4 = R3 % 100
!!VRv5:Sv4%100;
!!IF:M^%V5^;
@Alex, one moment, I try. I got R1=-208999012 but R4=78 and stack was not upgraded.
____________
Era II mods and utilities
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 15, 2014 11:46 PM |
|
|
Try this:
1. R1 = a*x + b*y + c*z + d
2. R2 = R1 / 65536 (integer division here!)
3. R3 = R2 % 32768
3a. If R3 < 0 then R3 = R3 + 32767
4. R4 = R3 % 100
Where
a = 196143423
b = 928924629
c = 348991063
d = 2148842073
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 15, 2014 11:48 PM |
|
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 15, 2014 11:51 PM |
|
Edited by AlexSpl at 23:52, 15 Dec 2014.
|
Well, now you might wanna do some testing
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 15, 2014 11:53 PM |
|
|
ok, who wanna test also?
ZVSE
;click on monster stack.
;will display message if stack has upgraded form
!?CM0;
!!CM:P?y2/?y3/?y4; [get location of click]
!!OBy2/y3/y4:T?y5;
!!FU&y5<>54:E; [exit if no monster stack]
!!VRy5:S196143423*y2;
!!VRy6:S928924629*y3;
!!VRy7:S348991063*y4;
!!VRv2:Sy5+y6+y7+2148842073;
!!VRv3:Sv2:65536;
!!VRv4:Sv3%32768;
!!VRv4&v4<0:+32767;
!!VRv5:Sv4%100;
!!IF&v5<50:M^These neutrals have upgraded stack^; [display result]
Thanks both
____________
Era II mods and utilities
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 15, 2014 11:55 PM |
|
|
Quote: ;if result >50, stack does not have upgrade
You mean, if result >= 50 ...
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 15, 2014 11:56 PM |
|
|
Fixed, sorry. Sunday I go holidays and I will start to look into split algorithms. If you have any extra data which could help me, please, especially about those tiles cases
____________
Era II mods and utilities
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 12:05 AM |
|
|
Now we should probably concentrate on the splitting problem, shouldn't we?
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 16, 2014 12:06 AM |
|
|
From Friday, for me. I feel we will make it.
btw, I only tested on small map, the upgraded coded will be compatible with bigger sizes too or need different values?
____________
Era II mods and utilities
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 12:08 AM |
|
|
Quote: From Friday, for me. I feel we will make it.
No doubt
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 12:11 AM |
|
Edited by AlexSpl at 00:23, 16 Dec 2014.
|
Quote: btw, I only tested on small map, the upgraded coded will be compatible with bigger sizes too or need different values?
Yeah, in LMOracle this code works fine for 252x252.
Here, btw, the link to the latest version with HotA 1.3.3 support:
http://handbookhmm.ru/forum/download/file.php?id=564
|
|
kicferk
Known Hero
|
posted December 16, 2014 12:21 AM |
|
|
Ok, I played with it, and it seems to be working
I found one case in which the result said there would be upgraded stack and did I not get one. But it was due to the splitting. I had large army, and I got the rare case of 1 stack and upgraded stack together.
I tested again with the same save but smaller army, and got an upgraded stack. Which means that for the next part, the case with small number of stacks can have upgrades, but it won't have any if you only fight one stack. It also means I did not find any case of the script not working
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 12:34 AM |
|
|
Of course, if you face a single stack it will never be upgraded unless you're attacking upgraded monsters. You also will never see an upgraded stack when fighting monsters who don't have upgrades
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 07:06 PM |
bonus applied by angelito on 21 Dec 2014. |
Edited by AlexSpl at 19:09, 16 Dec 2014.
|
The Splitting Problem
1. Find both Army_Power and Neutrals_Power. They are just the sum of AI values of all creatures in the corresponding armies. A powerful hero at your side doesn't change anything.
2. Find k = Army_Power / Neutrals_Power.
3. Determine the basic splitting:
k < 0.5 then 7 stacks
0.5 <= k < 0.67 then 6 stacks
0.67 <= k < 1 then 5 stacks
1 <= k < 1.5 then 4 stacks
1.5 <= k < 2 then 3 stacks
k >= 2 then 2 stacks
Note:
Here all the floating point numbers are of double precision, or type; sizeof(double) = 8 bytes.
4. Find the actual splitting:
1. R1 = a*x + b*y + c*z + d
2. R2 = R1 / 65536 (integer division here!)
3. R3 = R2 % 32768
3a. If R3 < 0 then R3 = R3 + 32767
4. R4 = R3 % 100 + 1
Where:
a = 1550811371
b = -935900487
c = 1943276003
d = -1120346418
Then,
if R4 <= 20 decrease the number of stacks by 1
if R4 >= 80 increase the number of stacks by 1 unless you have already 7.
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 16, 2014 07:45 PM |
|
|
Thanks, finding AI value is easy, but getting two values percentage in erm I have no clue how, asked in russian forums and waiting. We can only use addition, extract, multiply, division, remainder and integers thus this link didn't help me much.
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 07:47 PM |
|
|
You should finally start to use floating point numbers
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted December 16, 2014 08:01 PM |
|
|
Hmm, confused. I am testing and have this:
18400 our army value
10500 neutrals AI value
Result gives me that our army is 175% more powerful. Is this correct? Then I get only 3 stacks split, which suggest our army is 200% better
____________
Era II mods and utilities
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 08:07 PM |
|
|
However, you can still use integers.
For example,
0.5 <= k < 0.67 means 1/2 <= Army_Power / Neutrals_Power < 67/100, or:
1 * Neutrals_Powers <= 2 * Army_Power
and
100 * Army_Power < 67 * Neutrals_Power
Is this idea clear enough?
|
|
AlexSpl
Responsible
Supreme Hero
|
posted December 16, 2014 08:13 PM |
|
Edited by AlexSpl at 20:16, 16 Dec 2014.
|
Quote: Result gives me that our army is 175% more powerful. Is this correct? Then I get only 3 stacks split, which suggest our army is 200% better
Not exactly. If your army is 175% more powerful then you will face (3 + Deviation) stacks, where Deviation is -1, 0, or 1. If your army were 200% more powerful, you would have encountered (2 + Deviation) stacks.
|
|
|