www.ClassicTW.com
https://mail.black-squirrel.com/

Alien filter on Grimy’s
https://mail.black-squirrel.com/viewtopic.php?f=15&t=18452
Page 1 of 1

Author:  Parrothead [ Thu Jan 18, 2007 12:09 am ]
Post subject: 

Ive posted one of my alien filters on grimy's for the purpose of promoting some open discussion on the the use of ansiline getword getwordpos vs gettext cuttext for speed and accurate fiters.Hopwfully I can learn something from others on this.

Author:  Promethius [ Thu Jan 18, 2007 12:53 am ]
Post subject: 

Parrothead wrote:
Ive posted one of my alien filters on grimy's for the purpose of promoting some open discussion on the the use of ansiline getword getwordpos vs gettext cuttext for speed and accurate fiters.Hopwfully I can learn something from others on this.


I just use:
getWordPos CURRENTANSILINE $pos ": "

if $pos > 0 then it is an alien. I "assume" that getword and getwordpos are faster because they are just detecting the existance of something where getText has to perform a copy text after getting the position of the start and end.

Author:  ElderProphet [ Thu Jan 18, 2007 1:45 am ]
Post subject: 

That seems like a good technique Promethius. For clarity, you might use the char codes instead, which should equate to this:

getWordPos CURRENTANSILINE $pos ": " & #27 & "[1;36m" & #27 & "[33m"

Or even better, define that as a variable, and test for the variable's position.

I posted my ansi parser that converts the odd char codes to the # equivalents, ready to be copy/pasted from the log file it generates.

At least, I think I posted it on Grimy.

Anyway, I believe that getWordPos is faster than getText. cutText probably beats them all though. But hey, I gave you the getTimer feature so you can determine these things for yourself, then enlighten the rest of us

+EP+

Author:  Parrothead [ Thu Jan 18, 2007 1:47 am ]
Post subject: 

i tried that Prom and got intermitant misses on the screening but i will try again.It may have been do to not resetting the current ansi code by recalling the prompt.
And yes EP the script is their for download I use it often Great tool!
thanks 

Author:  Singularity [ Thu Jan 18, 2007 7:01 am ]
Post subject: 

K. Grimy finally got back up so I posted my fighit snippet too.

When I ran a speed test I found that getText is dependant on the length of the text being processed. I don't know if that's true of getWord or cuttext. But after 100000 iterations I was able to average under .05ms w/ my old snippet.

This is the CURRENTANSILINE for a subby I'm in. #27 is replaced by _ for clarity.

