View unanswered posts | View active topics It is currently Thu Apr 23, 2026 5:25 am



Reply to topic  [ 12 posts ] 
 Alien filter on Grimy’s 
Author Message
Commander
User avatar

Joined: Wed May 03, 2006 2:00 am
Posts: 1722
Location: USA
Unread post 
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.

_________________
Coconut Telegraph (ICQ)#586137616
Team Speak3@ 220.244.125.70:9987
Founding Member -=[Team Kraaken]=- Winner of Gridwars 2010 - Ka Pla
Image
Jesus wounldn't Subspace Crawl


Thu Jan 18, 2007 12:09 am
Profile ICQ YIM
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 
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.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Thu Jan 18, 2007 12:53 am
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 
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+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Thu Jan 18, 2007 1:45 am
Profile WWW
Commander
User avatar

Joined: Wed May 03, 2006 2:00 am
Posts: 1722
Location: USA
Unread post 
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 

_________________
Coconut Telegraph (ICQ)#586137616
Team Speak3@ 220.244.125.70:9987
Founding Member -=[Team Kraaken]=- Winner of Gridwars 2010 - Ka Pla
Image
Jesus wounldn't Subspace Crawl


Thu Jan 18, 2007 1:47 am
Profile ICQ YIM
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 
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

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Thu Jan 18, 2007 7:01 am
Profile ICQ WWW
Commander
User avatar

Joined: Wed May 03, 2006 2:00 am
Posts: 1722
Location: USA
Unread post 
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.

_________________
Coconut Telegraph (ICQ)#586137616
Team Speak3@ 220.244.125.70:9987
Founding Member -=[Team Kraaken]=- Winner of Gridwars 2010 - Ka Pla
Image
Jesus wounldn't Subspace Crawl


Thu Jan 18, 2007 5:29 pm
Profile ICQ YIM
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post 
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+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Thu Jan 18, 2007 9:39 pm
Profile WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 
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.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Thu Jan 18, 2007 10:55 pm
Profile ICQ
Commander
User avatar

Joined: Wed May 03, 2006 2:00 am
Posts: 1722
Location: USA
Unread post 
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.

_________________
Coconut Telegraph (ICQ)#586137616
Team Speak3@ 220.244.125.70:9987
Founding Member -=[Team Kraaken]=- Winner of Gridwars 2010 - Ka Pla
Image
Jesus wounldn't Subspace Crawl


Thu Jan 18, 2007 11:08 pm
Profile ICQ YIM
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 
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.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Fri Jan 19, 2007 12:23 am
Profile ICQ
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post 
Hm. Can you not setTextLineTrigger on #27? I haven't tried... I'm guessing it didn't work for you guys. Anyone?

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Fri Jan 19, 2007 2:45 am
Profile ICQ WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post 
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.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Fri Jan 19, 2007 2:51 am
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.