Jump to content
BrainDen.com - Brain Teasers
  • 0


Prime
 Share

Question

I have developed my own VNA emulator in Excel. Let's call it VNA2.e. You can download (or open and save) it from VNA2.e

Of course, you must have MS Excel on your computer. The workbook contains macros (lot's of them) so you may need to change your browser's security settings to allow downloading/opening that file.

It was a somewhat sizeable project (about 1500 lines of code). The emulator features own parser and a rudimentary user interface with input validation error checking. I did it to keep my programming skills alive and to learn programming in Excel. I'm sure, it is still full of bugs, so I could use help in testing it. Run your VNA programs in it and let me know if some commands or user interface do not perform as coded.

The Emulator comes with 5 sample VNA warriors: Fish2, Fish2.2, and Fish3 (of my own design); and Awesome and Ghost (by Unreality copied from his VNA topic). The Worksheet "VNA Reference" contains information on how to operate the emulator.

Have fun. We shall have another tournament soon. :)

Link to comment
Share on other sites

Recommended Posts

  • 0
Sweet. i've been want something like this. :D now i just:D need excel :P

There is such thing as Excel Viewer, which, I presume, you can download from Microsoft for free. I'm not sure how it handles macros.

Also, there is Open Office Org (OOO), a free software suit that matches closely Microsoft Office. I have one on my computer and I know you can open an MS Word document with it. Again, I never got around to check whether it can open/convert Excel with macros into its own format.

Link to comment
Share on other sites

  • 0
I just noticed somthing... when i was trying out the code, any numbers such as -1 refered to -1 away from line 0, or 50 would equal 50 from line zero... not from the line of code... you might want to fix this, it messes up the programs...

Can you give me a specific case, like the argument and the line where it was placed, so that I can test it?

Does it happen in VNA_RUN worksheet, or in the in the worksheet containing your program when you run VNA_Test on an argument?

I designed the Emulator to convert address references for 200-node queue. E.g., if you refer to the address -1 from the line zero, it should convert to 199. For example, a(-1) placed in the argument "a" at node zero should return whatever the argument "a" at the node 199 evaluates to.

On the other hand, if the Emulator modifies non-address references -- that would be a bug.

The address references are the arguments of a(), b(), and c(), and nzero() functions. Also, an "a" argument on any EDITx and JUMP command, "a" and "b" arguments of COPY, PCOPY, SWAP commands, and all three arguments on SHIFT command.

For now the Emulator relies on the program to start at line 2, column 2 of the worksheet. It goes through the 4 columns, 40 lines from that point. Both VNA_Test and VNA_RUN (Load/Reset) count on it. This a shortcoming of the user interface. However, making it to pick up the entire program from an arbitrary point in the worksheet would require quite a bit of additional programming effort.

Link to comment
Share on other sites

  • 0

One additional note:

When writing VNA program, you must start it from line 2, column 2 in the worksheet; and the program extends through line 41 of the worksheet (40 nodes). Any blank lines in that region will be converted to BLANK command. However, when you test an argument by selecting its cell and running VNA_Test macro, the node references (offsets) may range through the entire 200-node interval. That is from line 2 through 201 on the Worksheet. So if your argument refers to some other argument at node 150, you may want to put some number, or expression there for your test purposes. Otherwise, an empty cell evaluates as zero.

Link to comment
Share on other sites

  • 0

Another note: I did not implement smart equ() function, like Foolonthehill suggested. My parse() function evaluates arguments as it parses them. Thus, since the entire argument must be parsed, everything gets evaluated too. So, for now we, must avoid references leading to infinite regress, even when such references are not logically executable. Like a(1,1,1,a(0)) in argument "a", for example.

Link to comment
Share on other sites

  • 0
What i am saying is if i ran a jump line from line 2 of the VNA, and the A argument is -1, it goes to line 199, not line 1... or if i have a jump line on line 45 and the A argument is -4, the pointer jumps to line 196, not line 41...

Good catch! I mainly used SHIFT command for my VNA programs and never tested JUMP command properly. There was a simple bug there -- I forgot to add current location to the argument "a". I put corrected VNA into the same place.

Please download that new version and discard the old one.

Thanks. :)

Link to comment
Share on other sites

  • 0

finished my JavaScript emulator :D Works awesome, very fast, and able to handle the kind of crazy backloops that the excel emulators were having trouble with. Although it has some error detection in the beginning, it doesn't detect if you're using the correct syntax (other than auto-capitalizing commands and de-capitalizing functions), so I don't know what will happen if you plug in bad syntax, let's not find out :P