_[K_[1A_[1;33mDeployed Fighters _[0;32mReport Sector _[1;33m4465_[0;32m: _[1;36m_[33mAscian Wanderer_[36m Jedi Boexif's _[0m_[31mAscian Troller_[32m entered sector.

As you can see, prome's "_[1;36_[33m" snippet would work if #27 was there (dang forum), but only if the alien race color is always [33m. I'd also be a little concerned about false positives (dunno, not sure if it would ever happen) by using the full ansi line as a test.

What's interesting is I tested this in several variations...

1. With the code preset to a variable like:
setVar $test #27 & "[1;36m" & #27 & "[33m"

2. With the code being generated each time:
getWordPos CURRENTANSILINE $pos #27 & "[1;36m" & #27 & "[33m"

And got 2 very different results

The first was .0313ms for a 100k iteration avg. The 2nd was .0408ms. So building the line each time is adding some .009ms to the process.

When I added a getWord in there like this:

Code:
getWord CURRENTANSILINE $alien_check 6
getWordPos $alien_check $pos #27 & "[1;36m" & #27 & "["
if ($pos > 0)
     # Blah
end


I went up another .01ms. So by doing the combination...

Code:
getWord CURRENTANSILINE $alien_check 6
getWordPos $alien_check $pos $alien_ansi_code
if ($pos > 0)
end


And setting $alien_ansi_code to:
setVar $alien_ansi_code #27 & "[1;36m" & #27 & "["

Earlier, outside of the 100k test loop, I got:
Milliseconds per execution: 0.0416

Which is pretty dang fast, only marginally slower than Prome's and only because of the getWord to smooth out my one concern.

A cuttext only added about .001ms. A gettext only about .003ms there.

This seems to suggest that getText is actually faster than getWord. So I'm going to test it to confirm.

Code:
getText CURRENTANSILINE $alien_check ": " "'s"
getWordPos $alien_check $pos $alien_ansi_code
if ($pos > 0)
     # echo "*Alien*"
end


Where $alien_ansi_code is set.

I get an amazing...
Milliseconds per execution: 0.0367

Which is faster than my getWord variation and dang close to Prome's first variation.

getText seems to only take about .005ms !!

Food for thought.

Conclusion:
These are TINY amounts of time. So fast you won't recognize it, even in a photon script. But if you're looking to improve your time on 2.04 it seems that you should:

1. Use getText instead of getWord
2. Use cutText instead of getText
3. Pre-set as many variables outside of the input testing

Author:  Parrothead [ Thu Jan 18, 2007 5:29 pm ]
Post subject: 

Ok I did some testing of my own but taking into account the whole loop including the trigger fire but not the reset time reset time by utilizing 'processin' command to fire trigger from second script.
I ran Proms Sings and Mine approx 10000 times each.
the total processing time average including test as front window and back ground resulted in a average differential so small that testing inconsistances (windows processes may have triggered during test)make them moot.
So I would have to agree with sing that it is game inconsequential.
 
But it was a fun exchange of info.Thanks for taking part Gentlemen.

Author:  ElderProphet [ Thu Jan 18, 2007 9:39 pm ]
Post subject: 

Very nice work all. Let me offer two more tips.

1. Initialize variables. Variable creation takes time, so creating them before their first use saves a tiny amount of time. This can be demonstrated with the following code:

# My CPU is a Core 2 Duo 2.4 GHz,
# but the 2nd core doesn't count
setVar $MHz 2400
getTimer $start
getTimer $stop
setVar $lapse1 (($stop - $start) / $MHz)
getTimer $start
getTimer $stop
setPrecision 10
setVar $laps2 (($stop - $start) / $MHz)
echo "*1. " $lapse1 "*2. " $lapse2

The only difference between the first and second time is the time it takes to intialize the variables $start and $stop, but it is measureable.

2. Use the getTimer to measure code execution, without the overhead of the other script elements, like while loops. Do this by getting the start timer value just before code execution, and the stop timer value just after, as follows:

setVar $start 0
setVar $stop 0
setVar $pos 0
setVar $ansiline "InsertRealAnsiLineHere"
setVar $test #27 & "[1;36m" & #27 & "[33m"
setVar $iterations 1000
setVar $a 1
while ($a <= $iterations)
     getTimer $start
     getWordPos $ansiline $test
     getTimer $stop
     add $cumulative ($stop - $start)
     add $a 1
end
setPrecision 10
echo "*Time per execution: " (($cumulative / $iterations) / $MHz) " ms*"

+EP+

Author:  Promethius [ Thu Jan 18, 2007 10:55 pm ]
Post subject: 

From what I can tell, the aliens alway have the same ANSI sequence (color) after the ":". I use the ":" and ansi to eliminate any false positives on the full line. I don't think I have ever had a false launch on an alien since going to that sequence.

Author:  Parrothead [ Thu Jan 18, 2007 11:08 pm ]
Post subject: 

I will do that prom looking back in my notes i was not using ":" previously I started with #27.What i am trying to work up to is a simple set of filters that not only ignore aliens but other kinds of spam as well without script performance breakdown or multiple filters.I think I will try to use your method but reverse it to include only trader messages instead of excluding aliens if it is possible therefor eliminating spam from fed or becons shipnames etc.

Author:  Promethius [ Fri Jan 19, 2007 12:23 am ]
Post subject: 

Parrothead wrote:
I will do that prom looking back in my notes i was not using ":" previously I started with #27.What i am trying to work up to is a simple set of filters that not only ignore aliens but other kinds of spam as well without script performance breakdown or multiple filters.I think I will try to use your method but reverse it to include only trader messages instead of excluding aliens if it is possible therefor eliminating spam from fed or becons shipnames etc.


I believe that a trader's hit is the same as the alien up to a point in regard to the ANSI string.

   getwordpos CURRENTANSILINE $pos ": "
   getwordpos CURRENTANSILINE $pos2 ": "

$pos2 is what you will see for a trader and as is evident it is also in the alien string. The $pos2 is an alternative to the if/end testing of the first letter of a message for spoofing.

if ($pos = 0) and ($pos2 > 0)
# then let's kill someone
end

I would love to see a setAnsiTextTrigger command, but we can work around it not being there.

Author:  Singularity [ Fri Jan 19, 2007 2:45 am ]
Post subject: 

Hm. Can you not setTextLineTrigger on #27? I haven't tried... I'm guessing it didn't work for you guys. Anyone?

Author:  Promethius [ Fri Jan 19, 2007 2:51 am ]
Post subject: 

Singularity wrote:
Hm. Can you not setTextLineTrigger on #27? I haven't tried... I'm guessing it didn't work for you guys. Anyone?


I've tried the ANSI string, but not #27 and it didn't trigger.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/