Skybuck Investigates Wolfram's Machine for Encoding High Level Reasoning.

Hello,

I can't let it go... I have to investigate this Wolfram stuff otherwise it keep thinking about it LOL.

Anyway.

To figure out how this stuff works first I investigate which colors occur more often.

Those might be used to encode high level values to create higher level states and transitions or so:

The investigation module below examines how often a color occurs in sequence.

My reasoning is: These sequences of the same colors might be used to encode higher level values for example:

2 Oranges in a row = Do Action 1 3 Oranges in a row = Do Action 2 4 Oranges in a row = Do Action 3

2 Yellows in a row = Do Action 4

3 Yellows in a row = Do Action 5 4 Yellows in a row = Do Action 6

This reasoning seems a good way to do it..

Because the investigation module below already shows that white almost near occurs twice ?

Apperently white simply means "empty memory".

I am not sure which value occurs more often orange or yellow..

Or maybe orange can be seen as a digital one. and yellow as a digital zero or so..

and white simply as non content/meaning:

Simple Investigation module:

// *** Begin of Investigation Module ***

unit unit_TcombatAI_version_001;

interface

uses Unit_TwolframMachine_version_002;

type TcombatAI = record private public mWolframMachine : TwolframMachine; mOrangeOutputs : integer; mYellowOutputs : integer; mWhiteOutputs : integer;

procedure Initialize; procedure Execute; end;

implementation

uses Dialogs;

procedure TcombatAi.Initialize; var vWolframPosition : TwolframPosition; begin mWolframMachine.Initialize;

// fill program with random colors for vWolframPosition := Low(TwolframPosition) to High(TwolframPosition) do begin mWolframMachine.mTape[vWolframPosition] := TwolframColor(Random( Ord(High(TwolframColor))+1 ) ); end; end;

procedure TcombatAi.Execute; begin

mWolframMachine.Execute;

// determine number of consecutive/sequential outputs of same color. case mWolframMachine.mOutputColor of wc_orange : begin mOrangeOutputs := mOrangeOutputs + 1; mYellowOutputs := 0; mWhiteOutputs := 0;

case mOrangeOutputs of 2 : begin ShowMessage('Two Oranges !'); end; end; end;

wc_yellow : begin mOrangeOutputs := 0; mYellowOutputs := mYellowOutputs + 1; mWhiteOutputs := 0;

case mYellowOutputs of 2 : begin ShowMessage('Two Yellows !'); end; end;

end;

wc_white : begin mOrangeOutputs := 0; mYellowOutputs := 0; mWhiteOutputs := mWhiteOutputs + 1;

case mWhiteOutputs of 2 : begin ShowMessage('Two Whites !'); end; end;

end; end; end;

end.

// *** End of Investigation Module ***

Bye, Skybuck.

Reply to
Skybuck Flying
Loading thread data ...

This is a better investigation module.

It simply shows how many times the same color occurs in a row.

Also randomize on timer added ;)

// *** Begin of Module ***

unit unit_TcombatAI_version_001;

interface

uses Unit_TwolframMachine_version_002;

type TcombatAI = record private public mWolframMachine : TwolframMachine; mOrangeOutputs : integer; mYellowOutputs : integer; mWhiteOutputs : integer;

procedure Initialize; procedure Execute; end;

implementation

uses SysUtils, Dialogs;

procedure TcombatAi.Initialize; var vWolframPosition : TwolframPosition; begin mWolframMachine.Initialize;

// fill program with random colors for vWolframPosition := Low(TwolframPosition) to High(TwolframPosition) do begin mWolframMachine.mTape[vWolframPosition] := TwolframColor(Random( Ord(High(TwolframColor))+1 ) ); end; end;

procedure TcombatAi.Execute; begin

mWolframMachine.Execute;

// determine number of consecutive/sequential outputs of same color. case mWolframMachine.mOutputColor of wc_orange : begin mOrangeOutputs := mOrangeOutputs + 1; mYellowOutputs := 0; mWhiteOutputs := 0;

if mOrangeOutputs >= 2 then begin ShowMessage('Oranges: ' + IntToStr(mOrangeOutputs) ); end; end;

