Jump to content
BrainDen.com - Brain Teasers
  • 0


unreality
 Share

Question

VNA

VNA stands for Virtual Node Array, and is the setting for this game, which I based loosely off of Core Wars, an old programming game... but Redcode was pretty hard to understand IMO, I think VNA Code (which I have invented over the past two days) is better and easier to learn. You need no knowledge of Redcode or Core Wars to play this game.

Back to the game.

The VNA is like a computer memory space, one-dimensional, and filled with nodes. A node is like a line of programming code. Before the game begins, all of the VNA's nodes have the BLANK command, but when the game begins, two programs are put into the VNA at random locations. The programs designed by YOU, the players of the game! They retain their order and everything, they're just placed in at a random spot in the VNA, though considerably far away from each other.

Each node refers to itself as 0, while the next line is 1 and the previous line is -1. The VNA wraps around so it's like a loop of nodes.

So in the beginning of the game, both player's programs are put into the VNA, and then each player starts with one 'executor'. An executor starts at the beginning line of the player's program and then executes that node, then the next, etc.

In one round, Player 1 (P1)'s executor executes one node, and P2's executor does the same. Then in the next round, etc.

Using the SPLIT and MERGE commands, new executors can be made or deleted. Let's say P1 has 2 executors while P2 has 1. The game would proceed like this:

Round One

* P1's first executor

* P2's executor

Round Two

* P1's second executor

* P2's executor

etc. Each player can have up to four executors running at any one time.

The goal of the game is to destroy the opponent's executors and be the sole master of the Virtual Node Array! Note that once your initial executor starts running, you have no more impact in the game except to see the outcome.

So how to program in VNA Code?

First, the commands. Each node is essentially a command. Each command (except BLANK) is followed by three values: a,b,c. If not specified, they are assumed to be zero. I call the a/b/c values input vectors, and they can be either a number or a function (will get to functions next).

The commands:


COPY a,b	   copies line a into line b (overriding the current line b)

JUMP a		 jumps execution to line a

BOMB		   destroys the executor that executed this node

SPLIT a		creates a new executor which begins running at line a. Cannot create more than four

MERGE		  deletes the most recently created executor. Cannot delete the initial executor

EDITA a,b	  a is the line number, b is the new a value for that node

EDITB a,b	  a is the line nummber, b is the new b value for that node

EDITC a,b	  a is the line number, b is the new c value for that node

BLANK		  what the original VNA is filled with. You can use BLANK commands too, it's basically a "do-nothing" command. BLANKs cannot hold a/b/c values like other commands can


Note that there are no 'c' fields in usage, but I left the possibility open for both data storage and in case I add more commands later that need a third input value as well


So, a/b/c values are either numbers (usually line numbers, remember that each node refers to itself as line 0) OR functions. So what are functions?


The functions:


a(n)			returns the a value of the node at line n

b(n)			returns the b value of the node at line n

c(n)			returns the c value of the node at line n

add(m,n)		returns m+n

sub(m,n)		returns m-n

mul(m,n)		returns m*n

div(m,n)		returns m/n

mod(m,n)		returns the remainder of m/n

pow(m,n)		returns m^n

com(m,n,o,p,q)  compares m & n. If they are equal, returns o. If m>n, returns p. If n>m, returns q

exe()		   returns the number of executors that you have currently running

num()		   returns the number of lines in the VNA

That's all I've got right now, but I think it's enough. You can nest functions within functions, in case you were wondering - in fact I do that in my example program. I call it 'The Bomber'

COPY 3, 4

EDITB -1, add(b(-1), 1)

JUMP -2

BOMB

Whoa! What's that do? The COPY command copies line 3 (which would be the BOMB) into line 4 (just a BLANK before, now it's a BOMB too). So this part of the VNA looks like this now:

COPY 3, 4

EDITB -1, add(b(-1), 1)

JUMP -2

BOMB

BOMB

