Jump to content
BrainDen.com - Brain Teasers
  • 0


unreality
 Share

Question

VNA.4

~ Based on VNA/VNA2/VNA3, but you don't need to know anything about those. This is entirely redesigned and simplified ~

Download the VNA.4 emulator, written in HTML/Javascript that runs fine on Firefox 2.0.0.14, Firefox 3.5.1, Safari 1.3 (v312), and Chrome 2.0.172.37 (and 2.0.172.39). It appears to not be working in Internet Explorer whatsoever.

For some reason I can't get the html file to upload... the solution I guess is to post the code verbatim:


<html>

<head>

<title>VNA.4 Emulator, by unreality</title>

<script LANGUAGE="JavaScript">


/* global declarations */


var vna = new Array();

var alphastring = "abcdefghijklmnopqrstuvwxyz";

var capalphastring = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var p1vararray = new Array(26);

var p2vararray = new Array(26);


/* functions */


function doSwitch()

{

getp1 = document.form1.p1.value;

getp2 = document.form1.p2.value;

document.form1.p1.value = getp2;

document.form1.p2.value = getp1;

}


function doClear()

{

document.form1.p1.value = null;

document.form1.p2.value = null;

}


function doRandomStart()

{

document.form1.startline.value = Math.floor(117*Math.random())+42

}


function loadArray()

{

var pr1 = new Array();

var pr2 = new Array();

pr1 = document.form1.p1.value.split("\n");

pr2 = document.form1.p2.value.split("\n");

var nStart = document.form1.startline.value;

var error1="";

var error2="";

var error3="";

if (pr1.length > 40) error1 = "Program 1 is too long! ";

if (pr2.length > 40) error2 = "Program 2 is too long! ";

if (nStart=="") error3 = "You must specify a starting node for P2!";

error3 = error1 + error2 + error3;

if (error3 != ""){alert(error3); return;}

var iString;

var cString = document.form1.fillwith.value;

for (i=0;i<200;i++)

{

iString = cString;

if (i<pr1.length) {iString = pr1[i];}

if (i>=nStart && i<nStart+pr2.length) {iString = pr2[i - nStart];}

if (iString == undefined) iString = cString;

vna[i] = iString;

}

document.form1.vnarray.value = vna.join("\n");

document.form1.point1.value = 0;

document.form1.point2.value = nStart;

document.form1.rnds.value = 0;

document.form1.dornd.disabled = false;

document.form1.doxrnd.disabled = false;

document.form1.xrd.value = 10;

// fill variable arrays

for(i=0;i<26;i++)

{

p1vararray[i] = 0;

p2vararray[i] = 0;

}

document.form1.seevars.disabled = false;

}


function doRound()

{

// increment round counter

document.form1.rnds.value++;

// pointer locations

var lineOne = document.form1.point1.value*1;

var lineTwo = document.form1.point2.value*1;

// P1 first

var zline = vna[lineOne].toLowerCase();

// count the number of spaces in zline

var chratloopy = 0;

var numspaces = 0;

while (chratloopy < zline.length)

{

if (zline.charAt(chratloopy) == " ") numspaces++;

chratloopy++;

}

var newline;

var paramz = zline.split(" ");

var valqa = doFunc(paramz[0]+"",lineOne,1)*1;

if (numspaces > 0) var valqb = doFunc(paramz[1]+"",lineOne,1)*1;

if (numspaces > 1) var valqc = doFunc(paramz[2]+"",lineOne,1)*1;

if (numspaces > 2) var valqd = doFunc(paramz[3]+"",lineOne,1);

if (numspaces > 3) var valqe = doFunc(paramz[4]+"",lineOne,1);

if (valqd != "!") valqd *= 1;

if (valqe != "!") valqe *= 1;

switch (numspaces)

{

case 0:

if (zline == "x")

{

document.form1.dornd.disabled = true;

document.form1.doxrnd.disabled = true;

alert("Program 2 wins!");

return;

}

else

{

newline = doMod(lineOne + valqa);

}

break;

case 1:

var firstchar = zline.charAt(0);

p1vararray[alphastring.indexOf(firstchar)] = valqb;

newline = doMod(lineOne + 1);

break;

case 2:

var replacestring = vna[doMod(lineOne+valqa)];

// check for capital variables

var zzingl;

var dropfwhenzero = 1;

while (dropfwhenzero == 1)

{

zzingl = replacestring.length;

dropfwhenzero = 0;

for (i=0;i<zzingl;i++)

{

if (capalphastring.indexOf(replacestring.charAt(i)) != -1)

{

replacestring = replacestring.substring(0,i) + p1vararray[capalphastring.indexOf(replacestring.charAt(i))] + replacestring.substring(i+1);

dropfwhenzero = 1;

}

}

}

vna[doMod(lineOne+valqb)] = replacestring;

newline = doMod(lineOne + valqc);

break;

case 3:

var temptemptemp = vna[doMod(valqa + lineOne)];

vna[doMod(valqa + lineOne)] = vna[doMod(valqb + lineOne)];

vna[doMod(valqb + lineOne)] = temptemptemp;

if (vna[doMod(valqa + lineOne)] == vna[doMod(valqb + lineOne)])

{

newline = doMod(lineOne + valqc);

}

else

{

if (valqd != "!") newline = doMod(lineOne + valqd);

if (valqd == "!") newline = doMod(lineOne + valqc);

}

break;

case 4:

if (valqa == valqb) {newline = doMod(lineOne + valqc);}

if (valqa > valqb) {newline = doMod(lineOne + valqd);}

if (valqa < valqb && valqe == "!") {newline = doMod(lineOne + valqd);}

if (valqa < valqb && valqe != "!") {newline = doMod(lineOne + valqe);}

break;

}

//

//

// P2 now

//

//

var zline = vna[lineTwo].toLowerCase();

// count the number of spaces in zline

var chratloopy = 0;

var numspaces = 0;

while (chratloopy < zline.length)

{

if (zline.charAt(chratloopy) == " ") numspaces++;

chratloopy++;

}

var newxline;

paramz = zline.split(" ");

valqa = doFunc(paramz[0]+"",lineTwo,2)*1;

if (numspaces > 0) var valqb = doFunc(paramz[1]+"",lineTwo,1)*1;

if (numspaces > 1) var valqc = doFunc(paramz[2]+"",lineTwo,1)*1;

if (numspaces > 2) var valqd = doFunc(paramz[3]+"",lineTwo,1);

if (numspaces > 3) var valqe = doFunc(paramz[4]+"",lineTwo,1);

if (valqd != "!") valqd *= 1;

if (valqe != "!") valqe *= 1;

switch (numspaces)

{

case 0:

if (zline == "x")

{

document.form1.dornd.disabled = true;

document.form1.doxrnd.disabled = true;

alert("Program 1 wins!");

return;

}

else

{

newxline = doMod(lineTwo + valqa);

}

break;

case 1:

firstchar = zline.charAt(0);

p2vararray[alphastring.indexOf(firstchar)] = valqb;

newxline = doMod(lineTwo + 1);

break;

case 2:

vna[doMod(lineTwo+valqb)] = vna[doMod(lineTwo+valqa)];

newxline = doMod(valqc+lineTwo);

break;

case 3:

var temptemptemp = vna[doMod(valqa + lineTwo)];

vna[doMod(valqa + lineTwo)] = vna[doMod(valqb + lineTwo)];

vna[doMod(valqb + lineTwo)] = temptemptemp;

if (vna[doMod(valqa + lineTwo)] == vna[doMod(valqb + lineTwo)])

{

newxline = doMod(lineTwo + valqc);

}

else

{

if (valqd != "!") newxline = doMod(lineTwo + valqd);

if (valqd == "!") newxline = doMod(lineTwo + valqc);

}

break;

case 4:

if (valqa == valqb) {newxline = doMod(lineTwo + valqc);}

if (valqa > valqb) {newxline = doMod(lineTwo + valqd);}

if (valqa < valqb && valqe == "!") {newxline = doMod(lineTwo + valqd);}

if (valqa < valqb && valqe != "!") {newxline = doMod(lineTwo + valqe);}

break;

}




// render the VNA

document.form1.vnarray.value = vna.join("\n");

document.form1.point1.value = newline;

document.form1.point2.value = newxline;

}



function doMod(zeinput)

{

while (zeinput < 0)

{

zeinput += 200;

}

zeinput = zeinput % 200;

return zeinput;

}


function doFunc(param, qline, zpp)