wc_yellow : begin mOrangeOutputs := 0; mYellowOutputs := mYellowOutputs + 1; mWhiteOutputs := 0;

if mYellowOutputs >= 2 then begin ShowMessage('Yellows: ' + IntToStr(mYellowOutputs) ); end; end;

wc_white : begin mOrangeOutputs := 0; mYellowOutputs := 0; mWhiteOutputs := mWhiteOutputs + 1;

if mWhiteOutputs >= 2 then begin ShowMessage('Whites: ' + IntToStr(mWhiteOutputs) ); end; end; end; end;

end.

// *** End of Module ***

Bye, Skybuck.

Reply to
Skybuck Flying

While,

The combat's game AI has 5 actions available:

forward brake turn left turn right fire

I wolfram-encoded them as:

forward // 2 oranges brake // 2 yellows turn left // 3 oranges turn right // 3 yellows fire // 4 oranges or 4 yellows

Here is the code and now I go test it in my game to see what happens lol.

I expect the planes to simply rotate and fire sometimes.

The next idea is to implement "hurt" when they get fired upon and hit some memory contents/tape will be changed to hopefully improve the ai's program. (Already done: ai's program initialized with random program/tape/colors ;) maybe later stored and loaded from disk if ai actually learns)

// *** Begin of Module ***

unit unit_TcombatAI_version_001;

interface

uses Unit_TwolframMachine_version_002;

type TcombatAI = record private public mWolframMachine : TwolframMachine; mOrangeOutputs : integer; mYellowOutputs : integer; mWhiteOutputs : integer;

mForward : boolean; mBrake : boolean; mTurnLeft : boolean; mTurnRight : boolean; mFire : boolean;

procedure Initialize; procedure Execute;

procedure ExecuteOrangeAction; procedure ExecuteYellowAction; // procedure ExecuteWhiteAction; end;

implementation

uses SysUtils, Dialogs;

procedure TcombatAi.Initialize; var vWolframPosition : TwolframPosition; begin Randomize;

mWolframMachine.Initialize;

// fill program with random colors for vWolframPosition := Low(TwolframPosition) to High(TwolframPosition) do begin mWolframMachine.mTape[vWolframPosition] := TwolframColor(Random( Ord(High(TwolframColor))+1 ) ); end; end;

procedure TcombatAI.ExecuteOrangeAction; begin if mOrangeOutputs = 2 then begin mForward := true; end else if mOrangeOutputs = 3 then begin mTurnLeft := true; end else if mOrangeOutputs = 4 then begin mFire := true; end; end;

procedure TcombatAI.ExecuteYellowAction; begin if mYellowOutputs = 2 then begin mBrake := true; end else if mYellowOutputs = 3 then begin mTurnRight := true; end else if mYellowOutputs = 4 then begin mFire := true; end; end;

procedure TcombatAI.Execute; begin