anyway, here it is ;D Enjoy! Just drag it onto your web browser and voila!

http://brainden.com/forum/index.php?s=&amp...st&p=109350

I may make future updates to it, if a feature is requested

Edited by unreality
Link to comment
Share on other sites

  • 0
finished my JavaScript emulator :D Works awesome, very fast, and able to handle the kind of crazy backloops that the excel emulators were having trouble with. Although it has some error detection in the beginning, it doesn't detect if you're using the correct syntax (other than auto-capitalizing commands and de-capitalizing functions), so I don't know what will happen if you plug in bad syntax, let's not find out :P

anyway, here it is ;D Enjoy! Just drag it onto your web browser and voila!

http://brainden.com/forum/index.php?s=&amp...st&p=109350

I may make future updates to it, if a feature is requested

It did not work for me for some reason. Just increments the rounds counter, but does not move pointers. I get HTML message "error on the page".

Meanwhile...

I found and fixed another bug in my Emulatror. It was in the nzero function, which was getting an error unless "a" was non-zero. The corrected Emulator version is in the same place.

Link to comment
Share on other sites

  • 0
nzero is not an actual function, I was just using it to explain some things, later in the OP I gave what you could use with existing functions to calculate nzero and make it more flexible

as for the emulator - maybe it didn't upload properly, cuz it works great for me. I'll post the raw code in the VNA 2.0 topic

nzero(n) is an actual functions. Please, read VNA2.0 specifications. The nzero(n) returns zero if all three arguments of the node at offset n were zeros, otherwise it returns 1. I am using that function for my Fish4, which is designed to catch and destroy hoppers, such Fish2 and Ghost. ;)

Link to comment
Share on other sites

  • 0

lol I invented VNA, and I know what's there :P Like I said, I put nzero in the function codebox but then later, in the OP (if you read the whole thing, it's near the bottom of the OP) I explained that it wasn't an actual function but rather a general case, and I gave the replacement function that did the same thing but was much more flexible in the AZ/NZ values returned

It's really kind of insulting to say "please, read VNA 2.0 specifications"... when I invented them...

edit: I don't have a problem with putting nzero in, I think that's awesome (after all I did put in the function box, just as a pseudo-function), but it's just the way you said it. nvm.

Also, have you posted the Fish2.2 code anywhere? I downloaded your excel emulator but when I opened it, it freaked out, opened all of the code and said there was a bunch of debugging errors. Then it wouldn't let me quit, it kept popping up saying there was an error somewhere, so I had to force quit. Did that happen for anyone else?

Edited by unreality
Link to comment
Share on other sites

  • 0
lol I invented VNA, and I know what's there :P Like I said, I put nzero in the function codebox but then later, in the OP (if you read the whole thing, it's near the bottom of the OP) I explained that it wasn't an actual function but rather a general case, and I gave the replacement function that did the same thing but was much more flexible in the AZ/NZ values returned

It's really kind of insulting to say "please, read VNA 2.0 specifications"... when I invented them...

edit: I don't have a problem with putting nzero in, I think that's awesome (after all I did put in the function box, just as a pseudo-function), but it's just the way you said it. nvm.

Also, have you posted the Fish2.2 code anywhere? I downloaded your excel emulator but when I opened it, it freaked out, opened all of the code and said there was a bunch of debugging errors. Then it wouldn't let me quit, it kept popping up saying there was an error somewhere, so I had to force quit. Did that happen for anyone else?

Now nzero(n) is a function. Everything included in your original specifications in VNA2.0 topic in the codebox is implemented. I am also thinking about implementing new and() and or() functions to help cutting VNA expressions down in size.

I see nothing insulting in referring to VNA specifications. I did say "please". The specifications are, obviously, inside codeboxes in that post. If you contradict it latter on, I am going with the earlier statement. I invested a lot of time into VNA emulator, and into nzero() function, in particular. It is natural for me to be peeved when after all that effort you inform me that it is not actually a function. <_<

Also, my emulator does not have any problerms with any kinds of "backloops". As I said before, I wrote my own parser, which does not rely on any built-in Excel/VBA features, but goes through the input character by character, checking the syntax and interpreting and executing commands. I, arbitrarily set nesting limit to 100.

The Emulator works for me, allowing to enter and run VNA programs and display the results.

Fish2.2 as well as Fish3 included with the Workbook. I don't know what happened in your Excel. It could have something to do with the settings on your computer. (I presume, you have MS Excel installed.)

