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 think I mentioned it, although it was a few pages back... ceil(x) stands for the CEILING function and is the counterpart to the FLOOR function, which we have as int(x). I thought it might be useful to add it as well and a few days later it came into play so that was a good call... anyway:

int/floor is basically truncate. Ie,

int(5) = 5

int(5.1) = 5

int(5.5) = 5

int(5.4987) = 5

int(5.9) = 5

int(5.9999) = 5

int(x) or floor(x) returns the LARGEST INTEGER that is SMALLER THAN or EQUAL TO the input

ceiling(x) or ceil(x) is similar but returns the SMALLEST INTEGER that is GREATER THAN or EQUAL TO the input

ceil(5) = 5

ceil(4.999) = 5

ceil(4.5) = 5

ceil(4.2) = 5

ceil(4.00001) = 5

ceil(4) = 4

you might think CEILING can be made with FLOOR but this is not true because of their behavior on whole numbers/integers. Both are needed to properly represent the integer-izing functions

Link to comment
Share on other sites

  • 0

i was thinking a bracket tournament because that would be a lot easier, but it would be cool to have three different programs fighting at once.

it would also be cool to have one long continuous battle. Each player would have a few programs. When the first program dies their next one would be randomly put in. This would continue until one person ran out of programs. The emulator would have to be redone but it would some more strategy into the battles.

Edited by dms172
Link to comment
Share on other sites

  • 0

I like it! I'm down for rewriting the emulator. In fact I was thinking of rewriting it in Perl anyway. The Perl will be command line interface so you won't actually get to see the emulator but I have an idea: there will be a constant input line where you can type things in, ie, something like:

"put-____.txt"

this would put a new program into the array at a random point. I would have all programs beforehand in text files in the same folder. The format for the text files would be like this:

line-one: name of program

line-two: name of author

rest-of-lines: the program itself

.. Another command would be:

"do-x" where x is the number of rounds you want to run.

After each command finishes, it will rewrite a special "array.txt" file in the same folder. When opened, this file will show the array, each of the 200 nodes on a separate line. Or I could write to an "array.html" file but that would be fancier for a loss of viewing speed (you'd have to open a browswer to 'view it in).

windows uses .txt, right? or is it .rtf? I'll try my hardest to make it cross-platform and easy for other people to use.

After a "do" command, it will inform you if any programs have died, and on what round. In fact, if in the middle of a "do" command, ie, if the round count it was fed is only partway through, and a program dies, it will stop the "do" and stop it at the round that the program died, and tell you about it.

How does all this sound?

I could make other fancier commands for more "live-action" battles, something like:

"edit-x-____" where 'x' is a node number (0 to 199, even though in the actual game there's no absolute addressing of course, only relative addressing) and the rest of the line after the second dash is what the line there is modified to. Might be interesting... you wouldn't use it for normal games though.

What do you think of this idea?

It would rank programs by the order that they're put in. P1 is the first program entered, P2 is the second, P3 is the third, etc. The system would be truly random in that there's no limits to where the enemy can be as long as they don't overwrite each other from the getgo.

Link to comment
Share on other sites

  • 0

I'm pretty far into the above emulator in Perl (I changed a few of the things I said above but same idea)... it can host potentially infinite programs, loaded willy-nilly at any point on the array (no check yet for overwriting so programs can start ANYWHERE though it would be redone if one overwrote the other from the very beginning). It's pretty powerful and fast... still have to finish some parts and do some testing...

Link to comment
Share on other sites

  • 0

It's looking great so far... like I said, you can have any number of opponents and add new ones in, and edit lines on the fly, and you can make the array any size you want (currently it's set to 200) and fill it initially with anything you want. I just have a few things to tweak (for example, when a program loads near the edge, it needs to be able to load wrapping around to the beginning, I have to give that functionality) and then program the function evaluator (but I've gotten pretty good at making that, and with Perl's powerful string operators it should be a breeze)

Link to comment
Share on other sites

  • 0