{ Combat AI has 5 actions available:

mForward (boolean) // will be encoded as orange 2

mBrake (boolean) // will be encoded as yellow 2

mTurnLeft (boolean) // will be encoded as orange 3

mTurnRight (boolean) // will be encoded as yellow 3

mFire (boolean) // will be encoded as yellow 4 or orange 4 }

// reset ai actions

mForward := false; mBrake := false; mTurnLeft := false; mTurnRight := false; mFire := false;

mWolframMachine.Execute;

// determine number of consecutive/sequential outputs of same color. case mWolframMachine.mOutputColor of wc_orange : begin mOrangeOutputs := mOrangeOutputs + 1;

// if color change detected then execute previous color if mYellowOutputs >= 2 then begin ExecuteYellowAction; end;

// if max color reach then execute color if mOrangeOutputs = 4 then begin ExecuteOrangeAction; mOrangeOutputs := 0; end;

mYellowOutputs := 0; mWhiteOutputs := 0; end;

wc_yellow : begin mYellowOutputs := mYellowOutputs + 1;

// if color change detected then execute previous color if mOrangeOutputs >= 2 then begin ExecuteOrangeAction; end;

// if max color reach then execute color if mYellowOutputs = 4 then begin ExecuteYellowAction; mYellowOutputs := 0; end;

mOrangeOutputs := 0; mWhiteOutputs := 0; end;

wc_white : begin mWhiteOutputs := mWhiteOutputs + 1;

{ // 2 whites doesn't seem to happen ;) if mWhiteOutputs >= 2 then begin ShowMessage('Whites: ' + IntToStr(mWhiteOutputs) ); end; }

mOrangeOutputs := 0; mYellowOutputs := 0; end; end; end;

end.

// *** End of Module ***

Bye, Skybuck.

Reply to
Skybuck Flying

No wonder it's not working.

Some say wolfram's 2-3 machine aint universal LOL.

Good excuse ! LOL.

Newsserver problems remain for me and my isp.

(Not so universal says so on slashdot :P*)

Bye, Skybuck.

Reply to
Skybuck Flying

Yes, the Slashdot thread is an interesting read.

Have you ever played Core Wars? Creating a 'Memory Array Redcode Simulator' in Delphi might be an interesting exercise!

formatting link
formatting link

Nathan.

Reply to
Evenbit

This is something very cool, I will definetly look into it.

It's also well suited for having programs battle each other or so :) ;)

Bye, Skybuck.

Reply to
Skybuck Flying

I tried WinCore.

It seems it's not good enough to write self modifieing programs.

The programs can only be writing in "red code" assembler.

It seems impossible to write binary programs or to have the program generate it's own instructions.

The problem seems to be WinCore does not follow the original red code specification.

The only self modieing program which seems to work is:

mov 0, 1

However if I tried to write the binary version of it:

1, 0, 1

or

101

It does not compile.

When looking at the object code. Mov seems to be translated into something else than '1' ?

SHIT that's what it is ;)

Bye, Skybuck.

Reply to
Skybuck Flying

Oh wait,

Now I understand why mov 0, 1 works.

0 represent the current instruction which is itself.

Apperently it is allowed to copy instructions to somewhere else :)

However is it also possible to modify the instructions itself I wonder ?

Can I for example change instruction:

mov 0, 1

to Say

mov 0, 1000 ?

By self modification ? ;)

(Doesn't seem like it ?)

Bye, Skybuck.

Reply to
Skybuck Flying

Well mov 0, 1 probably works with constants.

If the constants are replaced with a memory address...

Then the memory address functions as a pointer.

So if the contents at the pointer^ change... then the instruction can behave differently.

So while the instruction encoding itself can not be changed as least via pointers the same kind of more or less same behaviour can be achieved I think ;)

Probably something like:

mov 0, @Destination

change @destination to something else.

copy mov instruction to somewhere else...

Unless ofcourse @destination is not absolute... but relative... then it becomes a problem again possibly ;)

Bye, Skybuck.

Reply to
Skybuck Flying

if a = 0 jump to b.

However WinCore seems to work vice versa:

if b=0 jump to a.

Bye, Skybuck.

Reply to
Skybuck Flying

Or maybe I am doing something wrong with the jmz instructions...

Weird.

Bye, Skybuck.

Reply to
Skybuck Flying

No I was correct. It's reversed. I just tried it differently that's why I wasn't sure.

It's confusing also because sometimes @Offset has to be used and sometimes just Offset.

For example:

Offset dat #5 jmz 2, Offset

Will jump to next next instruction if offset is zero.

However:

jmz 2, @Offset

Does something completely different ?

Weird.

Bye, Skybuck.

Reply to
Skybuck Flying

Hello,

Here is my First RedCode Warrior: The Jumping Imp ! ;) :D Version 0.03 !

The program simply copies itself to another location in memory and then executes itself from there and repeats itself.

I was just curious if it could be done and as a practice.

And it does work and it's nice... but it's not much of a warrior.

It gets bombed... or it gets eating by the simple imp ;)

Cool stuff though ! ;)

Wow almost forgot the code here it is ;):

;redcode ;name JumpingImp ;author Skybuck Flying ;strategy paper (replicator) ;history Skybuck's First Warrior :) version 0.03 created on 31 october 2007 works/tested in WinCore 2.3 jmp Initialization Source dat #0 Dest dat #0 Counter dat #0 Target dat #18 ; must equal dest initialization -2 Initialization mov #-1, Source mov #20, Dest mov #15, Counter CopyRoutine mov @Source, @Dest add #1, Source add #1, Dest sub #1, Counter jmz @Target, Counter jmp CopyRoutine dat #0