I suggest the following procedure for downloading my Emulator. Press on the link I gave and the browser should ask you whether you want to open or save the file. You can save in the directory of your choice on your computer, making sure the file name has ".xls" extention. Or you can open it in the browser and then use "save as" from the file menu. When you open VNA workbook, all macros run in the background and should not should not show any programming code. I used MS Office2002 Excel version. Also, you should set your Excel options to medium or low macro security level. (From the top menu: Tools-Options-Security tab-Macro Security button.)

It could be that you already have some macros default code in your Excel setup. And maybe that starts debugging whenever you open a workbook. Have you written or downloaded any marcros with Excel before? Maybe, FONH can give some suggestions. I am under impression, he has a thorough knowledge and understanding of the Excel.

What version of Excel do you have?

Link to comment
Share on other sites

  • 0

it says:

Microsoft Excel 2004 for Mac

Version 11.0

it could be that something is not working cross-platform, knowing MS. I have no macro security at all, so w/e. I'll just use one of my two emulators lol :lol:

Anyway - about nzero() - I guess I'll add it to mine, though did you also add rand()? I had that one there too, but removed it later [just like nzero()]. If you have, rand() at least needs to be removed without a doubt

And what exactly would the and/or functions do? Would they be bitwise operators? Because you can just use the com() function or its siblings (equ,geq,leq) for bitwise operations too, as well as base10 and/or functions

Link to comment
Share on other sites

  • 0

It well may be that MS Excel with macros does not work on Mac. Pitty. I've prepared a non-functional data only copy of my Emulator. So that if Excel macros don't work on your computer, you can at least see what it looks like. It also includes sample programs and VNA reference. But it has no macros (programming code), allowing to validate and run VNA programs.

Also, I made some updates to the Emulator. I changed it to highlight and select the command which is going to be executed next, instead of the command that just has executed. That seems to make more sense, somehow. Also, few other cosmetic changes here and there. Please download the updated version of the VNA.

nzero(n) function performs as coded. It equals zero when all 3 arguments at line "n" are zero, and 1 otherwise. It is a very powerful tool. Using it, I wrote Fish4 (Shark), which feeds primarily on Fish2 and Ghost. And I managed to keep the arguments in the SHIFT command down to a manageable size.

I have changed my mind about implementing and() and or() functions. They would make coding conditions too easy. I think the competition is more interesting using less convenient equ() and com() functions. Programs' ability to check all locations at once on the VNA battlefield must be limited.

My Fish4 (Shark) is almost ready. I'd like other contestants to post here whether they are close to developing their VNA combatants. I can run a tournament on my emulator, since it's been working well for 100s and even 1000s of rounds at a time, while evaluating long multi-story arguments refering to each other. B))

Link to comment
Share on other sites

  • 0
Cool :D Do you mind if I overindulge on function nesting in my Quicksand then? My goal is to make it as small and concise as possible, but there will be at least three nested equs, maybe more. Just let me know if there's a flood limit or if something will slow it down.

I set nesting limit to 100, arbitrarily. So, at any point point inside your argument if you count more than 100 opened left parenthesis (yet unmatched with the right parenthesis) -- that argument would fail. For example, equ(a(add(c(20),1)),2,0,1) has nesting level 4 at the point highlighted in red. However, there is no guaranty that that statement would not exceed maximum nesting level of 100. The reason being, there are further references like a() and c(), which can, in turn, nest deeper, and then make some further refernces to other arguments.

I am thinking to make a quilifying test for the tournament entry. A program must be able to run unopposed for a certain number of rounds, say 100, without bombing itself, or bumming out on nesting limit. Currently, my Fish4 has a problem with the latter requirement. Starting in the empty field, it runs 68 rounds and then exceeds the nesting limit as it keeps finding own copies left behind. I am working on improvement. Currently, Fish4's main decision-making argument features 7 equ()-s, 6 argrument references, 4 nzero()-s, and 3 add()-s. And the deepest level of nesting at any point there is 7.

Also, I am thinking of adopting the following scoring system:

1). 4:0 when opponent's pointer hit the bomb.

2). 3:1 when a program runs over the opponent leaving 2 copies of itself running with neither hitting a bomb.

3). 2:2 when two programs ran for a specified number of rounds, e.g., 1000, without any of the above conditions happening.

4). 0:0 when one of the pointers exceeded allowed nesting level.

I am not sure, whether the last condition is fair. It is designed to penalize both contestants, when one exceeds maximum nesting level.