In the next round, the next line is executed. The command on this node is EDITB, which edits the b field of a certain line. That line is in EDITB's a field, which is -1, so it's editing the b field of the line right before it. The line is edited to adding the CURRENT b field value [b(-1)] with the number 1. Basically, this EDITB line is incrementing the COPY's b field by 1. So the new code looks like this:

COPY 3, 5

EDITB -1, add(b(-1), 1)

JUMP -2

BOMB

BOMB

The next line is JUMP -2, which sends the executor backwards 2 lines to the COPY node again - phew that was close, we almost hit the BOMB command!

So now the program runs all over again, except this time it copies the BOMB command to line 5 (the next BLANK). Thus, as the executor loops over these three lines, it spews out a chain of BOMBs to eventually march upon the opponent. That's why I call it the Bomber :D

This isn't the perfect Bomber - because it only spews a BOMB command every third round, and the BOMB only advances one node each time. Depending on the size of the VNA, the opponent could have destroyed you by the time you lay the tenth BOMB. One way is to, based on the number of lines in the VNA, skip a certain amount of lines to place the next BOMB.

I made this slightly more complicated program next, I call it the Bomb Evader:

SPLIT -3

JUMP com(exe(),1,4,1,1)

MERGE

EDITA -3, sub(a(-3),2)

JUMP -4

COPY 2, sub(a(-5),7)

JUMP sub(a(-5),8)

JUMP 0

It works by sending a secondary executor backwards toward the opponent, with the initial executor checking to see if it's still alive with exe(). When/if the secondary executor is killed, the executor copies the line 'JUMP 0' to that line and then jumps itself to the JUMP 0 line, thus staying in the same place while the opponent's BOMBs continue past, destroying the original program, looping back around, and killing the Bomber, while the Bomb Evader stays alive. This could fail, however, if the Bomber is, say, 4 lines long and did some math to make a BOMB every 5th line done so that if it looped back around (based on num()) it would avoid itself. Though it would also be unlikely to hit the JUMP 0

If you're interested in building your own battle program and warring with other people, post here :D The cool thing is that I can play too ;D