{

if (param == "") return "";

if (param == "!") return "!";

if (alphastring.indexOf(param) != -1)

{

return doSuperFunc(param, zpp);

}

var tempeval;

var closeparen;

var funcin;

var beforeparstring;

var commaloc;

var parenloc;

var rightloc;

var funcname;

var inputarray = new Array();

/*var xdata = new Array();*/

// loop until param is just a number

while (param*1 != param)

{

closeparen = param.indexOf(")");

openparen = (param.substring(0,closeparen+1)).lastIndexOf("(");

funcin = param.substring(openparen+1,closeparen);

beforeparstring = param.substring(0,openparen);

commaloc = beforeparstring.lastIndexOf(",");

parenloc = beforeparstring.lastIndexOf("(");

rightloc = Math.max(commaloc,parenloc);

funcname = param.substring(rightloc+1,openparen);

funcname = funcname.toLowerCase();

//

/*alert(closeparen+" -- "+openparen+" -- "+commaloc+" -- "+parenloc+" -- "+rightloc+" -- "+zpp+qline); 

alert("Name: "+funcname+", Input: "+funcin);*/

//

inputarray = funcin.split(",");

for (i=0;i<inputarray.length;i++)

{

inputarray[i] = doSuperFunc(inputarray[i],zpp);

}

switch (funcname)

{

case "sum":

case "add":

tempeval = 0;

for (i=0;i<inputarray.length;i++)

{

tempeval += inputarray[i];

}

break;

case "prd":

case "mul":

case "mult":

tempeval = 1;

for (i=0;i<inputarray.length;i++)

{

tempeval *= inputarray[i];

}

break;

case "inc":

case "incr":

tempeval = (inputarray[0] + 1);

break;

case "dec":

case "decr":

tempeval = (inputarray[0] - 1);

break;

case "neg":

tempeval = (inputarray[0] * -1);

break;

case "inv":

if (inputarray[0] == 0) {tempeval = 0} else {tempeval = 1 / inputarray[0];}

break;

case "num":

var linetoterm = vna[doMod(qline + inputarray[0])]+"";

tempeval = 1;

for (i=0;i<linetoterm.length;i++)

{

if (linetoterm.charAt(i) == " ") tempeval++;

}

if (linetoterm == "x") tempeval = 0;

break;

case "mod":

tempeval = (inputarray[0]*1) % (inputarray[1]*1);

break;

case "pow":

tempeval = Math.pow(inputarray[0],inputarray[1]);

break;

case "div":

tempeval = (inputarray[0]*1) / (inputarray[1]*1);

break;

case "sub":

tempeval = (inputarray[0]*1) - (inputarray[1]*1);

break;

case "log":

tempeval = Math.log(inputarray[1]*1) / Math.log(inputarray[0]*1);

break;

case "abs":

tempeval = Math.abs(inputarray[0]);

break;

case "int":

tempeval = Math.floor(inputarray[0]);

break;

}

// replace part of param with tempeval... then loop again

param = param.substring(0,rightloc+1) + tempeval + param.substring(closeparen+1);

}

return param;

}


function doSuperFunc(qwerty, zppp)

{

var qwertest = alphastring.indexOf(qwerty);

if (qwertest != -1)

{

if (zppp == 1) qwerty = p1vararray[qwertest];

if (zppp == 2) qwerty = p2vararray[qwertest];

}

else qwerty *= 1;

return qwerty;

}


function doXRounds()

{

var getx = document.form1.xrd.value;

for (i=0;i<getx;i++)

{

doRound();

}

}


function seeVars()

{

var ystr = "P1:\n";

for (i=0;i<26;i++)

{

if (p1vararray[i] != 0) ystr += alphastring.charAt(i)+" = "+p1vararray[i]+"\n";

}

ystr += "\nP2:\n";

for (i=0;i<26;i++)

{

if (p2vararray[i] != 0) ystr += alphastring.charAt(i)+" = "+p2vararray[i]+"\n";

}

alert(ystr);

}


/* end of script */

</script>

</head>


<body>

<h1>VNA.4 Emulator, by unreality</h1>

<br><br><br>P1 ..........................................................................................................P2<br><form name="form1">

<textarea name="p1" rows=10 cols=50></textarea> <textarea name="p2" rows=10 cols=50></textarea>

<br>

<center><input type="button" value="Switch" onClick="doSwitch();"><input type="button" value="Clear" onClick="doClear();"></center>

<br><br><br><br>

P1 starts at line 0 and goes first<br>

P2 starts at line X and goes second<br>

X: <input type="text" name="startline" length="10"> <input type="button" value="Random" onClick="doRandomStart();">

<br>(range 42 to 158 please)

<br><br><br><br><center>Fill with: <input type="text" name="fillwith" length="10" value="x"></center><br><input type="button" value="Load the Virtual Node Array!" onClick="loadArray();"><br><hr><br>

VNA:<br><textarea name="vnarray" rows=30 cols=60></textarea><br>

P1 Pointer: <input type="text" name="point1" length="10"><br>

P2 Pointer: <input type="text" name="point2" length="10"><center>

<input type="button" value="Do 1 Round" name = "dornd" onClick="doRound();"> <input type="button" value="Do X Rounds" name="doxrnd" onClick="doXRounds();"> X:<input type="text" name="xrd" length="10"></center><br>

Rounds: <input type="text" name="rnds" length="10"><input type="button" value="See Nonzero Variables" name="seevars" onClick="seeVars();" disabled="true">

</form>

</body>

</html>

Just select all of the above code and copy it, pasting it into a simple text file. Then save the text file as "vna4.html". To run the emulator, just drag the text file onto your browser (for a Mac) or double-click the text file and it will open in your default browser (for Mac or PC) or right-click and select "Open with..." (for a Mac or PC) and then select the browser you want to open it in. Sorry for the inconvenience, I'll try to find out why I can't upload it...

Imagine a world where your senses fail you. There is no sound, no smells. There's nothing to taste and nothing to feel. All you can see is an indecipherable infinite hierarchy of data, echoless chambers of information, architectures of code. This cyberscape is constantly changing with iteration by iteration, programs and viruses and shells warring for memory space and processing power. This is the inside of your computer.

But now, an arena has been set aside... two programs, two warriors, shall duke it out in the Virtual Node Array... the VNA is a linear, circular memory core with 200 "nodes", or lines. You can keep going in any direction forever because of the VNA's circular disposition. Each node in the VNA has some code, mostly numbers with some letters and short words, written in terms and separated by spaces. Short, simple code. I will explain shortly how to design your program, but first, the setup system...

In the beginning,the VNA is empty, constituting either all x's (bombs) or 1's (the command to jump to the next line) or some other simple preset filler. Then, the two warring programs are placed into the VNA, spaced out enough to give each other room.

For example, say this is your program:

a sum(a,3)

1 a -1

Then the VNA, which previously looked like this:

x

x

x

x

x

x

x

x

...etc

will now look like this:

x

x

x

x

a sum(a,3)

1 a -1

x

x

...etc

and your program's "pointer" will be placed at the first line of your program, the ""a sum(a,3)"" line.

When the game begins, P1 (Program/Player 1) will go first, then P2, then P1, etc, in alteration. A single "round" is after both P1 and P2 have gone. The VNA updates after one program executes one line of code (so it updates twice each round).

When a program executes a line of code, it does something, and then "jumps" the pointer to a new line. Lines are always referred to relative to the current line of interest; there is no absolute line numbering. So line 1 is always the next line. Line 0 is always the current line. Line -3 is always the line three behind you. Line 200 is the same thing as line 0, line 201 = line 1 = line 401 = line 601, line 197 = line -3, etc, since the VNA wraps around in a circular pattern.

What the program does is determined by the line of code it executes. There are six "structures" which determine how the program evaluates a line of code.

(0) BOMB structure: x

*** the BOMB structure is always the single letter 'x'. If a program executes a BOMB structure, it will be terminated and the enemy will win. You can handle BOMB structures and move them around, copy them, etc, and as long as you don't execute one, you're fine...

(1) JUMP structure: a

*** this does nothing except jump the pointer to line 'a'

(2) SET structure: a b

*** this sets the variable 'a' to the value 'b', then jumps forward 1 line. You have 26 variables, a-z, and your opponent has 26 variables, a-z. Your variables and your opponent's variables never interact. More on variables in a second

(3) COPY structure: a b c

*** copy the contents of line 'a' into line 'b', overriding what was previously on line 'b'. Then jump the pointer to line 'c'

(4) SWITCH structure: a b c d

*** switch the two lines, 'a' and 'b', then jump to line 'c' if 'a' and 'b' were equal. If 'a' and 'b' are not the same, jump to line 'd'

(5) IF structure: a b c d e

*** compare two quantities, 'a' and 'b'. If a=b, jump to line 'c'. If a>b, jump to line 'd'. If a<b, jump to line 'e'

That's it. With this simple system, many good programs can be written concisely, without many lines. For example, I call this the Hopper:

0 137 137

it copies itself 137 nodes forward, then jumps to this copied line for the next round... so each iteration, it jumps 137 nodes forward in the VNA. However, the Hopper's main drawback (other than that it has no offensive capabilities) is that the enemy can get accidentally overwritten by the Hopper and become a hopper as well, hopping for eternity, neither program winning. This is made unlikely by adding one more term to the program:

0 137 137 137

this new-and-improved Hopper is now based on the SWITCH structure. It switches itself with the node 137 lines ahead and then jumps there (regardless of what the other line is). This means that it doesn't leave behind a "hopper trail" that the enemy can get caught up in.

But the Hopper is an offensively weak program; it takes no self-initiative to attack the enemy. It just jumps around, trying to avoid destruction and hoping the enemy destroys itself. So let's make a new program that rains BOMBs (the letter x) down over the VNA, attempting to hit the enemy's code We'll call this program 'Bomber'. If the enemy pointer executes a line of code that is a BOMB, the enemy's program will terminate, and the Bomber will win, so the goal is to spread bombs around the VNA...

3 sum(a,20) 1

a sum(a,3)

-2

x

what does it do? The first node copies line +3 (the BOMB) to the line denoted by the variable 'a' plus 20 [the function sum(1,2,3,4,...) adds everything inside] and then jumps forward 1 line.

The next line assigns, to the value a, the quantity a plus 3. In other words, it increments 'a' by 3. The next line jumps backwards 2, and the cycle starts all over again, bombing a spot three nodes later each time.

But wait! It is considered inefficient to have more "active lines" (lines that are actually being executed by the program) than you should, for two reasons: (1) The more lines the program is executing, the more susceptible it is to bombing. (2) It takes you longer to do the same task.

So how can we shorten it? By switching the order of the lines and using the COPY structure's built-in jump to go back to the start. This new-and-improved Bomber does exactly the same thing as the old one, but more efficiently:

a sum(a,3)

1 sum(a,16) -1

x

The only function you've seen is the sum() function, and you've only seen it operate on two parameters. But sum() can have any number of entries, and can be substituted with add(), which is the same [just preference which you use].

ie,

sum(a,b,c,d) = add(a,b,c,d)

What other functions are there?

* mul(), mult() and prd() are all the same, and they multiply everything inside. For example, mul(5,2,3) = 30.

* the inc(n) or incr(n) functions will output n+1

* the dec(n) or decr(n) functions will output n-1

* the neg(n) function will output n * -1, ie, negative n

