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
Which would be hard because I overwrite things with my split.

The split actually doesn't overwrite anything... all that has to happen is for one of my BOMBs to hit the main SPLIT 0 that your last four executors were caught in, and all four of your executors would get destroyed in their next rounds. But you still would've won because your initial executor was 2 lines ahead, so I would've had to loop all the way around the VNA to get back to it, thus killing myself before that could happen :D Good job

Advice: Though for future games, don't count on that effect ;D Your program's actual intention failed, though it still won.

Copy 0,1 should move it down :D Wiping everything in its way

Exactly - so both programs are executing infinite loops of COPY commands endlessly. That would be a tie ;D

Edited by unreality
Link to comment
Share on other sites

  • 0
The Phoenix (v2) by Unreality


COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(com(a(c(-3)),b(c(-3)),a(c(-3)),1,1),0,1,3,3)

EDITC -4, add(c(-4),3)

JUMP -2, 3

COPY -4, sub(c(-6),b(-1))

EDITB -2, sub(b(-2),1)

JUMP -2

how d'you like that fourth line? hehe :P

Im working on Taliesins Double Edge ( Like the name?) and yes Im still at work :( Ill Pm when Im done.. :D Is there a limit to program size?

Link to comment
Share on other sites

  • 0
There is no limit, though technically, right now, it's 30, though that can easily be changed

edit: I probably won't be using Phoenix v2 because everyone knows the coding now lol :D

May I suggest you dont post the code for that reason?

Link to comment
Share on other sites

  • 0
I've perfected a new program :) Anyone wanna fight? Mekal? FIF? Hacker? Frost? Taliesin? Etc? :P

Oh, and with school tomorrow... won't be back here for about 16 hours, probaly more

And we should get this rated up to 5*, to overcome my personal One Star Vandal ;D

I got the logic correct ( this prog has no defense ) :D it probably wrong since I was doing it while trying not let my boss see :D

Jump 2,0,13

Bomb 0,0,7

Edita -2,0,1

Split 14,0,49

Split 20,0,67

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Bomb 0,0,7

Jump -9,0,-20

Jump 66,66,535

"Jump con(

add(

mul( a( a( -1 )) , 3),

add(

mul( b( a( -1 )), 5),

7

)

),

c( a( -1 )),

1,

3,

3

)

,0,0"

edita -3,sub( add( a (-2), div( a ( -2),3),1),0

Jump -2,0,1

Copy -6,sub( a( -4),3),0

edita sub( a( -6 ),4),sub( 0, add( a( -5 ),4)),

edita -7,add( a( -6 ),1),0

Jump -6,0,-11

"Jump con(

add(

mul( a( sub( 0, b( -8 ))) , 3),

add(

mul( b( sub(0,b( -8 ))), 5),

7

)

),

c( sub(0,b( -8 ))),

1,

3,

3

)

,0,0"

