Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 07.06.2007, 08:47   #1
zcold
Архивный участник
 
Join Date: Nov 2005
Posts: 146
Default [share] small tool to change AI constants

hey all!

everybody knows, that NC uses some "source code" to compile ai.obj
and not a secret, that they use some variables (multipliers) to tune it before production release.
in compilied ai it's looks like:

myself.AddTimerEx(1001, 10 * 60 * 1000);

or

if (myself.sm.hp < myself.sm.max_hp * 2.000000 / 4.000000) { }

The result of 10*60*1000 is always same. And result of 2/4 is always same.
So, why we need to do this calculations every time handler called?

Here is some tool to check your AI for things like that: http://dev.blacksun.com.ua/download/bsaic.exe

In my AI, I found more than 9k of this "things to optimize".
This is alpha version of tool, so check your AI before sending to production.
Source file must be saved in ascii.

Sorry for "bad english"
zcold is offline  
Old 07.06.2007, 09:03   #2
smeli
Архивный участник
 
Join Date: Apr 2006
Posts: 181
Default

>myself.AddTimerEx(1001, 10 * 60 * 1000);

I have feeling that those 10, 60 are smething not just constans
but decompiler decompiled them as constants

or my feeling wrong?
smeli is offline  
Old 07.06.2007, 09:11   #3
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by zcold View Post
hey all!

everybody knows, that NC uses some "source code" to compile ai.obj
and not a secret, that they use some variables (multipliers) to tune it before production release.
in compilied ai it's looks like:

myself.AddTimerEx(1001, 10 * 60 * 1000);

or

if (myself.sm.hp < myself.sm.max_hp * 2.000000 / 4.000000) { }

The result of 10*60*1000 is always same. And result of 2/4 is always same.
So, why we need to do this calculations every time handler called?

Here is some tool to check your AI for things like that: http://dev.blacksun.com.ua/download/bsaic.exe

In my AI, I found more than 9k of this "things to optimize".
This is alpha version of tool, so check your AI before sending to production.
Source file must be saved in ascii.

Sorry for "bad english"
this is for Decompiled code? or for AI.obj original code?
HF is offline  
Old 07.06.2007, 09:17   #4
zcold
Архивный участник
 
Join Date: Nov 2005
Posts: 146
Default

Quote:
Originally Posted by HF View Post
this is for Decompiled code? or for AI.obj original code?
for original ai.obj (saved in ascii)
zcold is offline  
Old 07.06.2007, 09:18   #5
zcold
Архивный участник
 
Join Date: Nov 2005
Posts: 146
Default

Quote:
Originally Posted by smeli View Post
>myself.AddTimerEx(1001, 10 * 60 * 1000);

I have feeling that those 10, 60 are smething not just constans
but decompiler decompiled them as constants

or my feeling wrong?
in compilied file it's looks like:

push_const 10
push_const 60
mul
push_const 1000
mul

and we can do just
push_const 60000

the result will be same
zcold is offline  
Old 07.06.2007, 09:26   #6
Nevyn
Архивный участник
 
Join Date: Sep 2006
Posts: 114
Default

Will it give any noticeble permformance change? Its not like those calculations takes for ever :P
Nevyn is offline  
Old 07.06.2007, 11:00   #7
petre1980
Архивный участник
 
Join Date: Jan 2007
Posts: 45
Default

Well i tryied on my server, everything works fine, the changes have the same effect, maybe some small performance in calculation improve. (free de ALU from calculating some useless mul, add and sub operations)
petre1980 is offline  
Old 07.06.2007, 11:09   #8
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by petre1980 View Post
...
maybe some small performance in calculation improve.
This information show your server to you?
HF is offline  
Old 07.06.2007, 11:24   #9
petre1980
Архивный участник
 
Join Date: Jan 2007
Posts: 45
Default

Quote:
Originally Posted by HF View Post
This information show your server to you?
No, i just think that's the reason for that changes. (optimize the AI for peformance, free de CPU from some useless calculation)
petre1980 is offline  
Old 07.06.2007, 11:52   #10
Aikeleer
Архивный участник
 
Join Date: Jun 2005
Posts: 374
Default

In noticed those things too, I was like 'why?'. Never took the liberty to change them all. Good thing you did it
Aikeleer is offline  
Old 07.06.2007, 21:58   #11
Freeman
Архивный участник
 
Join Date: Jul 2006
Posts: 39
Default

[quote=zcold;87882]hey all!
myself.AddTimerEx(1001, 10 * 60 * 1000);

If you are still curious… Try to measure how much “processor time” it will cost to execute push_const one million times and to execute “9 thousands of add/sub/mul/div” one million times… divide the difference by one million back and post results here =)2nd thing… for example, usually, I edit ai.obj file directly and when I’m finished to create of to fix something, I decompile full version of a file… or when I modified the decompiler, I also need to re-decompile full version of ai.obj. In some time I try to see some_class.txt and see thee optimized version AddTimerEx(1001, 7800000) or not optimizer AddTimerEx(1001, 130 * 60 * 1000). How much time will it take for a human to de-calculate 7800000 into 130 seconds.. and I’ll be forced to by myself to do it each time I read any of 3k+ file of classes.I preferred to optimize my work and leave for server CPU “more work”…p.s. don’t beat me, it’s only my point of view by now)
Freeman is offline  
Old 08.06.2007, 01:54   #12
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default

you can do both, use a source version with 10 * 60 * 1000 which is very easy to understand the time and the optimized version in the compiled one. anyway doing 10 * 10 a millon times doesn't affect the performance. remember the cpu is most of the time at 4% usage
Sauron is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 14:56.