Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Failed concept(for now ?): HealthScanner/HealthRepairV4

 
   Game Forums (Home) -> Core War RSS
Next:  Problem with FSX Logbook  
Author Message
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 1) Posted: Thu Dec 20, 2007 10:29 pm
Post subject: Failed concept(for now ?): HealthScanner/HealthRepairV4
Archived from groups: rec>games>corewar (more info?)

Hello,

I decided to give the health scanner one more try so I started from scratch
to copy two instances to a location with good offsets and spawn programs
etc... (copy program from scratch rest of the program copy pasted into it Wink
Smile and modified just a little bit.)

So now it's kinda working as it should, I simply patched up the offsets and
euhm... only thing missing is the dead/alive status thing... so once a copy
goes dead it can't be revived by the other.

Still interesting to see the code in action... it's not so great at
surviving... threads keeping hanging in the trap or are killed off...

There is code present to spawn new threads... but it doesn't seem very
effective or anything... they just keeping dieing again.

Still failures can be interesting as well, so that's why I am posting it Wink

Maybe some other scanning concept might work better Wink

( code follows below )

Bye,
Skybuck.

;redcode
;name HealthRepairV4
;author SkybuckFlying
;strategy repairs itself
;version 4
;date 20 december 2007
;
; Let's try the health scanner again, but this time start from the start,
first copy two instances
; somewhere, then spawn enough threads to start them both, yeah, don't let
them spawn each other or so
; just fix and maybe add a little respawner.
;
;
;
;
; It works but it needs to respawn it's killed of threads than maybe it
could survive, do that in a next version.
; Ok that's now fixed.
;
; Only problem that remains is reviving the dead copy that was restored. At
least against core bombers/core clear.
; It should be able to survive random/nasty bombers... Smile
; Nope it doesn't even survive that... threads just keeping hanging in the
trap, or die off or something
; maybe the concept is just flawed or needs to be different.
;
; Even survivor v8 or so is better at surviving Wink Smile
; Hmm not true... even survivor v8 dies pretty fast Wink Smile
; maybe the trick is to complete a full loop of instructions and only then
figure out if something is dead or not... might be better
; than you known if the copy is intact or dead...
; but that's difficult because you can't execute the healing code... so you
won't know... you probably have to scan to be sure if it's intact or not Wink
Smile
;
; Another problem is it only detects disease spl $0, $0 and dat $0, $0.
;
; For example disease dat #0 is not detected
;
; Code is messy and uses patched-up offsets... just testing out the concept
Wink Smile
;
;
; copy one instance to location 2000
; copy second instances to location 5000
; makes it easy to set offsets later

CopyBegin
; mov.ab #3000-19, HealthScannerScanPosition
; mov.ab #-20, HealthScannerOwnPosition

mov.ab #3000-(19+12), HealthScannerScanPosition
mov.ab #-20-12, HealthScannerOwnPosition

mov.ab #(2000 - SourceDest)-2, SourceDest
CopyReCopy
mov.a #InstanceBegin - SourceDest, SourceDest
mov.ab #InstanceLength, CopyRepeat

Copy mov }SourceDest, >SourceDest
CopyRepeat djn Copy, #0
mov.ab #(5000 - SourceDest)-7, SourceDest

; mov.ab #-3000-19, HealthScannerScanPosition
; mov.ab #-20, HealthScannerOwnPosition

mov.ab #-3000-(19+12), HealthScannerScanPosition
mov.ab #-20-12, HealthScannerOwnPosition
CopyAgain djn CopyReCopy, #2
SourceDest nop $0, $0

; if you disable any instruction make sure to replace with nop's otherwise
offsets wrong Wink
spl SpawnProgram2Begin ; maybe not really necessary but this gets it up
running faster Wink
spl SpawnProgram1Begin
; nop 1
; nop 1

djn 0, #5 ; wait a bit
mov.ab #1, Activate ;activate

; djn 0, #2 ; wait another little bit, no need to wait it seems Wink
nop 0

spl 2000-17 ; spawn thread checker
spl 5000-18 ; spawn thread checker

Activate dat $0, $0

SpawnProgram1Begin

processes1 equ 37 ; works for 1 to 512, should be adequate!
for 9+0* (a=512)
for ((processes1-1)/(a=a/2))%2==1 && processes1>a
spl 1
rof

for ((processes1-1)/a)%2==0 && processes1>a
mov.i -1,#0
rof
rof

SpawnProgram1End