Editb -9,sub( add( b (-9), div( b ( -9),3),1),0

Jump -2,0,1

Copy -14,sub( 0, sub(0,b( -11 ))),0

Editb -12,add( b( -12 ),1),0

Jump -5,0,-8

Link to comment
Share on other sites

  • 0
I've perfected a new program :) Anyone wanna fight? Mekal? FIF? Hacker? Frost? Taliesin? Etc? :P

Oh, and with school tomorrow... won't be back here for about 16 hours, probaly more

And we should get this rated up to 5*, to overcome my personal One Star Vandal ;D

I'm developing a new program called the "Tidal Wave"

you should make a program that takes in these commands and runs the loop for you... BL should get THIS game automated :P

Link to comment
Share on other sites

  • 0
I'm developing a new program called the "Tidal Wave"

you should make a program that takes in these commands and runs the loop for you... BL should get THIS game automated :P

yeah Hacker is working on an emulator, I've been talking with him :D

taliesin: wait is that your program? Do you want to fight? What's with the random quotes in there? lol. Also can you please put it in the correct notation, which would be:

JUMP 2,0,13

BOMB 0,0,7

EDITA -2,0,1

SPLIT 14,0,49

SPLIT 20,0,67

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

BOMB 0,0,7

JUMP -9,0,-20

JUMP 66,66,535

JUMP com(add(mul(a(a(-1)),3),add(mul(b(a(-1)),5),7)),c(a(-1)),1,3,3), 0, 0

EDITA -3, sub(add(a(-2),div(a(-2),3),1),0

JUMP -2,0,1

COPY -6, sub( a( -4),3), 0

EDITA sub( a( -6 ),4), sub( 0, add( a( -5 ),4))

EDITA -7, add( a( -6 ),1),0

JUMP -6, 0, -11

JUMP com(add(mul( a( sub( 0, b( -8 ))) , 3),add(mul( b( sub(0,b( -8 ))), 5),7)),c( sub(0,b( -8 ))),1,3,3),0,0

EDITB -9,sub( add( b (-9), div( b ( -9),3),1),0

JUMP -2, 0, 1

COPY -14, sub(0,sub(0,b(-11))),0

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

JUMP -5, 0, -8

So is this your Double Edge? Cuz I got my program ready if you want to fight again

Edited by unreality
Link to comment
Share on other sites

  • 0

haha I ran through taliesin's program, seeing what it would do - and it essentially does the same thing as mine, except his has 29 lines, mine has 16 :D In this game, optimization is key

Here's mine....

Shielded Phoenix

JUMP 2

BOMB 27

JUMP com(com(a(a(-1)),b(a(-1)),a(a(-1)),1,1),0,1,3,3)

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

JUMP com(a(-3),168,4,4,-2), 3

COPY -4, sub(a(-4),b(-1))

EDITB -2, sub(b(-2),1)

JUMP -2

COPY -7, 6

EDITB -1, sum(b(-1),2)

JUMP com(b(-2),190,3,3,-2)

SPLIT 1

JUMP -1

COPY -2, -100

COPY -2, -100

JUMP -102

edit: You can probably see that the nugget code is the same concept as the Phoenix v2 (search for player in a wider scope, find them, bomb them 1-by-1), but I added lots of defense. It looks like Taliesin's concept was based off of the Phoenix v2 as well, so we'll see who triumphs :D

edit2: I could optimize it way better now that I know what Taliesin's program is lol, but that would be cheating :D And he can't either.

For the battle, I'm waiting to see if Hacker made the emulator or not today, cuz that would be easier.... maybe I'll work on one of my own, if I can find the right language to make it in :P

Edited by unreality
Link to comment
Share on other sites

  • 0

the old Hopper wasn't complete. This one's smaller by one line and better and works perfectly and smoothly :D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

edit: every 9th round it jumps off to the next version of itself X spaces away

example:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

jumps 150 spaces forward. You could simplify further and make it:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,148,148,-2)

if you knew what X was going to be. But making it all dependent on one variable only would mean you could change the jump distance at a fly and you would just have to change one number ;D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

I'm pretty proud of Hopper if you can't tell :P

edit2: the only restriction is that X has 3 as a minimum value and 197 as a maximum :P

Edited by unreality
Link to comment
Share on other sites

  • 0
the old Hopper wasn't complete. This one's smaller by one line and better and works perfectly and smoothly :D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

edit: every 9th round it jumps off to the next version of itself X spaces away

example:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

jumps 150 spaces forward. You could simplify further and make it:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,148,148,-2)

if you knew what X was going to be. But making it all dependent on one variable only would mean you could change the jump distance at a fly and you would just have to change one number ;D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

I'm pretty proud of Hopper if you can't tell :P

edit2: the only restriction is that X has 3 as a minimum value and 197 as a maximum :P

Did I win 2 in a row??

Link to comment
Share on other sites

  • 0
No I haven't even done the battle yet :D Read the end of page 6 and then all of page 7 ;D I'm guessing that I'll win, but we'll see who has the better algorithm :P

If you win I will have to write another, to do a best of three.. hmmm.. Taliesins Sharp Edge, or Taliesin's Flaming Edge hmmm

Link to comment
Share on other sites

  • 0
the old Hopper wasn't complete. This one's smaller by one line and better and works perfectly and smoothly :D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

edit: every 9th round it jumps off to the next version of itself X spaces away

example:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

jumps 150 spaces forward. You could simplify further and make it:

Hopper

COPY 0, sum(a(0),c(0)), 150

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,148,148,-2)

