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
Lunch time is now :D 12:09 :D

If we add a blank, it is executed, or is it jumped over..

eg

Do something

Blank

Do something else

does it Do somethin, do something else, or Do Somethign, WAIT Do something else

Link to comment
Share on other sites

  • 0

The Phoenix (Unreality)

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

The Edge (Taliesin)

COPY 1, 3

SPLIT 0

COPY 0, 2

number generated: 92

P1 roll: (odd=unreality, even=taliesin) 4. Taliesin is P1

so line 0 is taliesin's first line, line 92 is my first line

I'll play out the battle in a sec!

Link to comment
Share on other sites

  • 0
sweet :D I'm doing the Phoenix vs Edge battle right now, I didn't make anything to aid me so I'm doing it step by step, by hand. It might take a bit :P

Not sure I agree with your first line Unreality, That format is not in the specs!

Edit: Opps.. Sorry, skipped over that sentense in the spec :(

Edited by taliesin
Link to comment
Share on other sites

  • 0

num() would return 200. It's for programs that would play in VNA's with different number of nodes, just in case

anyway, the outcome of the battle:

Round Zero

COPY 1, 3

SPLIT 0

COPY 0, 2

(89 BLANKs)

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round One

COPY 1, 3

SPLIT 0

COPY 0, 2

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2 **

BOMB

JUMP com(a(c(-3)),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

Round Two

COPY 1, 3

SPLIT 0 (*2)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Three

COPY 1, 3

SPLIT 0 (*2) (*3)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Four

COPY 1, 3

SPLIT 0 (*2) (*3) (*4)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Five

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Six

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5) (attempted *6, failure)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Seven

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5)

COPY 0, 2

SPLIT 0 (*1)

COPY 0, 2

(87 BLANKs)

BOMB

COPY 2, -1, 33

JUMP 2

BOMB

JUMP com(a(c(-3)),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

And from that point forward Taliesin was caught in an endless loop trying to make a 6th executor while Unreality's program probed forward 3 more spaces every 3rd round until it hit line 201, which is also line 1, the second line of taliesin's program (SPLIT 0), however the a value was 0 so it took it to be a BLANK and continued, jumping 3 more, whose a value was also 0, so then it continued on, hitting line 91 BOMB, then line 94 BOMB, then line 97, which was one of my own commands (JUMP -2, 3). This triggered the compare switcher and a BOMB was copied onto the JUMP statement. When I hit it next, it killed me

Wow.... Taliesin got incredibly lucky :D His a-values all started with 0, except for one of them, otherwise my program would've DESTROYED his. If the randomly generated number had been 1 less, I would've found where his program was and loaded it with BOMBs. Dangit!

So, Taliesin won, but not in the intended way I think :P I'm going to tweak the Phoenix a bit to check both a and b values. Wow.

Link to comment
Share on other sites

  • 0

I've already tweaked it :D

The Phoenix (v2)

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

This Phoenix would've probed forward until it located the Edge, then loaded the Edge with BOMBs until Taliesin was dead :D

edit: Well it depends on the random placement of the two programs. 2/3 of the time I would still lose just because Taliesin's program is so small and the a/b values are almost all 0 (there's only one non-zero value in his lines) so there's no way to tell them apart from BLANK lines

Edited by unreality
Link to comment
Share on other sites

  • 0
I've already tweaked it :D

The Phoenix (v2)

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

This Phoenix would've probed forward until it located the Edge, then loaded the Edge with BOMBs until Taliesin was dead :D

Or until I wrote over you c varible and you ended up endless looping or bombing yourself

Edited by taliesin
Link to comment
Share on other sites

  • 0
see my edit :D

And no, your program was caught in an endless loop inside itself. It wasn't going anywhere :D

edit: I think this was the basic goal of your program:

COPY 0,1

or something along those lines. But this has no ability to win

What was the winning condiditon?

Link to comment
Share on other sites

  • 0
num() would return 200. It's for programs that would play in VNA's with different number of nodes, just in case

anyway, the outcome of the battle:

Round Zero

COPY 1, 3

SPLIT 0

COPY 0, 2

(89 BLANKs)

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round One

COPY 1, 3

SPLIT 0

COPY 0, 2

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2 **

BOMB

JUMP com(a(c(-3)),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

Round Two

COPY 1, 3

SPLIT 0 (*2)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Three

COPY 1, 3

SPLIT 0 (*2) (*3)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 27

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Four

COPY 1, 3

SPLIT 0 (*2) (*3) (*4)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Five

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Six

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5) (attempted *6, failure)

COPY 0, 2 (*1)

SPLIT 0

(87 BLANKs)

BOMB

COPY 2, -1, 30

JUMP 2

BOMB

JUMP com(a(c(-3)),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

Round Seven

COPY 1, 3

SPLIT 0 (*2) (*3) (*4) (*5)

COPY 0, 2

SPLIT 0 (*1)

COPY 0, 2

(87 BLANKs)

BOMB

COPY 2, -1, 33

JUMP 2

BOMB

JUMP com(a(c(-3)),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

And from that point forward Taliesin was caught in an endless loop trying to make a 6th executor while Unreality's program probed forward 3 more spaces every 3rd round until it hit line 201, which is also line 1, the second line of taliesin's program (SPLIT 0), however the a value was 0 so it took it to be a BLANK and continued, jumping 3 more, whose a value was also 0, so then it continued on, hitting line 91 BOMB, then line 94 BOMB, then line 97, which was one of my own commands (JUMP -2, 3). This triggered the compare switcher and a BOMB was copied onto the JUMP statement. When I hit it next, it killed me

Wow.... Taliesin got incredibly lucky :D His a-values all started with 0, except for one of them, otherwise my program would've DESTROYED his. If the randomly generated number had been 1 less, I would've found where his program was and loaded it with BOMBs. Dangit!

So, Taliesin won, but not in the intended way I think :P I'm going to tweak the Phoenix a bit to check both a and b values. Wow.

Do I get a trophy.. :D With me splitting you would have had to bomb me 5 times as well :D Which would be hard because I overwrite things with my split..

Link to comment
Share on other sites

  • 0
correction: actually it was post 9, not the OP

Taliesin: You get why your program ended up infinite-looping, right?

How about we match wits again? That first duel was a bit messed up lol

Ill do another one.. Do DEFEND MY CUP :D when I get time, amonst my study, War Room, Zombie etc.. :P

Link to comment
Share on other sites

  • 0
see my edit :D

And no, your program was caught in an endless loop inside itself. It wasn't going anywhere :D

edit: I think this was the basic goal of your program:

COPY 0,1

or something along those lines. But this has no ability to win

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

Edited by taliesin
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...