jmz 0, Activate
Jump1 jmp 2000 - 15; ok let's start them at the trap then they will be
released by thread releasor.. hopefully, bit dangerous if they dont get
released but ok Wink Smile, they gonna get trapped anyway sooner or later Wink


SpawnProgram2Begin

processes2 equ 37 ; works for 1 to 512, should be adequate!
for 9+0* (a=512)
for ((processes2-1)/(a=a/2))%2==1 && processes2>a
spl 1
rof

for ((processes2-1)/a)%2==0 && processes2>a
mov.i -1,#0
rof
rof

SpawnProgram2End

jmz 0, Activate
Jump2 jmp 5000 - 23; should start at HealthScannerScanForStunDisease



CopyEnd

InstanceLength equ InstanceEnd - InstanceBegin

InstanceBegin


; rough estimate for now... some jumps jump over instructions so the real
ammount of cycles is lower
; might fine tune this later when done coding.
HealthScannerScanCycles equ 13 ; 13 more accurate
(HealthScannerScanEnd - HealthScannerScanBegin) ; rough estimate.
HealthScannerScanInstances equ InstanceLength

; for now don't scan the thread checker
;HealthScannerScanInstances equ HealthScannerScanEnd -
HealthScannerScanBegin

; spl HealthScannerCheckThreadCountBegin

WarriorMainLoopBegin

HealthScannerCheckThreadCountBegin

; trap any living threads
mov.a $0, HealthScannerTrap

; reset waiting time
mov.ab #HealthScannerScanCycles, HealthScannerWaitForTrap

; wait a while till they trapped
; they waiting time should equal the ammount of instructions the threads
have to execute to recycle a full loop cycle.
HealthScannerWaitForTrap djn HealthScannerWaitForTrap, #0

; reset threads to spawn
mov.ab #HealthScannerScanInstances, HealthScannerCalculateThreadsToSpawn

; see how many are trapped
; subtract trapped count from max instances
HealthScannerCalculateThreadsToSpawn sub HealthScannerTrappedThreadCount,
#0

; if no threads to spawn then jump to release threads
; or alternatively jump to check if remote checker thread is alive... if
not spawn one... nice !
jmz HealthScannerCreateMissingThreadsDone,
HealthScannerCalculateThreadsToSpawn

; one is not handled for now hope for the best

; create the missing threads
; let's use something simpel for now
; just spawn one thread for now
spl HealthScannerSpinnerBegin

; jmp FastThreadSpawnerBegin

HealthScannerCreateMissingThreadsDone


HealthScannerCheckThreadCountReleaseThreads

; reset trap count
mov #0, HealthScannerTrappedThreadCount

; release thread by modifieng the trap
mov.a #(HealthScannerSpinnerEnd-HealthScannerTrap), HealthScannerTrap

; jump back to thread checker Wink
jmp HealthScannerCheckThreadCountBegin

HealthScannerCheckThreadCountEnd

HealthScannerScanBegin

HealthScannerSpinnerBegin

; prevent the threads from going for, this instruction can be used to trap
to threads and release them again by change the jump etc.
; can be used to synchronize threads Smile
add #1, HealthScannerTrappedThreadCount

HealthScannerTrap jmp $0, $0

HealthScannerSpinnerEnd

; algorithm will be:

; scan for bad instruction
; if bad instruction found jump to cure, otherwise skip and do next line
; scan for next bad instruction
; if bad instruction found jump to cure, otherwise skip and do next line
; repeat scan etc.

HealthScannerScanForStunDisease
; we must not forget it has to be conccurent so increment scan position
for next thread to scan next cell.
; each thread will heal one cell only
; scan for bad instruction
sne HealthScannerStunDisease, >HealthScannerScanPosition

jmp HealthScannerCureStunDisease, <HealthScannerScanPosition; each jump
has to decrement the scan position to make it usefull and keep it as it was
nop $0, <HealthScannerScanPosition

HealthScannerStunDiseaseNotPresent

nop $0, >HealthScannerScanPosition
nop $0, <HealthScannerScanPosition
jmp HealthScannerStunDiseaseCured

HealthScannerCureStunDisease
; do something to the infected cell, make sure to increment scan position
for next thread
; let's bomb the infected cell which contains spl 0, 0 it will be
overwritten with dat $0, $0 to kill off spinning instances.
; only problem is if other warrior has it's own spl 0, 0 instruction
which will be killed and later restored
; warriors could therefore destroy each other's stun instruction so be
carefull with that and check it out what happens later on Wink
mov HealthScannerBomb, >HealthScannerScanPosition; mov
HealthScannerDebug, >HealthScannerScanPosition
nop $0, <HealthScannerScanPosition
jmp HealthScannerStunDiseaseCured