The only thing I have left (though I'll do some more extensive testing to make sure) is the capital-letter thing... ie, when you copy a line, any capital letters in the line get evaluated to numbers for the new line...

so this:

1 2 0

A b C

might look like this afterward:

1 2 0

A b C

27 b 422

that's pretty much the last thing I have left to do. Since I'm at it, any new feature requests? I was thinking of adding a function like this:

var(number) where number is 0 to 25. it would specify a spot in the alphabet linked to one of your variables. For example, var(0) would be equivalent to "a", var(1) is "b", etc. They would be lower-case, not capital, and would get copied as normal with the line. The only advnatage would be if you wanted to change which variable was being used without changing the variable itself or something. idk. Tell me if you think I should impliment that.

Let me know if you have any ideas :thumbsup: Also are there are any meta-commands for the emulator itself you want? Here's what I'm using now:

# "load-NAME.txt" will load a program into the array randomly

# and give it the last P<number> spot

#

# "do-x" will do X rounds

# if a program dies, the "do" will stop after the round that

# the program died in, even if there were more rounds to execute

#

# "edit-x-___" will edit line X to look like the rest of the line

# after the second dash

#

# "status" will report information on the round count as well as status of each program

# -1 means dead, otherwise the first number is the current position of that program's pointer

# the string after that is the variable list, a-z, separated by underscores

#

# "end" will end the game prematurely and exit the program

The 'edit' command has been very useful in troubleshooting & testing, but during an actual game it would be off-limits unless we were doing some kind of "live action" game in which you can make edits on the fly (might be fun if we can establish some ground rules).

Edited by unreality
Link to comment
Share on other sites

  • 0

Sorry I've been out so much lately, I'm getting a real beatdown at work, and unlike word riddles, I can't really do any VNA-ing without sitting down at a computer for an extended period of time. I've also had to postpone posting Phronism on dawkins.net for the same reason; I'd rather wait until I actually have some time to devote some thought to it instead of posting right away and not being able to really get into a discussion. But from what I've seen I like the prospect of getting a guided-missile, one-line killer program that decisively beat the brute-force carpet bombing approach.

Link to comment
Share on other sites

  • 0

yeah I've also been pretty busy but in a minute I will resume working on the perl VNA.4 emulator - it's pretty nice so far :P I'm just going to add the var() function I was talking about earlier (in case anyone wants to use it) as well as the capital-letter-copy thing [and are there any other featuers you want added?] and then I'll essentially be done save for some more testing

Link to comment
Share on other sites

  • 0

finished the above tasks and both seem to be working properly :thumbsup:

One thing is that assigning to the variable "x" will result your program dying because I check the first array entry to see if it's "x". This is remedial in a couple ways...

[1] introduce other possible bomb structures other than "x" (ie, the word "bomb", the word "xx", a period/dot, an equals sign, etc)

[2] make a quick fix that checks if it is x and only x, THEN die. Remember that if you want to jump by the variable x, you have to do "0 0 x" or "0 0 x x" or "0 0 x x x" or somesuch... or just not use the variable x lol.

Either solution fine by me. What do you think?

Link to comment
Share on other sites

  • 0

right now, everything is loaded when you start the emulator, but I'm thinking of having a pre-game questionairre type thing that lets you enter the $maxnodes variable (default is 200), so you could have an array of 1000 nodes or 80 nodes or whatever (no limits) rather than having $maxnodes be a constant I define in the code.

Another option of this pre-load thing would be allowing the user to say what the default non-program nodes of the VNA are filled with. A third option is what to do in the event of a victory... normally it exits the program, but I think dms mentioned something about being able to load a new program in in this case.

Hmmm yes... I'll add this pre-game thing.

Also I added a metacommand where if you type "ar", "array" or "vna" it will auto-open the "array.txt" file for you (just a convenience thing and it will only work in UNIX or Mac OS X, but hey it's useful)

Link to comment
Share on other sites

  • 0

alright, it's pretty much done! It has all the features of VNA.4 (except what to do about "x" and the variable "x", see my post two above this one to voice your opinion on that) and even more:

* you can specify how many nodes you want the array to be

* you can specify what the array is initially filled with

* you can load as many programs as you want as well as edit lines & load new programs in realtime during the game

* you can see the array as well as a status digest of the programs at any time

* you can run as many rounds at once as you want (it's EXTREMELY fast)

* you can specify the game to quit after someone wins, OR to prompt you to load a new program into the ring

* you can exit anytime

edit ~ after someone weighs in on the "x" issue, I'll upload the code for everyone to use! I personally think we should make bombs be equal signs ("=") so that the variable "x" is freed up and there's no confusion, and equal signs are easy to see & differentiate from other code

Edited by unreality
Link to comment
Share on other sites

  • 0

I've just added a new metacommand called "change" which lets you change any property (name, author, pointer [aka current line position] and any of the 26 variables) of any program, alive or dead.

Keep in mind that "edit", "load" and "change", which allow you to personally edit the VNA in the middle of a game, should only be used in-game if there's some pre-arranged system or sequence for doing so (ie, a game in which, every Nth round, players get to change one variable or one line of code or something like that)

Link to comment
Share on other sites

  • 0

keeping up my self-conversation (:P), the new bomb is a plus sign ("+"). Now the "x" variable can be used as normal.

Also the equal sign is now used to parse metacommand instead of dash, ie, "do=5" does 5 rounds, so as to allow negative numbers

The only thing I have left to do is the exclamation point ("!") convenience operator in the SET/IF structures, i'll do that later today

Link to comment
Share on other sites

  • 0

actually I've decided against adding the "!" thing- it just seems so silly and superfluous for no actual programming effect.

So, the perl emulator (emu.pl) is done! It resides in a folder on my computer along with the file "array.txt" (although you don't need that, it will create it if it can't find it) and a couple programs (i have "imp.txt", "hopbomber.txt" and "advancer.txt").

All you need to run it is the file itself (just a text file and name it "emu.pl") with any programs in the same directory. Remember that program text files are like this:

program name

author name

[[actual program here]]

for example, the Hopbomber is like this:

Hopbomber

Unreality

a sum(a,137) 1

a mod(sum(a,1),4)

2 prd(a,50) 1

a 0 134 neg(3) 134

+

If anyone is still interested in VNA (lol... ;D It's good cuz making the emulator was good practice) then post here by all means and I'll send you the emulator code. I think we should have a duel of say, 250 nodes per contestant, and each contestant enters two programs. So if three of us played, we would have a 750 node arena and 6 programs total

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...