Any improvements to the code to make it shorter/execute faster are welcome ! ;) send comments to skybuck 2000 at hotmail dot com

Bye, Skybuck.

Reply to
Skybuck Flying

Hello,

Here is my second warrior: The Duplicating Imp, it's based on my first warrior: The Jumping Imp.

The duplicating imp simply executes it's copies.

Maybe it could still be better :) But for now it seems to always win from the jumping imp ;)

Duplicating Imp Code:

;redcode ;name DuplicatingImp ;author Skybuck Flying ;strategy paper (replicator) ;history Skybuck's Second Warrior Version 0.01 created on 31 october 2007 works/tested in WinCore 2.3 begin jmp Initialization Source dat #0 Dest dat #0 Counter dat #0 Target dat #18 ; must equal dest initialization -2 Initialization mov #-1, Source mov #20, Dest mov #15, Counter CopyRoutine mov @Source, @Dest add #1, Source add #1, Dest sub #1, Counter jmz 2, Counter jmp CopyRoutine spl @Target jmp begin

Yeah I was lazy I simply modified a little bit the jumping imp :)

I have a new idea for a duplicator/executor etc but need to write new code which is hard because I still don't quite understand everything ;)

Bye, Skybuck.

Reply to
Skybuck Flying

Also kinda sux how the first bot is always at core zero (wincore 2.3) ?

Oh well at least easy debugging that's probably why they did it..

But it's bad too I tried another bot... but it only works from core 0..

So not so good.

Bye, Skybuck.

Reply to
Skybuck Flying

Yeah I am gonna look for a redcode reference guide to better understand the language/instructions because that's not terrible clear so far ;)

Bye, Skybuck.

Reply to
Skybuck Flying

Hello,

Here is some concept code:

mov 0, 0 cmp @-1, @-1 mov 0, 0 mov 0, 0

Just to test if it's possible to detect if an instruction equals another instruction.

Maybe this can be used to detect "dat #0" bombs ;)

I'll give it a try here: jmp 2 dat #0 cmp @-1, @-1 dat #0 mov 0, 0

This should skip over the bombs and still execute the mov ;)

Cool... I think now programs can be "dual" written.

Just copy every instruction... and this could make it survive bombs or something.

Or maybe there are other bomb surviving techniques... like copieing itself multiple times the instructions..

Hmm.. I am kinda hungry... this prevent me from putting time in it..

I am hasty... if I spent more time on it I might come up with something..

But I am going in a possible good direction LOL :D

Bye, Skybuck.

Reply to
Skybuck Flying

I give up,

Core/Codewars is a nice idea.

However codewar is f*ck-ed up beyond recgonition ;)

Coding even the most basic things is hard in codewars ;)

In asm I could even do it more easily then in codewars I bet ! ;)

In other words:

Codewars asm design is crap.

A codewar clone with binary instruction encodig might be a much better alternative.

Bye, Skybuck.

Reply to
Skybuck Flying

Fuck just wrote a program and clicked exit... it didn't even ask to save... shitty.

Have to re-do it now.

Doh...

Still dont understand how @ works... Seems to be completely different per instruction or so ;)

Bye, Skybuck.

Reply to
Skybuck Flying

Here is an example how difficult it is to implement a basic idea:

Idea is to have two programs running.

One does nothing.

The other one scans and restores any defects, from the backup.

However the program still does not really function as it should, nor would it ofcourse survive an attack in unprotected sections.

The offsets in source and destination are simply wrong.

Pretty frustrating ;)

jmp runner

source dat backup destination dat main

runner spl main spl scan dat #0

main mov 0,0 mov 0,0 mov 0,0 jmp main

backup mov 0,0 mov 0,0 mov 0,0 jmp backup

restore mov @source, @destination mov @source+1, @destination+1 mov @source+2, @destination+2 mov @source+3, @destination+3 jmp scan

scan cmp @source, @destination jmp restore cmp @source+1, @destination+1 jmp restore cmp @source+2, @destination+2 jmp restore cmp @source+3, @destination+3 jmp restore jmp scan

I had enough of this shit.

Bye, Skybuck.

Reply to
Skybuck Flying

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.