HealthScannerStunDiseaseCured

; place additional scans here etc.

HealthScannerScanForBombDisease
; we must not forget it has to be conccurent so increment scan position
for next thread to scan next cell.
; each thread will heal one cell only
; scan for bad instruction
sne HealthScannerBombDisease, >HealthScannerScanPosition

jmp HealthScannerCureBombDisease, <HealthScannerScanPosition; each jump
has to decrement the scan position to make it usefull and keep it as it was
nop $0, <HealthScannerScanPosition

HealthScannerBombDiseaseNotPresent

nop $>HealthScannerOwnPosition, >HealthScannerScanPosition
nop <HealthScannerOwnPosition, <HealthScannerScanPosition
jmp HealthScannerBombDiseaseCured

HealthScannerCureBombDisease
; do something to the infected cell, make sure to increment scan position
for next thread
; let's copy our own instruction to the other warrior, assuming our copy
is still good
mov >HealthScannerOwnPosition, >HealthScannerScanPosition; mov
HealthScannerDebug, >HealthScannerScanPosition
nop <HealthScannerOwnPosition, <HealthScannerScanPosition
jmp HealthScannerBombDiseaseCured

HealthScannerBombDiseaseCured

; place additional scans here etc.

; repeat scan
jmp HealthScannerScanBegin
HealthScannerScanEnd

HealthScannerData

HealthScannerScanPosition dat $0, #0
HealthScannerOwnPosition dat $0, #0
HealthScannerBomb dat $0, $0
HealthScannerTrappedThreadCount dat $0, #0

HealthScannerDiseases

HealthScannerStunDisease spl $0, $0
HealthScannerBombDisease dat $0, $0
; HealthScannerDebug dat $666, $666

InstanceEnd
dat $777, $777

 >> Stay informed about: Failed concept(for now ?): HealthScanner/HealthRepairV4 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 2) Posted: Fri Dec 21, 2007 12:07 am
Post subject: Re: Failed concept(for now ?): HealthScanner/HealthRepairV4 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hmm maybe not so failed after all.

If the other copy manages to revive the checker thread, it might work, and
it might even work quite well.

Just gotta get it working somehow Wink

Haven't tried yet with the new code.


Bye,
Skybuck.

 >> Stay informed about: Failed concept(for now ?): HealthScanner/HealthRepairV4 
Back to top
Login to vote
Skybuck Flying

External


Since: May 25, 2006
Posts: 295



(Msg. 3) Posted: Fri Dec 21, 2007 12:07 am
Post subject: Re: Failed concept(for now ?): HealthScanner/HealthRepairV4 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

One way to improve on it might be to prevent the threads from being trapped,
since they should be in sync anyway...

and the final thread could execute special code... and then maybe by
inserting enough instructions it might be auto-synced into place or so. so
no trapping needed, might work.

Bye,
Skybuck.
 >> Stay informed about: Failed concept(for now ?): HealthScanner/HealthRepairV4 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Score Surface for 94nop - Hi, some anonymous person (still called "bvowk" for simplicity ;-) is so kind to provide access to a pile of computers. I have suggested to calculate one score surface for standard settings. It takes roughly 1000 times the time of one "no...

Bug in pMARS - Hi, either I don't know how EQUs work or I have found a bug in the parser of pMARS. So far I cound pin it down to: ;redcode-tiny ;name test ;assert CORESIZE == 800 v3 EQU 3 * (3 / 2 + 1) + 3 v4 EQU (CORESIZE - v3) dat.f v3, v4 With the..

KOTH.ORG: Status - ICWS Experimental 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG ICWS Experimental 94..

KOTH.ORG: Status - MultiWarrior 94 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG Multiwarrior 94 CoreWar..

KOTH.ORG: Status - 94 No Pspace 03/06/06 - Weekly Status on 03/06/06 -=- irc.KOTH.org is up! Meetings held in #corewars -=- Tons of new features on www.KOTH.org/koth.html pages -=- *FAQ* page located at: www.KOTH.org/corewar-faq.html Current Status of the KOTH.ORG 94 No Pspace CoreWar Hill...
   Game Forums (Home) -> Core War All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]