if you knew what X was going to be. But making it all dependent on one variable only would mean you could change the jump distance at a fly and you would just have to change one number ;D

Hopper

COPY 0, sum(a(0),c(0)), X

EDITA -1, sum(a(-1),1)

JUMP com(a(-2),3,sub(c(-2),2),sub(c(-2),2),-2)

I'm pretty proud of Hopper if you can't tell :P

edit2: the only restriction is that X has 3 as a minimum value and 197 as a maximum :P

Also you are using a "sum" function we dont get privy to :)

Link to comment
Share on other sites

  • 0
Also you are using a "sum" function we dont get privy to :)

Oops, I meant add ;D Sum, add, same thing :P

Okay, UR... You are up for a challenge... the "Tidal Wave" is almost complete and i challenge YOU!!!

great! The only thing is that you've seen my program :o Lol I might make a new one, not sure. I'll be on Tomorrow, but I'm logging off now for the day, sorry

What would

editb 0 add( b( 0 ), mul(7, a( 0 )) )

do?

EDITB 0, add(b(0), mul(7,a(0)))

essentially you're asking

EDITB 0, b(0)

Well b(0) in the b slot references itself, so impossible

And you can't do EDITX 0, X anyway.... I left that out of the rules, though it's common sense in a way. I'll make sure to specify that ;D

No EDITing the same line as the edit (or potential infinite loop). A ROUND-based infinite loop is fine (usually that player will lose, though sometimes not), but an infinite loop WITHIN a round means that the game will freeze, so no go :D

Okay... Thanks to Talisin my program is complete... so do i send It to you or do i post it here?

Neither... I won't be on for about 19 and a half hours or thereabouts, so you can reread your code... remember that I might be making changes to the codes I've already posted here, so don't base your code off of mine, that would be cheating :D

Link to comment
Share on other sites

  • 0
Neither... I won't be on for about 19 and a half hours or thereabouts, so you can reread your code... remember that I might be making changes to the codes I've already posted here, so don't base your code off of mine, that would be cheating :D

My code has actually nothing to do with yours... it is completely... okay... maybe not completely... but It isn't based of any of your phoenix codes...

Link to comment
Share on other sites

  • 0

Yeah I didn't mean that, I meant designed specifically thinking that 'Shielded Phoenix' would be your opponent - I was just saying that would be a mistake because you never know what program I'm gonna use :D

Taliesin:

COMMAND a(0), #, # is not allowed

COMMAND #, b(0), # is not allowed

COMMAND #, #, c(0) is not allowed

Can't point to itself cuz it has no value. But THIS is allowed:

COMMAND #, a(0)

in this case, anything for # is fine EXCEPT something that would essentially be this:

COMMAND b(0), a(0)

Because then we have our infinite loop. It's just common sense, but with programming we've got to be clear :D

Link to comment
Share on other sites

  • 0
Yeah I didn't mean that, I meant designed specifically thinking that 'Shielded Phoenix' would be your opponent - I was just saying that would be a mistake because you never know what program I'm gonna use :D

Taliesin:

COMMAND a(0), #, # is not allowed

COMMAND #, b(0), # is not allowed

COMMAND #, #, c(0) is not allowed

Can't point to itself cuz it has no value. But THIS is allowed:

COMMAND #, a(0)

in this case, anything for # is fine EXCEPT something that would essentially be this:

COMMAND b(0), a(0)

Because then we have our infinite loop. It's just common sense, but with programming we've got to be clear :D

I was just seeing if I could use it to potentually confuse your program to win :D

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