* the inv(n) function will output 1/n, ie, the reciprocal of n

* the mod(n,m) function will output n%m, ie, n modulo m, ie, the remainder when n is divided by m

* the pow(n,m) function will output n^m, ie, n raised to the power of m

* the div(n,m) function will output n/m, ie, n divided by m

* the sub(n,m) function will output n-m, ie, n minus m

* the log(n,m) function will output the logarithm base-n of m

* the abs(n) function will output the absolute value of n

* the int(n) function will output the integer base of n, ie, it will truncate/floor n to the greatest integer less than or equal to n

* the num(n) function will output the number of terms in the line 'n' (relative to the current line of course). num(n) will return 0 if 'n' is a BOMB, 1 for JUMP, 2 for SET, 3 for COPY, 4 for SWITCH, and 5 for IF

You can nest functions within functions and pass variables as parameters to functions. For example:

sum(5,mul(3,mod(8,3)),inv(neg(-.2)),a,inc(inc( B)) )

will output 5 + 3*(8%3) + 1/-(-.2) + a + (b+2) = 5 + 3*2 + 5 + a + b + 2 = a+b+18

ADDITIONAL THINGS

~~~~

What if you want to do a SWITCH structure but the line you jump to after that will be the same no matter what, regardless of whether the switched lines are equal? The answer is simple: in the setup 1 2 3 4, just make the 4th term the exact same as the 3rd term. But what if the term is long and complex or something? Just put a "!" exclamation point for the fourth term, ie:

1 2 3 !

This has no practical effect, it's just a preference thing. For SWITCH, it must be placed in the fourth term, and it just means that the 3rd term is the line that is jumped to, no matter what.

The exclamation point is also usable in the IF structure. If you're using the IF structure a b c d e as a=b or a≠b and thus your fourth term is the same as your fifth term, put an exclamation point for the fifth term:

1 2 3 4 !

This means that, if 1=2, jump to 3. Otherwise, jump to 4. Again, the exclamation point just a convenience thing.

~~~~

What if you want to jump to variable 'x'?

First of all, why use 'x' as a variable? There are plenty of others. But if you're using x for whatever reason, and you want to jump to the line denoted by the number 'x' is representing, you can't just do this:

x

since that's a bomb. However, you can just do:

0 0 x

which is the same thing.

~~~~

When a line is copied by a COPY structure, it is copied verbatim. ie:

1 2 100

7 9 add(a,2)

when run, that will copy the second line EXACTLY AS IT IS. Ie, after the first line is ran, the program will look like this:

1 2 100

7 9 add(a,2)

7 9 add(a,2)

But if you want to make it so that a variable is evaluated before being copied, use a CAPITAL letter. Take this program:

1 2 100

7 9 add(A,2)

say that the variable 'a' had a value of 3 at the time. Then after the first line runs, the program looks like this:

1 2 100

7 9 add(A,2)

7 9 add(3,2)

A capital letter variable has no difference from a lower-case variable when the line is being executed, the only difference from lowercaseness is when the line is being copied... when a line is copied, all of its variables stay variables, unless they are capitalized, in which case they are evaluated then and there for the new line.

By the way, a lone capital X is the same thing as a lower case 'x', ie, a bomb, except that if you copy this X, the result will be a number equal to whatever value your variable 'x' has. This makes 'x' a unique variable in that respect.

So... two programs. One array. 200 nodes... and only one victor. Post your ideas, your programs, declare duels... I've only written two more programs that I haven't posted here, called "Hopping Bomber" (or "Bombing Hopper", not sure which one sounds better ;D) and "Tracker", so you reading this can probably do better than what I've got so far :P The emulator is for download at the top of this post. Have at it, test your programs. If you have any questions, feel free to post here!

Link to comment
Share on other sites

  • Answers 70
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 0

I ran some tests...

~~~

BM vs Zero

[starting Number for Zero]: [Results]

142: BM wins after 143 rounds (odd...)

143: BM wins after 27 rounds

42: Zero wins after 391 rounds! This is to be expected since the first line bombs 41 + 1 + a(which is 1) = 43 from the origin. Thus a zero at 42 will slip by unnoticed and the BM will die on the 391st round, which is what happened. Testing the other extreme now...

158: BM wins after 147 rounds

I think that we can conclude the rest of the results in theory... with a distance of 4 between each of the BM's bomb each time, after 4 iterations are complete, the BM will have bombed the whole space between 43 and 194. This happens after exactly 156 rounds and BM is back at line zero ready to increment a from 4 to 5. At this point, there are only 8 non-BM or non-BM-bombed lines in the VNA: the two following BM's own bomb (I made it 'zzz' instead of 'x' in testing to see how it was progressing) then three x's that constitute lines 40, 41 and 42 and of those it's only technically legal for the enemy program to be on line 42 and onward, so the only space left is line 42 itself. The five other safe lines are 195, 196, 197, 198 and 199, which are directly before BM and thus not legal either for the Zero.

Thus the ONLY and I repeat ONLY legal spot where the Zero can survive and kill the Brutus Maximus is starting line 42. Out of 117 possible starting locations, only one results in the Zero's success.

So "0" is not a viable competitor. But a non-static hopper with the correct hopping constant (before I've used 137 just for its non-repetitious behavior) might be able to sneak through and stay always just ahead or just behind, jumping over places that the BM has already bombed... hmmm...

Link to comment
Share on other sites

  • 0

self-repairing program

a sum(a,-3)

38 sum(-2,a) 1

sum(num(-2),num(-1),num(0)) 10 -2 1 1

sum(num(1),num(2),num(3),num(4),num(5),num(6),num(7)) 24 1 8 8

4 -4 1

4 -4 1

4 -4 1

sum(num(-7),num(-6),num(-5)) 10 -7 4 4

a sum(a,-3)

38 sum(-2,a) 1

sum(num(-2),num(-1),num(0)) 10 -2 1 1

sum(num(1),num(2),num(3),num(4),num(5),num(6),num(7)) 24 1 8 8

4 -12 1

4 -12 1

4 -12 1

sum(num(-15),num(-14),num(-13)) 10 -15 4 4

a sum(a,-3)

38 sum(-2,a) 1

sum(num(-2),num(-1),num(0)) 10 -2 1 1

sum(num(1),num(2),num(3),num(4),num(5),num(6),num(7)) 24 1 8 8

4 -20 1

4 -20 1

4 -20 1

sum(num(-23),num(-22),num(-21)) 10 -23 4 4

a sum(a,-3)

38 sum(-2,a) 1

sum(num(-2),num(-1),num(0)) 10 -2 1 1

sum(num(1),num(2),num(3),num(4),num(5),num(6),num(7)) 24 1 8 8

4 -28 1

4 -28 1

4 -28 1

sum(num(-31),num(-30),num(-29)) 10 -31 4 4

a sum(a,-3)

38 sum(-2,a) -1

sum(num(-2),num(-1)) 5 -2 1 1

a sum(a,-37)

1 a -1

x

x

x

just had time to look at this one, nice! I love the use of num()s to check if a group of lines has been compromised. A bomb will lower the total num() count since you have no single-term JUMP structures. The fifth value each time might as well be a "!" since it's not expected for the num()count to increase, but that got me thinking... the only way to bomb this program and then fool it into thinking it's alright is to throw a bomb down on one space and then a longer line on another. But it's hard to predict exactly what the bomb will replace and thus what number will need to be added on in another bomb quickly enough before it's checked. So essentially this is fully self-repairing; the problem is when a bomb hits an unexpected spot and it can't save itself quickly enough.

I love the multiple-regenerator setup and how, if the regenerator itself is compromised, it jumps to the next one instead. This seems to be in the class of "imps" or "hoppers" not because it's constantly moving but because it's hard to kill, but weak offensively. Then again, if it's not hit, it only lends an extra round to CHECKING if it was hit before resuming bombing. And if it is hit and it sees it, it can save itself rather than dying, so loss of efficiency is better there than no efficiency. Thus the only real "efficiency loss" is that one extra lines it takes to do the check... going well it would bomb 1-in-3 rounds. The best way I can see to optimize it would be to change its -5 starting bomb to -42 or so :thumbsup:

Link to comment
Share on other sites

  • 0

I finished my programs. :thumbsup:

The first one is called Transporter.

z 46

z sum(4,z)

1 z -1 -1

The second is called Transporter 2.

z 46

z sum(5,z)

6 z -1 2

0

z sum(z,2)

z sum(5,z)

sum(-6,z) z -1

0

The last and much more complex one is radar bomber.

sum(num(42),num(44),num(46),num(48),num(50),num(52),num(54),num(56),num(58),num(60)) 0 1 6 172

sum(num(60),num(63),num(65),num(67),num(69),num(71),num(73),num(75),num(77),num(78)) 0 1 6 172

sum(num(78),num(82),num(84),num(86),num(88),num(90),num(92),num(94),num(96)) 0 1 6 172

sum(num(96),num(99),num(101),num(103),num(105),num(107),num(109),num(111),num(113)) 0 1 6 172

sum(num(113),num(116),num(118),num(120),num(122),num(124),num(126),num(128),num(130)) 0 1 6 172

sum(num(130),num(133),num(135),num(137),num(139),num(141),num(143),num(145),num(147)) 0 1 6 172

sum(num(36),num(38),num(40),num(42),num(44)) sum(num(45),num(48),num(50),num(52),num(54)) 1 6 8

sum(num(54),num(57),num(59),num(61),num(62)) sum(num(63),num(67),num(69),num(71),num(72)) 1 9 11

sum(num(72),num(75),num(78),num(80),num(82)) sum(num(83),num(84),num(86),num(88),num(90))) 1 12 14

sum(num(90),num(93),num(95),num(97)) sum(num(98),num(101),num(103),num(105),num(107)) 1 15 17

sum(num(107),num(110),num(112),num(114)) sum(num(115),num(118),num(120),num(122),num(124)) 1 18 20

