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

What the hell- someone hates me, lol. I looked at it and someone gave it 1* :rolleyes:

edit: I've gotten it up a little bit with some help, still at 4*, oh well. Some people are just immature :(

aaaanyway... I know the concept might be hard to get your head around, but is anyone interested in this? :D

Edited by unreality
Link to comment
Share on other sites

  • 0

I know :D Take your time, and I'll dream up some ideas of a killer program ;D

Clarifiers: (don't read until you've read [and understood :P] the OP)

* there can be some ambiguity about what is done next round after a SPLIT. The rule will be thus: I will find the most recent executor executed and then continue from there. For example, you have 1 exe, then SPLIT another. The next round will go to the 2nd exe, because two follows one. Say you have 2 executors now, and the first exe uses SPLIT to create a third... in this case, the next round will be the 2nd as usual, then the 3rd after that. If the SPLIT was used on the 2nd exe, then the next round will be the 3rd. It's common sense, but I need to clarify how the SPLIT works, just in case :D And MERGE works the same way, just in reverse

* if the functions a(n), b(n) or c(n) are used on a BLANK command, they will return 0, as if the BLANK was BLANK 0,0,0, even though the BLANK has no input vectors at all

Link to comment
Share on other sites

  • 0

oops I made a slight mistake in the Bomb Evader.

Instead of this:

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

this is better:

SPLIT -3

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

MERGE

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

JUMP -4

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

JUMP sub(a(-5),7)

JUMP 0

I know, minor detail :D

Edited by unreality
Link to comment
Share on other sites

  • 0

No, I've made this to be very different from any sort of programming language. After a few games and whatnot you'll learn how it works :D

I just came up with one type of program that I call a Hijacker, and it's code is just BLANK. It just progresses one node forward each round until it hits the first node of the opponent's code, and thus "hijacks" it. The chance of winning with that is low and heavily dependent on the other person's code, however, and they can easily prevent Hijackers by putting this at the beginning of their code:

COPY 2, -1

JUMP 2

BOMB

[real program starts here]

Another program, which I'm calling an 'Endless Copier', just consists of COPY 0,1... it copies itself forward forever, copying over the opponent's program when it reaches it too, turning both programs into infinite, endless copiers - that would be a tie :D

And I've thought of a more complicated one (I'm gonna call it the Overloader) that I'm gonna start working on ;D

Link to comment
Share on other sites

  • 0

Soooo...

People Interested So Far:

Unreality

Frozen in Fire

Mekal

Pretty good so far, for having posted it less than two hours ago :D

edit: a major perk of this game is that all you need to do is make your program and PM it in when the match is going to begin, because after that you have no control on the game and don't need to be here every x hours or whatever ;D

Edited by unreality
Link to comment
Share on other sites

  • 0
Soooo...

People Interested So Far:

Unreality

Frozen in Fire

Mekal

Pretty good so far, for having posted it less than two hours ago :D

edit: a major perk of this game is that all you need to do is make your program and PM it in when the match is going to begin, because after that you have no control on the game and don't need to be here every x hours or whatever ;D

Remind me of a game I playey a few years back, where you had to program robot AI :D

Link to comment
Share on other sites

  • 0

Sounds interesting... it reminds me of an older programming game I used to play a many years ago involving robots in an arena. You got to customize the robots though, and then had to write programming routines for them to use while battling each other.

Will our programs be posted and visible to everyone else? Like lets say someone were to come up with a really killer program, yet its code is posted during the battle for everyone to see. During the next round people can copy ideas from that program or design their programs specifically to beat that one.

If there's no time constraint I'll definitely play, this sounds cool, but it might be about a week before I have enough time to work on a program.

Link to comment
Share on other sites

  • 0

Sinistral: programs are PMed in privately, but once the match begins I think they'll be opened. I might have a Tournament at some point too, where you enter one program and there's a bracket system. But yeah everything will be open source after the match :D

Taliesin asked some questions:

What does the "c" varible do?

Inside the code block on the OP of this topic I talked about this: essentially the c input is there in case I add more commands later that may need more input values, AND to store extra data, if desired

can we COPY "BLANK" -1?

What do you mean? COPY's structure is this:

COPY a,b... a is the line to copy, b is the line to copy it to. So if a pointed to a BLANK and b was -1, then yes :D

People Interested So Far:

Unreality

Frozen in Fire

Mekal

Taliesin

Sinistral

Link to comment
Share on other sites

  • 0

Interesting...a doubly-linked circular list, eh? How do you keep coming up with all of these games, unreality? It's crazy. There are already so many games going on. I would participate, especially since I like programming, but like always, I have too much work... :P

Link to comment
Share on other sites

  • 0

On a side note, what do you guys think of the VNA having 200 nodes? The two programs' starting lines would be placed randomly from 80 to 120 lines apart (and thus 120 to 80 lines apart in the opposite direction). Too much? Too little?

edit:

Players Interested So Far:

Unreality

Frozen in Fire

Mekal

Taliesin

Sinistral

Players Ready For a Fight: (name and program name)

Unreality - The Phoenix :D

Edited by unreality
Link to comment
Share on other sites

  • 0

I'm thinking 200 nodes in the VNA, but the two programs' starting lines can be anywhere from 20 to 180 nodes apart going forwards (and thus 200 minus that number going backwards), the number produced randomly

~~~

Players Interested So Far:

Unreality

Frozen in Fire

Mekal

Taliesin

Sinistral

Players Ready For a Fight: (name and program name)

Unreality - The Phoenix

edit: To make way for possibly larger programs, the VNA will consist 200 nodes and the distance between the first node of P1's program and the first node of P2's program will be random from 30 to 170

Edited by unreality
Link to comment
Share on other sites

  • 0
I originally meant 4 total, but I picked it arbitrarily, I could change the max number of executors if you want (the current max is 4, see the SPLIT command in the OP)

Well make you decision, 4 or 5 so I can work my program around it..

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