Let me know what you think of the rules. I could run a tournament on Dec 28, if we get qualifying contestants by Dec 27.

Link to comment
Share on other sites

  • 0

how about:

+5 if your enemy hits a bomb (other program gets +0)

+3 if you override the other program (other gets +0)

+1 if the game is still going after 2000 rounds (both get +1)

* rematch or cancel game if someone overloads the pointer count

then we could total up each program's points and divide by the number of rounds that program played - so if one round ended in a pointer overflow, it doesn't factor into the average

Edited by unreality
Link to comment
Share on other sites

  • 0

My reasoning for the scoring system is as following:

Leaving the infinite loop (nesting level exceeded) situation aside, I made it a zero-sum scoring system. That is total number of points for each game is 4. Whatever points one contestant is loosing, the other is gaining, and their total for the game always adds up to 4. Giving 5:0 and 3:0 score for bombing and overriding respectively implies that bombing is a "better" win, but being bombed and being overriden is the same kind of loss. It could make sense, so we should think about it some more. However, bombing should be a priority win criteria. E.g., if your program after overriding the opponent ended up in a situation with two uncooperative copies of self and the pointer of the "overrider" hit a bomb -- that should be a loss by bombing, not a win by overriding. Overriding should only be counted when the two copies ended up in an infinite harmless cycle. Which is a kind of draw. Yet, here is my reason for making it a win:

I observed how a hopper program landed inside Fish3's body, whereupon Fish3 detected and repaired the node, which resulted in both pointers running inside Fish3's body and bombing the outside field forever.

Now about the nesting level violation. We have a good reason here for penalizing both programs. On one hand the program, which has lots of conditions, which include testing arguments at other nodes gets an advantage. Disregarding situations where such testing leads to an infinite regression, or excessive testing makes it easier to code. One could develop a program with too much recursive testing, which is more likely to bomb the opponent in the initial stages, or go into an infinite regress. Discarding and allowing to replay such a match, helps the offender to make a number of tries until the two programs are positioned in such a way that it wins. On the other hand, it is simple enough to write arguments that would cause your opponent go into an infinite regress, should they happen to test them. Also, I'm sticking with my previous idea of picking a random location, running the match, then swapping the programs and run another match using the same location. (That eliminates some element of luck.) Discarding matches if a program goes into an infinite loop would interfere with such swapping system. So, I think, both programs should be penalized, if one violates nesting level. NO REPLAYS!

Also, I am introducing another rule here. NO BOMBING ON THE FIRST INSTRUCTION! We don't want to give an easy win to the program, which finds first non-zero node within some 50 nodes outside itself and throws a bomb there.

Link to comment
Share on other sites

  • 0

it seems like you've discovered the Megastructure then:

equ(a(40),0,equ(a(41),0,equ(a(42),0,equ(a(43),0,equ(a(44),0,equ(a(45),0,equ(a(46),0,equ(a(47),0,equ(a(48),0,equ(a(49),0,equ(a(50),0,equ(a(51),0,equ(a(52),0,equ(a(53),0,equ(a(54),0,equ(a(55),0,equ(a(56),0,equ(a(57),0,equ(a(58),0,equ(a(59),0,equ(a(60),0,equ(a(61),0,equ(a(62),0,equ(a(63),0,equ(a(64),0,equ(a(65),0,equ(a(66),0,equ(a(67),0,equ(a(68),0,equ(a(69),0,equ(a(70),0,equ(a(71),0,equ(a(72),0,equ(a(73),0,equ(a(74),0,equ(a(75),0,equ(a(76),0,equ(a(77),0,equ(a(78),0,equ(a(79),0,equ(a(80),0,equ(a(81),0,equ(a(82),0,equ(a(83),0,equ(a(84),0,equ(a(85),0,equ(a(86),0,equ(a(87),0,equ(a(88),0,equ(a(89),0,equ(a(90),0,equ(a(91),0,equ(a(92),0,equ(a(93),0,equ(a(94),0,equ(a(95),0,equ(a(96),0,equ(a(97),0,equ(a(98),0,equ(a(99),0,equ(a(100),0,equ(a(101),0,equ(a(102),0,equ(a(103),0,equ(a(104),0,equ(a(105),0,equ(a(106),0,equ(a(107),0,equ(a(108),0,equ(a(109),0,equ(a(110),0,equ(a(111),0,equ(a(112),0,equ(a(113),0,equ(a(114),0,equ(a(115),0,equ(a(116),0,equ(a(117),0,equ(a(118),0,equ(a(119),0,equ(a(120),0,equ(a(121),0,equ(a(122),0,equ(a(123),0,equ(a(124),0,equ(a(125),0,equ(a(126),0,equ(a(127),0,equ(a(128),0,equ(a(129),0,equ(a(130),0,equ(a(131),0,equ(a(132),0,equ(a(133),0,equ(a(134),0,equ(a(135),0,equ(a(136),0,equ(a(137),0,equ(a(138),0,equ(a(139),0,equ(a(140),0,equ(a(141),0,equ(a(142),0,equ(a(143),0,equ(a(144),0,equ(a(145),0,equ(a(146),0,equ(a(147),0,equ(a(148),0,equ(a(149),0,equ(a(150),0,equ(a(151),0,equ(a(152),0,equ(a(153),0,equ(a(154),0,equ(a(155),0,equ(a(156),0,equ(a(157),0,equ(a(158),0,equ(a(159),0,equ(a(160),0,80,156),155),154),153),152),151),150),149),148),147),146),145),144),143),142),141),140),139),138),137),136),135),134),133),132),131),130),129),128),127),126),125),124),123),122),121),120),119),118),117),116),115),114),113),112),111),110),109),108),107),106),105),104),103),102),101),100),99),98),97),96),95),94),93),92),91),90),89),88),87),86),85),84),83),82),81),80),79),78),77),76),75),74),73),72),71),70),69),68),67),66),65),64),63),62),61),60),59),58),57),56),55),54),53),52),51),50),49),48),47),46),45),44),43),42),41),40),39),38),37),36)