sum(num(124),num(127),num(129),num(131),num(133)) sum(num(134),num(137),num(139),num(141))) 1 21 23

d 29

25 d 24

d 38

23 sum(d,-2) 22

d 48

21 sum(d,-4) 20

d 57

19 sum(d,-6) 18

d 67

17 sum(d,-8) 16

d 78

15 sum(d,-10) 14

d 86

13 sum(d,-12) 12

d 94

11 sum(d,-14) 10

d 108

9 sum(d,-16) 8

d 112

7 sum(d,-18) 6

d 122

5 sum(d,-20) 4

d 132

3 sum(d,-22) 2

d sum(d,2)

1 sum(d,-22) -1

This one took me forever.

Link to comment
Share on other sites

  • 0

those look pretty damn good :D I love how you use the SWITCH_structure in Transporter 2 to act as a checker to see if you've been compromised, and at no extra efficiency cost... nice!

I haven't looked at radar bomber in depth yet but it looks pretty meticulously planned hehe. I'll be out tonight and tomorrow but before I go, if you want we can see how they fare against various other programs if you wish. Or one of you guys can run some matches, we've all got the same emulator ;D

Link to comment
Share on other sites

  • 0

dms172's radar bomber program made me think of a way to make a really killer program. It would be theoretically possible to write this program, but in practice would be completely unwieldy. But I'll explain it anyways.

The amazing part is that there will be ONE LINE of code that determines exactly (or very nearly) where the enemy code ends. This line would be the tough one to write. Briefly, the concept is that you use the num() command to look at each of the ~160 non-self nodes and determine whether or not they're bombs. You can do this with a function like

div(num(n),num(n)-0.001) [call this F1(n)]

to return 1 (or slightly more) if line n is a non-bomb and 0 if line n is a bomb (while avoiding divide by zero errors).

You can take that term and just multiply it by n to make it return the line number if line n is a command or zero if line n is a bomb.

mult(n,F1(n)) [call this F2(n)]

So now how do you find the last line of code for the enemy program? One way to come close is by taking the sum over all n of F2(n) raised to a large power and then taking the log of that sum. In practice, the fourth power should be large enough to make the log base 4 of ( sum of all F2(n)^4 ) be pretty close to the maximum value of F2(n). The final function would look something like