Link to comment
Share on other sites

  • Answers 197
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 0
Yesterday I started working on a VNA emulator where I can just enter the programs, the VNA size and the max program length and it generates the VNA and then I can press a button to do a round (once I finish that I'll do one that repeats rounds until the game is over)

okay.. i am ready to fight... so should i post the program or send it to you?

Link to comment
Share on other sites

  • 0
either, doesn't matter ;D Unfortunately my emulator isn't done yet, I may finish it tomorrow, not sure. We can wait for that if you want, cuz it's kind of hard to do by hand :D

fine with me... so... can you send me the code for the emulator and instruct me on how to use it?

Link to comment
Share on other sites

  • 0

Do you have an old 8.x.something iMac that can run HyperCard? Lol my programming options are a bit scant right now, so I'm using the old bucket of wrenches in my room that serves as a computer, with the only programming thing I can do on it at this point - HyperCard. But HyperCard works fine... the only problem is that there is next to none string manipulation. No substring function, no left or right functions, no findsubstring, etc. You have to do it all with manual loops using chunk syntax like "character of" and "line of", etc.

Aaaanyway, I've made great progress (I started yesterday and did a bit today), I reckon that tomorrow if I put my mind to it I can finish it

But my export options are kind of lacking, unless you can run the old HyperCard (not the new OSX "Revolution" version or whatever it's called). Don't worry, I'll make sure it works perfectly before plugging our programs in and stuff :D

Link to comment
Share on other sites

  • 0
Do you have an old 8.x.something iMac that can run HyperCard? Lol my programming options are a bit scant right now, so I'm using the old bucket of wrenches in my room that serves as a computer, with the only programming thing I can do on it at this point - HyperCard. But HyperCard works fine... the only problem is that there is next to none string manipulation. No substring function, no left or right functions, no findsubstring, etc. You have to do it all with manual loops using chunk syntax like "character of" and "line of", etc.

Aaaanyway, I've made great progress (I started yesterday and did a bit today), I reckon that tomorrow if I put my mind to it I can finish it

But my export options are kind of lacking, unless you can run the old HyperCard (not the new OSX "Revolution" version or whatever it's called). Don't worry, I'll make sure it works perfectly before plugging our programs in and stuff :D

can you say that again in English? You have to remember that i can only program in HTML... Which does close to nothing compared to emulators...

Edited by Mekal
Link to comment
Share on other sites

  • 0

Basically, I'm making good progress on creating an emulator program that simulates the VNA and runs the programs against each other :D It's hard to work with strings (ie, characters in quotes like "bob") in HyperCard, but otherwise it's perfect for the job

And unless you have HyperCard on an old iMac, you can't run the emulator, is what it boils down to

Edited by unreality
Link to comment
Share on other sites

  • 0
Basically, I'm making good progress :D It's hard to work with strings (ie, characters in quotes like "bob") in HyperCard, but otherwise it's perfect for the job

And unless you have HyperCard on an old iMac, you can't run the emulator, is what it boils down to

oh... ya... i'm running on Windows vista... But good job on getting close to finnishing... :D

Link to comment
Share on other sites

  • 0
I think I've got it covered, you can if you want :D It'd probably be better and more accessible to everyone than mine ;D I'll work more on mine tomorrow - let us know if you decide to make one too :D

Ill see how much I can get dont on friday. If I complete it to a working level I will post it for testing..

Link to comment
Share on other sites

  • 0
I think I've got it covered, you can if you want :D It'd probably be better and more accessible to everyone than mine ;D I'll work more on mine tomorrow - let us know if you decide to make one too :D

I have the basic commands going. I need to know a few things about split. Can you explain SPLIT when you get a chance.

and if BOMB hit the main executor when there is asplit going and that kind of things.

How do you want the output? Ill upload a sample to my site to see what I have got :D

http://taliesin.net78.net/Brainden/VNA/battle.php

Edit: Posted Correct Link

Edited by taliesin
Link to comment
Share on other sites

  • 0

I'm not sure I follow what you're doing... is there any input in that? Where exactly are the 200 or so lines of the VNA? :D (The VNA size is a changeable variable in mine actually)

Well, I'll explain:

SPLIT a - unless there's already 5 executors running, a new executor is created, primed to run at the line denoted by 'a'. The current executor (the one that executed the SPLIT) jumps forward 1 as usual

MERGE - deletes the most recently created executor, and unless the deleted executor is the executor that ran the MERGE, the current executor jumps forward 1 as usual

Edited by unreality
Link to comment
Share on other sites

  • 0
I'm not sure I follow what you're doing... is there any input in that? Where exactly are the 200 or so lines of the VNA? :D (The VNA size is a changeable variable in mine actually)

Well, I'll explain:

SPLIT a - unless there's already 5 executors running, a new executor is created, primed to run at the line denoted by 'a'. The current executor (the one that executed the SPLIT) jumps forward 1 as usual

MERGE - deletes the most recently created executor, and unless the deleted executor is the executor that ran the MERGE, the current executor jumps forward 1 as usual

Yeah, I havent done the input page yet.. The VNA size is changable I put it to 10 for testing as 200 is a lot of information to take in and compare.. Will hopefully finish it off after work, before my "no computer" week..

Link to comment
Share on other sites

  • 0

Right, so I have my program nearly ready. Do we have an emulator yet? As I think (depending on the strategy of the other program) this might not be as easy to work out by hand as the previous one.

foolonthehill: 'Swarm'

challenger: ??

Should be ready after lunch (in about 2 hours)

And thanks for doing the hard work UR and taliesin - an emulator will make this quite a good game I think. If you need a hand, I can do a bit of php, but don't have a great deal of time at the moment.

Edited by foolonthehill
Link to comment
Share on other sites

  • 0
Right, so I have my program nearly ready. Do we have an emulator yet? As I think (depending on the strategy of the other program) this might not be as easy to work out by hand as the previous one.

foolonthehill: 'Swarm'

challenger: ??

Should be ready after lunch (in about 2 hours)

And thanks for doing the hard work UR and taliesin - an emulator will make this quite a good game I think. If you need a hand, I can do a bit of php, but don't have a great deal of time at the moment.

I will finish the Emulator tomorrow when I get back from Martial Arts. Just have to program a little more error checking, the function parser and do some tests :P

You can test it here http://taliesin.net78.net/Brainden/VNA/ as long as you remember its not finished yet

Edit: added URL

Edited by taliesin
Link to comment
Share on other sites

  • 0
I will finish the Emulator tomorrow when I get back from Martial Arts. Just have to program a little more error checking, the function parser and do some tests :P

You can test it here http://taliesin.net78.net/Brainden/VNA/ as long as you remember its not finished yet

Edit: added URL

Looks good. I tried it with a couple of basic programs and it seems to do the basic operations well enough (though I couldn't get JUMP to work?). Obviously without the function parser it currently just strips out the brackets of the function, turning b(1) into b1, which it interprets as 0...but will be great when it's done.

I can't decide if my program is a winner or not, so am keen to give it an outing! It will be interesting what sort of strategies work best for this (actually having just read back through, mine has some elements similar to previous suggestions)

At the moment Taliesin seems to have shown that 'defence'-type programs that get caught up in themselves are best, leaving the 'killer'-type program to self-desctruct :D!

Link to comment
Share on other sites

  • 0
Looks good. I tried it with a couple of basic programs and it seems to do the basic operations well enough (though I couldn't get JUMP to work?). Obviously without the function parser it currently just strips out the brackets of the function, turning b(1) into b1, which it interprets as 0...but will be great when it's done.

I can't decide if my program is a winner or not, so am keen to give it an outing! It will be interesting what sort of strategies work best for this (actually having just read back through, mine has some elements similar to previous suggestions)

At the moment Taliesin seems to have shown that 'defence'-type programs that get caught up in themselves are best, leaving the 'killer'-type program to self-desctruct :D!

I think you just have to get the right program for the right opponenet. You dont get enough soace to do a one prog fits all..

Im glad someone is using the simulator :D

Link to comment
Share on other sites

  • 0

I tried it out, looks pretty good. I'll have time to finish mine this weekend, and since I can't see the coding of anything else (and don't understand PHP anyway :P) it'll be the only one I trust, lol. Unless I can't get the function evaluator to work right, then I'll use taliesin's lol. All I have left to do is to program the EDITA/B/C commands and then the function evaluator (the "function function" haha)

Link to comment
Share on other sites

  • 0

A question mainly for the OP, but also anyone involved in an emulator: is there a limit to the memory available for a) command lines b) command arguments. ie, how long can our command lines be and what are the numerical/memory limits for a,b and c.

UR showed us the line he was very proud of ;)

JUMP com(com(a(c(-3)),b(c(-3)),a(c(-3)),1,1),0,1,3,3)
but could we include much longer ones? And what would the effect of overflowing a variable be? eg
BOMB 2

EDITA -1,pow(a(-1),a(-1))

JUMP -1

I think I might have a super-efficient killer program, but not sure whether it it will be effective....

Link to comment
Share on other sites

  • 0

If it's killer as in "kill the emulator", that's not the goal ;D The goal is to kill the opponent program, not the emulator interface lol

Which is why the following are not allowed:

EDITX 0,x,x

Where X is A, B or C and the little x's are anything. You can't edit the edit line lol

just as a(0) in the 'a' spot, b(0) in the 'b' spot, c(0) in the 'c' spot, or anything that equates to be one of those is not allowed either

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