fortunately, nobody will ever use this, so we're okay :P This just checks a-params, it would be at least three times as long if it checks b and c params too. Although the task is exponentially easier with nzero(), it still fits into the megastructure category, which I unofficially outlawed in the VNA 2.0 topic after posting an example of a megastructure.

No offense, but I'm not going to join this tournament if you're going to be adding new rules and stuff. The rule is unnecessary. If someone was really going to use a megastructure or similar thing (which actually isn't as effective against something like a Hopper or really anything that nests the actual program with a big prefix or suffix of bombs with non-zero parameters to throw off Hunters), anyway, the second round would almost be just as effective.

Also, my program does bomb on the first round, it's essential to its structure. But the bomb is made specifically to cover up its jump command that sends it to the actual program so that any program following behind won't land on it.

So, let every program bomb on the first round. Many programs need that, others don't. A better way is just to screen for megastructures, and if someone submits one then chuckle - because they're not as effective as you might think. The chance of infinite regress is higher, as you said, but Hunters in general are ineffective because the better programs now shroud themselves in a shell of nonzero-parameter bombs anyway.

Link to comment
Share on other sites

  • 0

"Megastructure" which checks all 120 nodes for the opponent's starting location is almost guaranteed to win when it has the first move. Regardless, of filler bombs with non-zero arguments, every pointer starts at its first location. To avoid the hit, the oponnent program would have to start with a command with all 3 arguments 0. (Like BLANK 0;0;0, and hit the bomb as soon as it reaches the node where its first meaningful command used to be.) The imposed nesting limit does not allow checking all 120 locations. But testing a number of locations and bombing the first non-zero one could give a serious advantage on the first move.

Also, I must remind, there is nzero(n) function, which checks all 3 arguments at the node n. Feel free to use it. (And it would be more convenient to use in a megastructure like the one in the above post.)

So, we can allow bombing on the first move.

The other rules, I stand by:

1). Maximum nesting level -- 100. Or should we make it smaller?

2). Any program exceeds nesting level -- both programs lose that match.

3). A program must pass qualifying test to enter the tournament. It should be able to run unopposed for some number of rounds. I think 200(?).

I take it upon myself to be able to run a contest in my emulator between all qualifying entries. Normally, it takes less than a minute for each match.

So, qualifying round on Dec. 25? Anyone is going to be ready by then?

Edited by Prime
Link to comment
Share on other sites

  • 0

probably :) And thanks for retracting the no-bomb rule, my program needs that. Max nesting level of say 50?

Also, I'm adding the following function to my emulator:

nzero(n,a,b) = if all three parameters on line n are zero, returns a. Otherwise, returns b

if just 'n' is given, I'll assume they mean nzero(n,0,1) and fill it in for them, but given the second two input values, it removes the almost-necessity of using an equ with the nzero to match the 0 or 1 to another value.

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