int(log(4,sum(pow(F2(1),4),pow(F2(2),4),pow(F2(3),4),...

That's how to do it in principle, but it would mean you would have to write out all ~160 of those F2(n) terms by hand in that one line of code. (Of course there are probably ways of making Excel or Calc do it for you, or at least make it easier.)

Once you've found out where your foe's last line of code is, it would be pretty straightforward to use a Brutus-esque bombing approach to wipe it out in short order.

The only way to reliably foil such a program would be to make sure you have a 40-liner by making sure the last line of the 40 available lines of code is a non-bomb, and then have some code that transports the "real" program outside of the hot zone and executes it elsewhere sort of like zebra warrior. It would sort of have to be a program custom-built to avoid this program; I would imagine that most generic programs that don't know what's about to hit them would fall to this program if it were writeable.

Link to comment
Share on other sites

  • 0

dms172's radar bomber program made me think of a way to make a really killer program. It would be theoretically possible to write this program, but in practice would be completely unwieldy. But I'll explain it anyways.

The amazing part is that there will be ONE LINE of code that determines exactly (or very nearly) where the enemy code ends. This line would be the tough one to write. Briefly, the concept is that you use the num() command to look at each of the ~160 non-self nodes and determine whether or not they're bombs. You can do this with a function like

div(num(n),num(n)-0.001) [call this F1(n)]

to return 1 (or slightly more) if line n is a non-bomb and 0 if line n is a bomb (while avoiding divide by zero errors).

You can take that term and just multiply it by n to make it return the line number if line n is a command or zero if line n is a bomb.

mult(n,F1(n)) [call this F2(n)]

So now how do you find the last line of code for the enemy program? One way to come close is by taking the sum over all n of F2(n) raised to a large power and then taking the log of that sum. In practice, the fourth power should be large enough to make the log base 4 of ( sum of all F2(n)^4 ) be pretty close to the maximum value of F2(n). The final function would look something like

int(log(4,sum(pow(F2(1),4),pow(F2(2),4),pow(F2(3),4),...

That's how to do it in principle, but it would mean you would have to write out all ~160 of those F2(n) terms by hand in that one line of code. (Of course there are probably ways of making Excel or Calc do it for you, or at least make it easier.)

Once you've found out where your foe's last line of code is, it would be pretty straightforward to use a Brutus-esque bombing approach to wipe it out in short order.

The only way to reliably foil such a program would be to make sure you have a 40-liner by making sure the last line of the 40 available lines of code is a non-bomb, and then have some code that transports the "real" program outside of the hot zone and executes it elsewhere sort of like zebra warrior. It would sort of have to be a program custom-built to avoid this program; I would imagine that most generic programs that don't know what's about to hit them would fall to this program if it were writeable.

My plan actually was to find the enemy in one round, but after a few minutes I found out that the emulator has a limit to the number of characters per line. If you fixed that little problem it would work great. Also you would only have to do about 110 nodes.

Edited by dms172
Link to comment
Share on other sites

  • 0

there are 117 non-self nodes :thumbsup:

and damn, I figured megastructure was impossible in this game without the com() function. I have yet to analyze your method though...

regarding divide by zero, the inv() function is rigged to output 0 if fed 0. I'll do the same for the div() function... ie, if the second is 0, then it will output 0. Likewise if you do log(0,x) it will output 0.

Also as dms said, there were problems with line carry-over, so I extended out the text field to allow for any (or so I thought) reasonable line length. I think a massive line can still be introduced depending on how you copy it into the text field, I'll have to play with that...

edit: also fixed it for mod(x,0) and I tested it for pow(0,0)... it says "1"

Edited by unreality
Link to comment
Share on other sites

  • 0

there are 117 non-self nodes :thumbsup:

and damn, I figured megastructure was impossible in this game without the com() function. I have yet to analyze your method though...

regarding divide by zero, the inv() function is rigged to output 0 if fed 0. I'll do the same for the div() function... ie, if the second is 0, then it will output 0. Likewise if you do log(0,x) it will output 0.

Also as dms said, there were problems with line carry-over, so I extended out the text field to allow for any (or so I thought) reasonable line length. I think a massive line can still be introduced depending on how you copy it into the text field, I'll have to play with that...

edit: also fixed it for mod(x,0) and I tested it for pow(0,0)... it says "1"

How do you get 117 non-self node when there are 200 nodes and 40 self nodes? :huh: (well, plus a couple of nodes of buffer between you and where the enemy might lurk)

If I were to use 160, then a line of code that uses the principle I described but goes backwards from -1 to -160 instead of counting forwards (to find the first line of enemy code instead of the last line) and assigns it to the variable "a" would be ....

a neg(int(pow(sum(pow(mult(-1,div(num(-1),num(-1))),4),pow(mult(-2,div(num(-2),num(-2))),4),pow(mult(-3,div(num(-3),num(-3))),4),pow(mult(-4,div(num(-4),num(-4))),4),pow(mult(-5,div(num(-5),num(-5))),4),pow(mult(-6,div(num(-6),num(-6))),4),pow(mult(-7,div(num(-7),num(-7))),4),pow(mult(-8,div(num(-8),num(-8))),4),pow(mult(-9,div(num(-9),num(-9))),4),pow(mult(-10,div(num(-10),num(-10))),4),pow(mult(-11,div(num(-11),num(-11))),4),pow(mult(-12,div(num(-12),num(-12))),4),pow(mult(-13,div(num(-13),num(-13))),4),pow(mult(-14,div(num(-14),num(-14))),4),pow(mult(-15,div(num(-15),num(-15))),4),pow(mult(-16,div(num(-16),num(-16))),4),pow(mult(-17,div(num(-17),num(-17))),4),pow(mult(-18,div(num(-18),num(-18))),4),pow(mult(-19,div(num(-19),num(-19))),4),pow(mult(-20,div(num(-20),num(-20))),4),pow(mult(-21,div(num(-21),num(-21))),4),pow(mult(-22,div(num(-22),num(-22))),4),pow(mult(-23,div(num(-23),num(-23))),4),pow(mult(-24,div(num(-24),num(-24))),4),pow(mult(-25,div(num(-25),num(-25))),4),pow(mult(-26,div(num(-26),num(-26))),4),pow(mult(-27,div(num(-27),num(-27))),4),pow(mult(-28,div(num(-28),num(-28))),4),pow(mult(-29,div(num(-29),num(-29))),4),pow(mult(-30,div(num(-30),num(-30))),4),pow(mult(-31,div(num(-31),num(-31))),4),pow(mult(-32,div(num(-32),num(-32))),4),pow(mult(-33,div(num(-33),num(-33))),4),pow(mult(-34,div(num(-34),num(-34))),4),pow(mult(-35,div(num(-35),num(-35))),4),pow(mult(-36,div(num(-36),num(-36))),4),pow(mult(-37,div(num(-37),num(-37))),4),pow(mult(-38,div(num(-38),num(-38))),4),pow(mult(-39,div(num(-39),num(-39))),4),pow(mult(-40,div(num(-40),num(-40))),4),pow(mult(-41,div(num(-41),num(-41))),4),pow(mult(-42,div(num(-42),num(-42))),4),pow(mult(-43,div(num(-43),num(-43))),4),pow(mult(-44,div(num(-44),num(-44))),4),pow(mult(-45,div(num(-45),num(-45))),4),pow(mult(-46,div(num(-46),num(-46))),4),pow(mult(-47,div(num(-47),num(-47))),4),pow(mult(-48,div(num(-48),num(-48))),4),pow(mult(-49,div(num(-49),num(-49))),4),pow(mult(-50,div(num(-50),num(-50))),4),pow(mult(-51,div(num(-51),num(-51))),4),pow(mult(-52,div(num(-52),num(-52))),4),pow(mult(-53,div(num(-53),num(-53))),4),pow(mult(-54,div(num(-54),num(-54))),4),pow(mult(-55,div(num(-55),num(-55))),4),pow(mult(-56,div(num(-56),num(-56))),4),pow(mult(-57,div(num(-57),num(-57))),4),pow(mult(-58,div(num(-58),num(-58))),4),pow(mult(-59,div(num(-59),num(-59))),4),pow(mult(-60,div(num(-60),num(-60))),4),pow(mult(-61,div(num(-61),num(-61))),4),pow(mult(-62,div(num(-62),num(-62))),4),pow(mult(-63,div(num(-63),num(-63))),4),pow(mult(-64,div(num(-64),num(-64))),4),pow(mult(-65,div(num(-65),num(-65))),4),pow(mult(-66,div(num(-66),num(-66))),4),pow(mult(-67,div(num(-67),num(-67))),4),pow(mult(-68,div(num(-68),num(-68))),4),pow(mult(-69,div(num(-69),num(-69))),4),pow(mult(-70,div(num(-70),num(-70))),4),pow(mult(-71,div(num(-71),num(-71))),4),pow(mult(-72,div(num(-72),num(-72))),4),pow(mult(-73,div(num(-73),num(-73))),4),pow(mult(-74,div(num(-74),num(-74))),4),pow(mult(-75,div(num(-75),num(-75))),4),pow(mult(-76,div(num(-76),num(-76))),4),pow(mult(-77,div(num(-77),num(-77))),4),pow(mult(-78,div(num(-78),num(-78))),4),pow(mult(-79,div(num(-79),num(-79))),4),pow(mult(-80,div(num(-80),num(-80))),4),pow(mult(-81,div(num(-81),num(-81))),4),pow(mult(-82,div(num(-82),num(-82))),4),pow(mult(-83,div(num(-83),num(-83))),4),pow(mult(-84,div(num(-84),num(-84))),4),pow(mult(-85,div(num(-85),num(-85))),4),pow(mult(-86,div(num(-86),num(-86))),4),pow(mult(-87,div(num(-87),num(-87))),4),pow(mult(-88,div(num(-88),num(-88))),4),pow(mult(-89,div(num(-89),num(-89))),4),pow(mult(-90,div(num(-90),num(-90))),4),pow(mult(-91,div(num(-91),num(-91))),4),pow(mult(-92,div(num(-92),num(-92))),4),pow(mult(-93,div(num(-93),num(-93))),4),pow(mult(-94,div(num(-94),num(-94))),4),pow(mult(-95,div(num(-95),num(-95))),4),pow(mult(-96,div(num(-96),num(-96))),4),pow(mult(-97,div(num(-97),num(-97))),4),pow(mult(-98,div(num(-98),num(-98))),4),pow(mult(-99,div(num(-99),num(-99))),4),pow(mult(-100,div(num(-100),num(-100))),4),pow(mult(-101,div(num(-101),num(-101))),4),pow(mult(-102,div(num(-102),num(-102))),4),pow(mult(-103,div(num(-103),num(-103))),4),pow(mult(-104,div(num(-104),num(-104))),4),pow(mult(-105,div(num(-105),num(-105))),4),pow(mult(-106,div(num(-106),num(-106))),4),pow(mult(-107,div(num(-107),num(-107))),4),pow(mult(-108,div(num(-108),num(-108))),4),pow(mult(-109,div(num(-109),num(-109))),4),pow(mult(-110,div(num(-110),num(-110))),4),pow(mult(-111,div(num(-111),num(-111))),4),pow(mult(-112,div(num(-112),num(-112))),4),pow(mult(-113,div(num(-113),num(-113))),4),pow(mult(-114,div(num(-114),num(-114))),4),pow(mult(-115,div(num(-115),num(-115))),4),pow(mult(-116,div(num(-116),num(-116))),4),pow(mult(-117,div(num(-117),num(-117))),4),pow(mult(-118,div(num(-118),num(-118))),4),pow(mult(-119,div(num(-119),num(-119))),4),pow(mult(-120,div(num(-120),num(-120))),4),pow(mult(-121,div(num(-121),num(-121))),4),pow(mult(-122,div(num(-122),num(-122))),4),pow(mult(-123,div(num(-123),num(-123))),4),pow(mult(-124,div(num(-124),num(-124))),4),pow(mult(-125,div(num(-125),num(-125))),4),pow(mult(-126,div(num(-126),num(-126))),4),pow(mult(-127,div(num(-127),num(-127))),4),pow(mult(-128,div(num(-128),num(-128))),4),pow(mult(-129,div(num(-129),num(-129))),4),pow(mult(-130,div(num(-130),num(-130))),4),pow(mult(-131,div(num(-131),num(-131))),4),pow(mult(-132,div(num(-132),num(-132))),4),pow(mult(-133,div(num(-133),num(-133))),4),pow(mult(-134,div(num(-134),num(-134))),4),pow(mult(-135,div(num(-135),num(-135))),4),pow(mult(-136,div(num(-136),num(-136))),4),pow(mult(-137,div(num(-137),num(-137))),4),pow(mult(-138,div(num(-138),num(-138))),4),pow(mult(-139,div(num(-139),num(-139))),4),pow(mult(-140,div(num(-140),num(-140))),4),pow(mult(-141,div(num(-141),num(-141))),4),pow(mult(-142,div(num(-142),num(-142))),4),pow(mult(-143,div(num(-143),num(-143))),4),pow(mult(-144,div(num(-144),num(-144))),4),pow(mult(-145,div(num(-145),num(-145))),4),pow(mult(-146,div(num(-146),num(-146))),4),pow(mult(-147,div(num(-147),num(-147))),4),pow(mult(-148,div(num(-148),num(-148))),4),pow(mult(-149,div(num(-149),num(-149))),4),pow(mult(-150,div(num(-150),num(-150))),4),pow(mult(-151,div(num(-151),num(-151))),4),pow(mult(-152,div(num(-152),num(-152))),4),pow(mult(-153,div(num(-153),num(-153))),4),pow(mult(-154,div(num(-154),num(-154))),4),pow(mult(-155,div(num(-155),num(-155))),4),pow(mult(-156,div(num(-156),num(-156))),4),pow(mult(-157,div(num(-157),num(-157))),4),pow(mult(-158,div(num(-158),num(-158))),4),pow(mult(-159,div(num(-159),num(-159))),4),pow(mult(-160,div(num(-160),num(-160))),4)),0.25)))

At least I hope... I of course haven't been able to test it. If the enemy program is long enough, then the fourth root of (the sum of (its line numbers raised to the fourth power)) might be a little bit greater than the first line number, meaning that this will point to a line or two before the beginning of the enemy code.

If this function works, you might even write the program so the first line calculates and moves a bomb to that spot: automatic win if you go first. Then have the rest of the program take reasonable actions in case you're going second.

Link to comment
Share on other sites

  • 0

i've tried the Brutus Maximus against the hopper code from the initial post

0 137 137 137 and the hopper seems to beat it pretty regularly, so simplicity seems to be the way to go!

Link to comment
Share on other sites

  • 0

about the 117, yeah my bad... I was thinking about a different number. You are correct that there are 160 nodes that are not in the domain of your initial round-zero program.

And to everyone, this is the most recent emulator, with extra changes to make sure there are no numerical errors in regards to dividing by zero, etc. If you think the defaults I gave should be changed (ie, the result shouldn't be 0 for inv(0), div(x,0), etc) just tell me, I think 0 is a useful default though...


<html>

<head>

<title>VNA.4 Emulator, by unreality</title>

<script LANGUAGE="JavaScript">


/* global declarations */


var vna = new Array();

var alphastring = "abcdefghijklmnopqrstuvwxyz";

var capalphastring = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var p1vararray = new Array(26);

var p2vararray = new Array(26);


/* functions */


function doSwitch()

{

getp1 = document.form1.p1.value;

getp2 = document.form1.p2.value;

document.form1.p1.value = getp2;

document.form1.p2.value = getp1;

}


function doClear()

{

document.form1.p1.value = null;

document.form1.p2.value = null;

}


function doRandomStart()

{

document.form1.startline.value = Math.floor(117*Math.random())+42

}


function loadArray()

{

var pr1 = new Array();

var pr2 = new Array();

pr1 = document.form1.p1.value.split("\n");

pr2 = document.form1.p2.value.split("\n");

var nStart = document.form1.startline.value;

var error1="";

var error2="";

var error3="";

if (pr1.length > 40) error1 = "Program 1 is too long! ";

if (pr2.length > 40) error2 = "Program 2 is too long! ";

if (nStart=="") error3 = "You must specify a starting node for P2!";

error3 = error1 + error2 + error3;

if (error3 != ""){alert(error3); return;}

var iString;

var cString = document.form1.fillwith.value;

for (ihh=0;ihh<200;ihh++)

{

iString = cString;

if (ihh<pr1.length) {iString = pr1[ihh];}

if (ihh>=nStart && ihh<nStart+pr2.length) {iString = pr2[ihh - nStart];}

if (iString == undefined) iString = cString;

vna[ihh] = iString;

}

document.form1.vnarray.value = vna.join("\n");

document.form1.point1.value = 0;

document.form1.point2.value = nStart;

document.form1.rnds.value = 0;

document.form1.dornd.disabled = false;

document.form1.doxrnd.disabled = false;

document.form1.xrd.value = 10;

// fill variable arrays

for(iww=0;iww<26;iww++)

{

p1vararray[iww] = 0;

p2vararray[iww] = 0;

}

document.form1.seevars.disabled = false;

}


function doRound()

{

// increment round counter

document.form1.rnds.value++;

// pointer locations

var lineOne = document.form1.point1.value*1;

var lineTwo = document.form1.point2.value*1;

// P1 first

var zline = vna[lineOne].toLowerCase();

// count the number of spaces in zline

var chratloopy = 0;

var numspaces = 0;

while (chratloopy < zline.length)

{

if (zline.charAt(chratloopy) == " ") numspaces++;

chratloopy++;

}

var newline;

var paramz = zline.split(" ");

var valqa = doFunc(paramz[0]+"",lineOne,1)*1;

if (numspaces > 0) var valqb = doFunc(paramz[1]+"",lineOne,1)*1;

if (numspaces > 1) var valqc = doFunc(paramz[2]+"",lineOne,1)*1;

if (numspaces > 2) var valqd = doFunc(paramz[3]+"",lineOne,1);

if (numspaces > 3) var valqe = doFunc(paramz[4]+"",lineOne,1);

if (valqd != "!") valqd *= 1;

if (valqe != "!") valqe *= 1;

switch (numspaces)

{

case 0:

if (zline == "x")

{

document.form1.dornd.disabled = true;

document.form1.doxrnd.disabled = true;

alert("Program 2 wins!");

return;

}

else

{

newline = doMod(lineOne + valqa);

}

break;

case 1:

var firstchar = zline.charAt(0);

p1vararray[alphastring.indexOf(firstchar)] = valqb;

newline = doMod(lineOne + 1);

break;

case 2:

var replacestring = vna[doMod(lineOne+valqa)];

// check for capital variables

var zzingl;

var dropfwhenzero = 1;

while (dropfwhenzero == 1)

{

zzingl = replacestring.length;

dropfwhenzero = 0;

for (eee=0;eee<zzingl;eee++)

{

if (capalphastring.indexOf(replacestring.charAt(eee)) != -1)

{

replacestring = replacestring.substring(0,eee) + p1vararray[capalphastring.indexOf(replacestring.charAt(eee))] + replacestring.substring(eee+1);

dropfwhenzero = 1;

}

}

}

vna[doMod(lineOne+valqb)] = replacestring;

newline = doMod(lineOne + valqc);

break;

case 3:

var temptemptemp = vna[doMod(valqa + lineOne)];

vna[doMod(valqa + lineOne)] = vna[doMod(valqb + lineOne)];

vna[doMod(valqb + lineOne)] = temptemptemp;

if (vna[doMod(valqa + lineOne)] == vna[doMod(valqb + lineOne)])

{

newline = doMod(lineOne + valqc);

}

else

{

if (valqd != "!") newline = doMod(lineOne + valqd);

if (valqd == "!") newline = doMod(lineOne + valqc);

}

break;

case 4:

if (valqa == valqb) {newline = doMod(lineOne + valqc);}

if (valqa > valqb) {newline = doMod(lineOne + valqd);}

if (valqa < valqb && valqe == "!") {newline = doMod(lineOne + valqd);}

if (valqa < valqb && valqe != "!") {newline = doMod(lineOne + valqe);}

break;

}

//

//

// P2 now

//

//

var zline = vna[lineTwo].toLowerCase();

// count the number of spaces in zline

var chratloopy = 0;

var numspaces = 0;

while (chratloopy < zline.length)

{

if (zline.charAt(chratloopy) == " ") numspaces++;

chratloopy++;

}

var newxline;

paramz = zline.split(" ");

valqa = doFunc(paramz[0]+"",lineTwo,2)*1;

if (numspaces > 0) var valqb = doFunc(paramz[1]+"",lineTwo,2)*1;

if (numspaces > 1) var valqc = doFunc(paramz[2]+"",lineTwo,2)*1;

if (numspaces > 2) var valqd = doFunc(paramz[3]+"",lineTwo,2);

if (numspaces > 3) var valqe = doFunc(paramz[4]+"",lineTwo,2);

if (valqd != "!") valqd *= 1;

if (valqe != "!") valqe *= 1;

switch (numspaces)

{

case 0:

if (zline == "x")

{

document.form1.dornd.disabled = true;

document.form1.doxrnd.disabled = true;

alert("Program 1 wins!");

return;

}

else

{

newxline = doMod(lineTwo + valqa);

}

break;

case 1:

firstchar = zline.charAt(0);

p2vararray[alphastring.indexOf(firstchar)] = valqb;

newxline = doMod(lineTwo + 1);

break;

case 2:

var replacestring = vna[doMod(lineTwo+valqa)];

// check for capital variables

var zzingl;

var dropfwhenzero = 1;

while (dropfwhenzero == 1)

{

zzingl = replacestring.length;

dropfwhenzero = 0;

for (eee=0;eee<zzingl;eee++)

{

if (capalphastring.indexOf(replacestring.charAt(eee)) != -1)

{

replacestring = replacestring.substring(0,eee) + p1vararray[capalphastring.indexOf(replacestring.charAt(eee))] + replacestring.substring(eee+1);

dropfwhenzero = 1;

}

}

}

vna[doMod(lineTwo+valqb)] = replacestring;

newxline = doMod(lineTwo + valqc);

break;

case 3:

var temptemptemp = vna[doMod(valqa + lineTwo)];

vna[doMod(valqa + lineTwo)] = vna[doMod(valqb + lineTwo)];

vna[doMod(valqb + lineTwo)] = temptemptemp;

if (vna[doMod(valqa + lineTwo)] == vna[doMod(valqb + lineTwo)])

{

newxline = doMod(lineTwo + valqc);

}

else

{

if (valqd != "!") newxline = doMod(lineTwo + valqd);

if (valqd == "!") newxline = doMod(lineTwo + valqc);

}

break;

case 4:

if (valqa == valqb) {newxline = doMod(lineTwo + valqc);}

if (valqa > valqb) {newxline = doMod(lineTwo + valqd);}

if (valqa < valqb && valqe == "!") {newxline = doMod(lineTwo + valqd);}

if (valqa < valqb && valqe != "!") {newxline = doMod(lineTwo + valqe);}

break;

}




// render the VNA

document.form1.vnarray.value = vna.join("\n");

document.form1.point1.value = newline;

document.form1.point2.value = newxline;

}



function doMod(zeinput)

{

while (zeinput < 0)

{

zeinput += 200;

}

zeinput = zeinput % 200;

return zeinput;

}


function doFunc(param, qline, zpp)

{

if (param == "") return "";

if (param == "!") return "!";

if (alphastring.indexOf(param) != -1)

{

return doSuperFunc(param, zpp);

}

var tempeval;

var closeparen;

var funcin;

var beforeparstring;

var commaloc;

var parenloc;

var rightloc;

var funcname;

var inputarray = new Array();

/*var xdata = new Array();*/

// loop until param is just a number

while (param*1 != param)

{

closeparen = param.indexOf(")");

openparen = (param.substring(0,closeparen+1)).lastIndexOf("(");

funcin = param.substring(openparen+1,closeparen);

beforeparstring = param.substring(0,openparen);

commaloc = beforeparstring.lastIndexOf(",");

parenloc = beforeparstring.lastIndexOf("(");

rightloc = Math.max(commaloc,parenloc);

funcname = param.substring(rightloc+1,openparen);

funcname = funcname.toLowerCase();

//

/*alert(closeparen+" -- "+openparen+" -- "+commaloc+" -- "+parenloc+" -- "+rightloc+" -- "+zpp+qline); 

alert("Name: "+funcname+", Input: "+funcin);*/

//

inputarray = funcin.split(",");

for (yyyy=0;yyyy<inputarray.length;yyyy++)

{

inputarray[yyyy] = doSuperFunc(inputarray[yyyy],zpp);

}

switch (funcname)

{

case "sum":

case "add":

tempeval = 0;

for (tttt=0;tttt<inputarray.length;tttt++)

{

tempeval += inputarray[tttt];

}

break;

case "prd":

case "mul":

case "mult":

tempeval = 1;

for (ssss=0;ssss<inputarray.length;ssss++)

{

tempeval *= inputarray[ssss];

}

break;

case "inc":

case "incr":

tempeval = (inputarray[0] + 1);

break;

case "dec":

case "decr":

tempeval = (inputarray[0] - 1);

break;

case "neg":

tempeval = (inputarray[0] * -1);

break;

case "inv":

if (inputarray[0] == 0) {tempeval = 0} else {tempeval = 1 / inputarray[0];}

break;

case "num":

var linetoterm = vna[doMod(qline + inputarray[0])]+"";

tempeval = 1;

for (ccc=0;ccc<linetoterm.length;ccc++)

{

if (linetoterm.charAt(ccc) == " ") tempeval++;

}

if (linetoterm == "x") tempeval = 0;

break;

case "mod":

if (inputarray[1] == 0) {tempeval = 0} else{tempeval = (inputarray[0]) % (inputarray[1]);}

break;

case "pow":

tempeval = Math.pow(inputarray[0],inputarray[1]);

break;

case "div":

if (inputarray[1] == 0) {tempeval = 0} else{ tempeval = (inputarray[0]) / (inputarray[1]);}

break;

case "sub":

tempeval = (inputarray[0]) - (inputarray[1]);

break;

case "log":

if (inputarray[0] == 0) {tempeval = 0} else{tempeval = Math.log(inputarray[1]) / Math.log(inputarray[0]);}

break;

case "abs":

tempeval = Math.abs(inputarray[0]);

break;

case "int":

tempeval = Math.floor(inputarray[0]);

break;

case "ceil":

tempeval = Math.ceil(inputarray[0]);

break;

}

// replace part of param with tempeval... then loop again

param = param.substring(0,rightloc+1) + tempeval + param.substring(closeparen+1);

}

return param;

}


function doSuperFunc(qwerty, zppp)

{

var qwertest = alphastring.indexOf(qwerty);

if (qwertest != -1)

{

if (zppp == 1) qwerty = p1vararray[qwertest];

if (zppp == 2) qwerty = p2vararray[qwertest];

}

else qwerty *= 1;

return qwerty;

}


function doXRounds()

{

var getx = document.form1.xrd.value;

for (bbb=0;bbb<getx;bbb++)

{

doRound();

}

}


function seeVars()

{

var ystr = "P1:\n";

for (inn=0;inn<26;inn++)

{

if (p1vararray[inn] != 0) ystr += alphastring.charAt(inn)+" = "+p1vararray[inn]+"\n";

}

ystr += "\nP2:\n";

for (inn=0;inn<26;inn++)

{

if (p2vararray[inn] != 0) ystr += alphastring.charAt(inn)+" = "+p2vararray[inn]+"\n";

}

alert(ystr);

}


/* end of script */

</script>

</head>


<body>

<h1>VNA.4 Emulator, by unreality</h1><form name="form1">

<br><br><br>P1 <br>

<textarea name="p1" rows=10 cols=100></textarea> <br>P2<br><textarea name="p2" rows=10 cols=100></textarea>

<br>

<center><input type="button" value="Switch" onClick="doSwitch();"><input type="button" value="Clear" onClick="doClear();"></center>

<br><br><br><br>

P1 starts at line 0 and goes first<br>

P2 starts at line X and goes second<br>

X: <input type="text" name="startline" length="10"> <input type="button" value="Random" onClick="doRandomStart();">

<br>(range 42 to 158 please)

<br><br><br><br><center>Fill with: <input type="text" name="fillwith" length="10" value="x"></center><br><input type="button" value="Load the Virtual Node Array!" onClick="loadArray();"><br><hr><br>

VNA:<br><textarea name="vnarray" rows=30 cols=100></textarea><br>

P1 Pointer: <input type="text" name="point1" length="10"><br>

P2 Pointer: <input type="text" name="point2" length="10"><center>

<input type="button" value="Do 1 Round" name = "dornd" onClick="doRound();"> <input type="button" value="Do X Rounds" name="doxrnd" onClick="doXRounds();"> X:<input type="text" name="xrd" length="10"></center><br>

Rounds: <input type="text" name="rnds" length="10"><input type="button" value="See Nonzero Variables" name="seevars" onClick="seeVars();" disabled="true">

</form>

</body>

</html>

Edited by unreality
Link to comment
Share on other sites

  • 0

so here's my first attempt, the random bomber.

a 3

a sum(a,sum(mod(a,7),mod(a,13)))

1 a -1

x

here's my results against BM.

rounds: 67, 82, 57, 107, 49

1a RB wins

1b RB wins

2a RB wins

2b BM wins

3a RB wins

3b BM wins

4a BM wins

4b RB wins

5a RB wins

5b BM wins

so its basically a question of whether he's closer to me or i'm closer to him!

Link to comment
Share on other sites

  • 0

Thanks for joining the fray, philip! I've been busy and have yet to experiment with the lengthy-line dilemma, but later today I may have sufficient time to play around. Everyone has the most recent version of the emulator, though, I assume... too bad there's no way of editing the OP with the most updated.

I also have yet to inspect plasmid's superline and get the logic behind it... it seems impossible to me at first glance but I haven't thought about it carefully yet... anyway, i gtg, bbl...

Link to comment
Share on other sites

  • 0

i just had a bit of time so I wrote a program called "hopcalc.html"...


<html>

<head>

<title>Hop Calculator, by unreality</title>

<script LANGUAGE="JavaScript">


var curval = 0;


function gogogo()

{

var numits = document.form1.its.value*1;

var numcons = document.form1.cons.value*1;

var numnodes = document.form1.nodes.value*1;

for (i=0;i<numits;i++)

{

curval = (curval+numcons) % (numnodes);

document.form1.outp.value += (curval + "\n");

}

}


function ccc()

{

document.form1.outp.value = "";

curval = 0;

}


</script>

</head>

<body>

<form name="form1"><h1>Hop Calculator</h1><br><br>Hop Constant: <input type="text" name="cons" length="10" value="0"><br>Iterations: <input type="text" name="its" length="10" value="10"><br>Nodes: <input type="text" name="nodes" length="10" value="200"><br><input type="button" value="Go" onClick="gogogo();"><br><hr><br><textarea name="outp" rows=30 cols=30></textarea><br><input type="button" value="Clear" onClick="ccc();">

</form>

</body>

</html>

the Hop Constant is how much the program hops by, for example it could be 137. Nodes is 200 for this game of course, but you can change that for curiosity. Iterations is how many hops you want to do. It just adds the constant and mods by 200 each time, displaying the lines it will be at. Pretty simple yet useful... it's perhaps more useful as a bomb calculator to see where your bombs will land.

The variable is preserved globally so pressing the button again will continue from that point (and if you've changed the parameters, it will still continue from that point with the current variable in the newer settings). If you press Clear, it will wipe the display field and reset the counter variable to zero

Link to comment
Share on other sites

  • 0

i'm having an odd switch problem.

i wrote a "frog" program just to be funny but can't seem to get it to work properly. here's the code.

2 -5 -5 -5

x

5 -2 -2 -2

basically the code "leaps" over itself over and over again (hence frog) but when i ran it, it doesnt seem to execute the 5 -2 -2 -2 line properly.

Link to comment
Share on other sites

  • 0

okay, now i'm confused. i just tested it again and its working fine now. ????

when i first tried it, it would move the 5 -2 -2 -2 line fine but then it wouldn't move 2 -5 -5 -5 line.

well false alarm i guess.

Link to comment
Share on other sites

  • 0

i've had ideas for several programs, but most would require the ability to combine code, for example placing a set function inside a switch funtion.

is there any way currently to do that? if not, can you code it such that its possible?

Link to comment
Share on other sites

  • 0

the point perhaps is in the limitations of the code. There are clever ways to incorporate comparison stuff with the IF structure as well as with moduli and things, and a few other tricks you can do, like capital letter variables allow you to "edit" lines or custom-copy lines with current variables. Try things like that :D The language structure shouldn't be rewritten in any case to allow for certain programs; in fact it would be too easy if you could heap a bunch of commands on a single line. Usually there are things you can do to create an optimal program that's still efficient... maybe if you tell us some of your ideas we can help or see if it's not too far-fetched to tweak some things on the emulator?

Link to comment
Share on other sites

  • 0

here are several ideas i've had.

sweeper: a program that jumps 5 spaces, then checks the 5 lines below it to see if any are not bombs. if so , then it paces bombs on all 5 spots, and jumps 5 spaces again.

zombie: a program that copies itself, then kills the previous copy.

transfuser: a program that creates 1 copy if itself, and if initial one is compromised, uses copy to regenerate.

crawler: program that swaps between moving 1 line forward, and bombing 3 lines in front.

fibonacci: a program that shifts lines around based on the golden ratio.

pacifist: a program that copies itself over bombs (tries for ties without destroying opposing program)

Link to comment
Share on other sites

  • 0

here are several ideas i've had.

sweeper: a program that jumps 5 spaces, then checks the 5 lines below it to see if any are not bombs. if so , then it paces bombs on all 5 spots, and jumps 5 spaces again.

sum(num(8),num(9),num(10),num(11),num(12)) 0 1 5 !

k -4

k inc(k)

k sum(13,k) 1

k 4 9 9 -2

j inc(j)

-7 inc(j) 1

j 5 -6 -6 -2

I haven't yet tested its behavior when it encounters an enemy but it works good from what i've done so far. It's not too efficient, though, of course

zombie: a program that copies itself, then kills the previous copy.

0 137 137 137

transfuser: a program that creates 1 copy if itself, and if initial one is compromised, uses copy to regenerate.

this has been done in one of dms's programs I think, and more extensive regeneration subroutines were used in one of plasmid's programs

crawler: program that swaps between moving 1 line forward, and bombing 3 lines in front.

the trick here is to have a COPY line like this:

0|1 1|3 1|0

ie, it alternates from this:

0 1 1

to this:

1 3 0

at first glance it's not possible without an additional line to change a variable (which would make the self-copying a lot more complex) but I think it may be possible under a single line with the num function if you do something like this:

3

x

0

0 0 0

<actual program here>

it can refer back somehow to those three lines (x, 0, 0 0 0) and use the num() function to get values of 0, 1 or 3. I'll think about how this might be possible :)

fibonacci: a program that shifts lines around based on the golden ratio.

I'm not sure what you mean "shifts lines around" but here's a fibonacci incrementer:

s 0

t 1

s sum(s,t)

t sum(s,t)

2 4 1

2 3 -3

S

T

x

it will generate a continuous ouput over that last "x" starting with 1, then 2,3,5,8,13,etc. It could be changed to make it output the next number each one line down to create a list of fibonaccis

pacifist: a program that copies itself over bombs (tries for ties without destroying opposing program)

a while ago I imagined something called the "hijacker" which would only work if the VNA was filled with 1's instead of x's. In this case, the hijacker would simply be the numeral "1" and would eventually 'hijack' the opponent's code. This is easily avoidable if your first line replaces itself with a bomb and then jumps forward 1 to the actual start of the program, but still, an interesting concept... I don't think such defenses are really warranted unless hijackers are perceived as a very real threat depending on how your program is structured.

The pacifist is a bit different though... I think a simple hopper is effectively a pacifist in a way. Even Zebra Warrior, which bombed while hopping, forced a lot of ties while hopping around since the enemy got sucked in. An even faster hopper could easily overtake large programs and catch them in the game. The trick would be to NOT be a switch-hopper since that erases its travel, but a normal copy-hopper... I think a hop constant of something small, like 11 or maybe even as low as 7, would be most effective, provided it's coprime with 200.

Link to comment
Share on other sites

  • 0

I justed tested it and it works. It advances line by line (I can change it from just +1 to any number if you want) until it sees a non-bomb line 3 ahead from itself, which it proceeds to bomb before marching onward again.

See, no special clauses necessary :thumbsup: It was a fun challenge and probably a pretty decent program, with some tweaks.

To see it in action, make it P1 and make P2 "0 1 1" and distance P2 at 20 away or so.

edit - make sure you have the most recent emulator, which supports the ceiling function

Edited by unreality
Link to comment
Share on other sites

  • 0

In the search for a pretty-good program I have created a fundamentally-unbeatable program... here is my thought process, recorded in a text file because I had no internet access to post anything for a while. My thought process begins with the "Advancer" program that I posted in the two posts above this one, and then doodles around from there, eventually realizing the existence of an uber-super-program, deadly-accurate.

ceil(div(num(3),5)) inc(mul(ceil(div(num(3),5)),2)) inc(mul(ceil(div(num(3),5)),-1))

0/1 1/3 1/0

Trying the Advancer program above with advancing two each time and bombing four ahead if a nonbomb is encountered:

0/1 2/4 2/0

ceil(div(num(4),5)) sum(mul(ceil(div(num(4),5)),2),2) sub(2,mul(ceil(div(num(4),5)),2))

not good; can run up against uncopies.

GENERAL FORMULA:

should advance X and copy bomb N in front

0/1 X/N X/0

ceil(div(num(N),5)) sum(mul(ceil(div(num(N),5)),sub(N,X)),X) sub(X,mul(ceil(div(num(N),5)),X))

Advancer: X=1, N=small number (2 to 6 or so I'd say)

Flybomber: X=large & coprime with 200, N=decent gap (5 to 15 or so)

trying X=137, N=10 ... decent but eventually locked up.

any non X=1 program suffers from the same problem of continually trying to copy a nonbomb over a nonbomb and thus being stuck forever. It's still possible for an X=1 to suffer from this but very very unlikely.

Trying out a new class of program now, inspired by what I was just doing. If a one-liner can hop and bomb within itself I figure it can stay put and bomb somehow... but the variation in the Advancer/Flybomber technique comes from it moving around and thus the only stimulus to bomb comes from the nearby environment, with num() commands. So this oneliner bomber would have to use num() commands to fuel a continually advancing bomb arsenal.

A simple bomber could be a COPY or SWITCH statement...

COPY: 1 x 0

SWITCH: 1 x 0 0

where 1 is the bomb location (would have to gamble on that being a bomb of course but it should work), x is the bomb destination, and the 0s instruct it to jump back. The only advantage of using a SWITCH is that it gives an option to jump somewhere else if the switched lines were the same, so maybe only if I have a secondary line somewhere that we can jump to if the bomb after the SWITCH gets corrupted. But that can only work if we know that the target line is a nonbomb, in which case equal switch lines would mean that our bomb was corrupted. But it's highly unlikely even in that case that our corrupted bomb is now exactly the same as the line we're switching. And it's no use replacing bombs with bombs anyway. So there's no need for a SWITCH. So a bare COPY will work just fine:

1 x 0

The problem is, what to do for the x. I have an idea with varsetting:

The Jumplauncher:

a add(a,40)

a inc(a)

1 a -1

A

After the first line initialization it will stay in those middle two lines, with a bombing efficiency of 50%. It won't actually send bombs but rather copy the hard A to thus copy a number that the enemy will jump, hopefully jumping them into bomb territory. My original idea was to use hard vars to use them to advance the bombing, but you cant advance the vars without SET, so this loses the entire purpose of the varsetting. So might as well use "x" instead of "A" to have a surefire kill.

And my original idea in the first place was to have 100% bombing efficiency, so the Jumplauncher doesn't work. I'll have to rethink...

There might be a way to capture the enemy variables and use THEM to increment yourself by using the sum of all 26 of their variables... but the only way to access their variables is if your program finds their code and if they're using hard/capital vars, so you could've bombed them by that time anyhow.

So that leads us back to my original idea for this 100% B.E. bomber: using num()s to get a quasirandom number for bombing.

ie, in this line:

1 x 0

x equals sum(30,num(0),num(1),num(2),num(3),...,num(198),num(199))

We have 33 at least from the +30 and +num(0), after that bombs in the VNA count as zero and the opponent's lines add on. The problem is that x will never change if the opponent is self-contained, since if they bomb with bombs it will just override bombs for the most part and change nothing. Only if the opponent is some kind of hopper would they add additional nums to the VNA... but not if they're a more-efficient no-trace switch-hopper that deletes the previous copy. So using a massive addition function of nums() can't support a dynamically changing bomb target in a oneliner. It would work much better if it was facing against a bunch of different opponents that were replicating and bombing each other, but not one-on-one.

The next idea is a superline of sorts that would work like this: [i believe that plasmid offered a superline that use powers and then roots to find roughly where the opponent was but I was skeptical... I haven't yet checked his superline out yet and I don't have internet access right now, so I'll try constructing my own in a different fashion]

* check if num(z) > 0 ... if true, bomb, if not, try num(z+1)

Borrowing from the Advancer:

ceil(div(num(z),5))

the above snippet outputs 0 if line 'z' contains a BOMB, and outputs 1 for all other structures. A system would have to be rigged where a result of 1 ends it and a result of 0 adds on to the next z. In other words, they would be nested inside of each other, and the z above would itself be identical to the overall snippet, and ad infinitum to a certain point. It would be sneakier than that though because if it's just what I described, finding a nonbomb will then prompt it to check the line right after itself. We need to revamp the snippet to this:

sub(1,ceil(div(num(z),5)))

Much better. This returns 0 if we need to bomb and 1 to keep looking. If only we could add the result of this snippet to z itself for the next iteration. Then if we ever get to 0, it'll be z+0 and so on until the end, thus outputting z as the line we need to bomb (if we subtract the overall from 1 and then multiply by z for the final most-outside iteration). However, 1 is outputted if there's a bomb, so we need to find a way to add the output to the next z and so search the next node for enemy code.

I believe this is possible... say that this:

sub(1,ceil(div(num(z),5)))

is a function referred to as:

snip(z)

It just outputs 0 if we've found a nonbomb line, 1 if we've found a bomb line.

i think what we need to do is this:

snip(z+snip(z+snip(z...)))

say that we initialize the value of 'z' with 42, and the innermost section is simply snip(z+snip(z+snip(z))), coming to a halt.

it will first evaluate to this:

snip(z+snip(z+snip(42)))

If line 42 is a bomb, snip(42) it will evaluate to 1

snip(z+snip(z+1))

and we now have:

snip(z+snip(43))

oh crap. If snip(43) also evaluates to 1, we're left with 43 again on the outside. It needs to be like this:

snip(46+snip(45+snip(44+snip(43+snip(42)))))

etc [the above snippet is just the innermost section]

so if snip(42)=1, we'll check snip(44) next... crap, then snip(45) if that's a 1, and so on. Unfortunately snip(43) will never be checked but that's okay.

The problem is that I don't think this is the right behavior if snip(42) evaluates to zero (since zero means "bomb this line!") since the numbers cascade up.

What I'm saying is that for it to work, they ALL have to be 42, they can't cascade down 46,45,44,43,42... But we need an extra addition in each section. Something that retains the value of the line that was just processed, so that a result of 0 is a result of 0+n (where n is the line we found a nonbomb at) cascading ALL THE WAY UP.

In other words, each higher-leveled nest needs to check the line that was just checked inside PLUS the output of the line that was checked inside.

So we check 42, get 1. 42+1=43. Check 43, get 1. 43+1=44. Etc. Until we check say, 85, and get 0, which means nonbomb. 85+0 means 85 so we check 85 again, and again, and again, until we get out of the superline with the result of 85.

So each snip needs to check the line processed by the below snip plus the output of that. Ie, each snip, when evaluated, needs to look like this:

snip(x+snip(x))

So if we're checking line 63:

snip(63+snip(63))

If we need to bomb at 63, then 63 is returned for the higher level. If we don't, then 64 is returned.

So we need to have it so that each snip checks an addition of two things:

* the snip checked two levels down [63 in the above example]

* the snip checked one level down [snip(63) in the above example]

but of course nested.

42 ... the base unit

42+snip(42) ... our initial unit [checks 42]

42+snip(42)+snip(42+snip(42)) ... our next highest unit [checks 43]

42+snip(42)+snip(42+snip(42))+snip(42+snip(42)+snip(42+snip(42))) ... the next highest unit [checks 44]

etc. If a unit is this:

U

then the next highest unit this:

U+snip(U)

In a second I'm going to write a Perl script that starts with 42 as U and then iterates until we have checked node 199. 42 is checked with two appearances of 42, 43 checked with 4 appearances, 44 with 8 appearances, so node X will have 2^(X-41) appearances of the number "42".

So node 199 can only be checked if the superline has 2^(199-41) = 2^158 = 3.65375409 * 1047 occurences. In other words, in no way am I going to write that Perl script lol.

General formula to check nodes U through U+X is:

U -> U+snip(U) iterated

2 occurences of U for checking U

4 occurences of U for checking U+1

8 occurences of U for checking U+2

...

2^(X+1) occurences of U for checking from U until U+X

so to check from 42 to 199 it will take 2^(199-42+1) = 2^(158) as I already said.

But if I were to check, say, 42 to 158, the zone in which the enemy could be, it would only take 2^(117) occurrences of the number "42" in this superline.

This is roughly: 1.66153499 * 1035

But that's the smallest it can be to cover all possible starting nodes of the enemy program. I would then generate this string, and instead of the function snip(z) I would use:

sub(1,ceil(div(num(z),5)))

iterating this out until we have 2^117 occurences of the number 42. Then call that whole string x. The UBERBOMBER would then look like this:

1 x 0

And it would win on round 1 provided it went first. If it goes second, it would win on round 2 unless the enemy jumps out of the zone.

In curiosity of what would be physically feasible, I should think that 2^17 or 131072 is acceptable. It'd be a horrendoulsy long line, yes, but it wouldn't be impossible to generate. So that would enabling checking from U to U+16. I could keep a variable 'z' that starts off at 42 and then is incremented the next line by 17. Thus the program could comb through batches at once.

But if it's technologically possible under our circumstances teo extend out the snip() line, it can check EVERY SINGLE NODE with 100% ACCURACY and determine the exact spot of the enemy - and then bomb it - in a single turn.

*bow*

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...