1. 2nd Contest ... Purpose, get people using RC2

4.0.0 RC has been released, it's time for another mini-contest! I want to be right up front, however, that 4.0 use is not required. You can enter the contest using 3.x.

This contest will be a bit more involved but still pretty easy. This time, however, scoring will be a little bit different. 100 possible points for all test cases working. 20% bonus if you are in the top 20% for token count and a 20% bonus if you are in the top 20% for execution speed. A 20 point bonus will be given to anyone using a new 4.0 construct. A 20 point bonus will be given to anyone using a new 4.0 standard library routine. Total possible points without bonus = 100. Total possible with bonuses awarded to everyone = 140. Total possible points with all bonuses 202.

Now, on with the contest definition.

A certain computer has ten registers. Each register and RAM location holds an integer value. Instructions are encoded as three-digit integers with the exception of the print instructions. The encoding is as follows:

100 halt
2dn set register d to n
3dn add n to register d
4dn multiply register d by n
5ds set register d to the value of register s
6ds add the value of register s to register d
7ds multiply register d by the value of register s
8da set register d to the value in RAM whose address is in register a
9sa set the value in RAM whose address is in register a to that of register s
0ds goto the location in register d unless register s contains 0
?d print the value of register d with a trailing newline
??d print the value of register d with a trailing space

All registers initially contain 000. All ram addresses initially contain 0 except for ram address 0 which should contain -1 making it easy to provide looping structures. Anything after the 3 digit instruction is a comment.

An example program:

$ cat > prog1.txt 
215 Set register 1 to 5 
225 Set register 2 to 5 
612 Added register 2 to register 1 
?1  Print the value of register 1 
?2  Print the value of register 2 
100 Halt 
$ eui cpu.ex prog1.txt 
10 
5 

Let's do this a bit differently. Please state here on this message if you are going to participate. That will make things more interesting. As with the last contest, the contest can be discussed here but code and algorithms should not be discussed in any detail.

Deadline is 1 week, i.e. 7PM EST December 15th 2010. Please do not send me submissions before Monday. I would like to work on my own solution w/o being influenced. Mine will not count, but would like to have fun too smile After Monday, please send submissions to jeremy A.T. cowgar dot com.

Updates

  • Ram is 1,000 bytes long, address 0 should be initialized to -1 for ease of looping structions and all other addresses should be initialized to 0. Ram should store a Euphoria integer
  • Ram, registers and goto are all 0 based index
  • There is no requirement to handle invalid instructions, registers or ram addresses, it's OK to let the program crash
  • ??d should print a trailing space

Sample test cases

Sample test cases are located on our contest SCM server at hg:contest/file/default/2010-12-15-cpu. See the .cpu and .out files. Example testing

% eui myapp.ex basics.cpu > basics.mine 
% diff basics.mine basics.out 

If your application crashes or has a different output then your CPU program is not functioning as expected.

Final Words

Submissions will be added to our hg:contest repository. To count your tokens, you may use the token_count program found there.

new topic     » topic index » view message » categorize

2. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...

Please state here on this message if you are going to participate.

I'm in.

new topic     » goto parent     » topic index » view message » categorize

3. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...

Each ... RAM location holds an integer value ...

What are the RAM restrictions for the certain computer? For example, how many bits can be stored in each RAM address - are they 30-bit Euphoria integers or some other format? What is the size of the address space we can work with?

new topic     » goto parent     » topic index » view message » categorize

4. Re: 2nd Contest ... Purpose, get people using RC2

DerekParnell said...
jeremy said...

Please state here on this message if you are going to participate.

I'm in.

I edited my original and your comment as to not cause confusion. That was actually changing requirements as I added a bit more interesting things to it smile

So... to clarify, the only output from the program should come from the ? and ?? instructions. No other output is expected.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

5. Re: 2nd Contest ... Purpose, get people using RC2

I'm in.

Q: Does the goto instruction treat the program as zero or one-based?

Q: Is RAM indexed zero or one-based?

Q: What if the program doesn't have a halt at the end?

Q: What should the machine do about:

  • invalid instructions
  • invalid RAM addresses
  • invalid goto address
new topic     » goto parent     » topic index » view message » categorize

6. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

Q: Does the goto instruction treat the program as zero or one-based?

Since ram is zero based index, 0-9 = 10 registers, single digit, goto is also zero based.

PeteE said...

Q: Is RAM indexed zero or one-based?

Zero based index, 0-9 = 10 registers total

PeteE said...

Q: What if the program doesn't have a halt at the end?

It should terminate when it has no more instructions to process. Halt is really for stopping mid program.

PeteE said...

Q: What should the machine do about:

  • invalid instructions
  • invalid RAM locations
  • invalid goto locations

This is not defined, but it should cease execution of the the program in some manner. I use error:crash().

All good questions Pete, thanks for asking and seeking clarification for all.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

7. Re: 2nd Contest ... Purpose, get people using RC2

I'm in.

new topic     » goto parent     » topic index » view message » categorize

8. Re: 2nd Contest ... Purpose, get people using RC2

DerekParnell said...
jeremy said...

Each ... RAM location holds an integer value ...

What are the RAM restrictions for the certain computer? For example, how many bits can be stored in each RAM address - are they 30-bit Euphoria integers or some other format? What is the size of the address space we can work with?

I've left out that vital part and confused the issue when answering Pete.

There should be 1,000 ram addresses that can store an integer value type. Ram may be created in euphoria as:

sequence ram = repeat(0, 1_000) 

Instructions 8 and 9 read/write to these ram locations.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

9. Re: 2nd Contest ... Purpose, get people using RC2

DerekParnell said...
jeremy said...

Each ... RAM location holds an integer value ...

What are the RAM restrictions for the certain computer? For example, how many bits can be stored in each RAM address - are they 30-bit Euphoria integers or some other format? What is the size of the address space we can work with?

Also, my reading of your spec is that REGISTERS and RAM are two independently addressable locations. That is, there are ten registers, numbered 0 - 9, each capable of holding a Euphoria integer. There are also an unknown number of RAM locations that are each capable of hold a Euphoria integer, and these are numbered (addressed) 0 - ????.

About the competition, can we put in more than one entry? For example, I might want to submit one that has a low token count and another that has a high functionality count (pretty .LST output, assemble to 'machine code' file, syntax analysis, improved runtime error messages, etc ...).

new topic     » goto parent     » topic index » view message » categorize

10. Re: 2nd Contest ... Purpose, get people using RC2

DerekParnell said...

About the competition, can we put in more than one entry? For example, I might want to submit one that has a low token count and another that has a high functionality count (pretty .LST output, assemble to 'machine code' file, syntax analysis, improved runtime error messages, etc ...).

Yes, that's a good idea. Please number your submissions.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

11. Re: 2nd Contest ... Purpose, get people using RC2

UPDATE: Ram address 0 should be initialized in Euphoria to -1. This will enable much easier looping structures and the ability to subtract.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

12. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...

4.0.0 RC has been released, it's time for another mini-contest! I want to be right up front, however, that 4.0 use is not required. You can enter the contest using 3.x.

I'm in.

jeremy said...

20% bonus if you are in the top 20% for execution speed.

Interpreted? Translated? Bound? Average of all?

Matt

new topic     » goto parent     » topic index » view message » categorize

13. Re: 2nd Contest ... Purpose, get people using RC2

mattlewis said...
jeremy said...

20% bonus if you are in the top 20% for execution speed.

Interpreted? Translated? Bound? Average of all?

To factor our Euphoria's time of parsing, I was thinking I would do it either translated or bound but am up for suggestions.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

14. Re: 2nd Contest ... Purpose, get people using RC2

Hi

This does get you thinking doesn't it.

Will there be a standard test program? Can we run it before submitting? Is there any point in going up against Derek and Matt?

Next stop VirtualBoxEU!

Chris

new topic     » goto parent     » topic index » view message » categorize

15. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...
mattlewis said...
jeremy said...

20% bonus if you are in the top 20% for execution speed.

Interpreted? Translated? Bound? Average of all?

To factor our Euphoria's time of parsing, I was thinking I would do it either translated or bound but am up for suggestions.

I think they all provide interesting metrics, though perhaps just bound and translated.

Matt

new topic     » goto parent     » topic index » view message » categorize

16. Re: 2nd Contest ... Purpose, get people using RC2

ChrisB said...

Will there be a standard test program? Can we run it before submitting?

I'm not yet organized enough to have that, sorry. I am writing some sample programs as I go getlost The loop and fibonacii in the examples thread, message:113871 will certainly be used.

ChrisB said...

Is there any point in going up against Derek and Matt?

Against Matt and Derek? Sure! Pete had a best score for line size last time. Matt's was huge compared to Pete's. It did a little more, but...

It's all for fun and for using 4.0. It's great seeing how different people solve the same problem in the same language. I hope more people decide to enter. It really is quite a bit of fun!

Jeremy

new topic     » goto parent     » topic index » view message » categorize

17. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...

UPDATE: Ram address 0 should be initialized in Euphoria to -1. This will enable much easier looping structures and the ability to subtract.

Whew. That does make things easier, and negative numbers possible. While we're changing things, could we specify ??d to print the register followed by a space? Thanks.

P.S. I'm having more fun writing test programs than the contest entry itself.

new topic     » goto parent     » topic index » view message » categorize

18. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...
jeremy said...

UPDATE: Ram address 0 should be initialized in Euphoria to -1. This will enable much easier looping structures and the ability to subtract.

Whew. That does make things easier, and negative numbers possible. While we're changing things, could we specify ??d to print the register followed by a space? Thanks.

P.S. I'm having more fun writing test programs than the contest entry itself.

Sure, I talked with a few others who are in the contest and they agree. I've updated the original post.

Let's do this. If you have any desired changes to the spec, please get them in before 5PM EST today. If multiple people want the change then I'll amend the rules. After 5PM EST let's cut off changes to the spec.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

19. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

P.S. I'm having more fun writing test programs than the contest entry itself.

If you are, do you have any long running ones that would be a good benchmark? i.e. uses most (if not all) instructions and takes a while to complete?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

20. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...
PeteE said...

P.S. I'm having more fun writing test programs than the contest entry itself.

If you are, do you have any long running ones that would be a good benchmark? i.e. uses most (if not all) instructions and takes a while to complete?

I'm waiting for someone to post a Game of Life implementation.

Matt

new topic     » goto parent     » topic index » view message » categorize

21. Re: 2nd Contest ... Purpose, get people using RC2

Hi

I'm in BTW

4dn multiply d by n

and do what with the result?

new topic     » goto parent     » topic index » view message » categorize

22. Re: 2nd Contest ... Purpose, get people using RC2

ChrisB said...

Hi

I'm in BTW

4dn multiply d by n

and do what with the result?

It's like: d *= n

Matt

new topic     » goto parent     » topic index » view message » categorize

23. Re: 2nd Contest ... Purpose, get people using RC2

Are blank lines allowed?

In one of my test programs it became easier to calculate goto addresses if the destination address is the product of two numbers 1..9. This required putting blank lines in the program to make the destination instruction appear at the desired address. But is a blank line valid input? If not, I can easily insert a no-operation into the code (such as "200 r0=r0" or "300 r0+=0".)

new topic     » goto parent     » topic index » view message » categorize

24. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

Are blank lines allowed?

In one of my test programs it became easier to calculate goto addresses if the destination address is the product of two numbers 1..9. This required putting blank lines in the program to make the destination instruction appear at the desired address. But is a blank line valid input? If not, I can easily insert a no-operation into the code (such as "200 r0=r0" or "300 r0+=0".)

I'm writing a little assembler whose output is cpu programs. The assembler source can have labels!.

new topic     » goto parent     » topic index » view message » categorize

25. Re: 2nd Contest ... Purpose, get people using RC2

mattlewis said...
ChrisB said...

Hi

I'm in BTW

4dn multiply d by n

and do what with the result?

It's like: d *= n

Matt

Hmm, I think it should be:

4dn multiply register d by n
new topic     » goto parent     » topic index » view message » categorize

26. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

Hmm, I think it should be:

4dn multiply register d by n

Ok, fixed it now.

new topic     » goto parent     » topic index » view message » categorize

27. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

Are blank lines allowed?

In one of my test programs it became easier to calculate goto addresses if the destination address is the product of two numbers 1..9. This required putting blank lines in the program to make the destination instruction appear at the desired address. But is a blank line valid input? If not, I can easily insert a no-operation into the code (such as "200 r0=r0" or "300 r0+=0".)

I'd say no at this point because it wasn't in the spec as what to do with a blank line and there is already quite a bit of code written for this contest, changing the requirements now would be unfair. Sorry.

As we do more contests and learn more about it, we should alter our methods. For example, posting the spec then allowing 1 day (of the contest period) for comments, suggestions, clarifications, etc... of the spec. Those who start programming before the comment time is over have taken the risk they may have to modify the code they've already written.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

28. Re: 2nd Contest ... Purpose, get people using RC2

PeteE said...

Are blank lines allowed?

I regard blank lines as 'comments' and just ignore them, as if they weren't there.

new topic     » goto parent     » topic index » view message » categorize

29. Re: 2nd Contest ... Purpose, get people using RC2

CLARIFICATION

Ram address 1 - 999 should be initialized to zero. Ram address 0 should be initialized to -1 which provides an easy way of creating looping structures.

The original spec has been modified to reflect this clarification.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

30. Re: 2nd Contest ... Purpose, get people using RC2

I'm in too

new topic     » goto parent     » topic index » view message » categorize

31. Re: 2nd Contest ... Purpose, get people using RC2

I've delayed too long and didn't finish my submission so mine will be again for example again, but for good measure, here is the checksum of one of my submissions (the one I like the most):

{2986893504,2470845369,1935038652,3654172199} 

Jeremy

new topic     » goto parent     » topic index » view message » categorize

32. Re: 2nd Contest ... Purpose, get people using RC2

emailed entry

new topic     » goto parent     » topic index » view message » categorize

33. Re: 2nd Contest ... Purpose, get people using RC2

I just emailed an entry as well.

new topic     » goto parent     » topic index » view message » categorize

34. Re: 2nd Contest ... Purpose, get people using RC2

Just to be clear, the actual deadline is not until Wednesday Dec 15 at 7PM EST. Some have said late submission. It's not late yet smile

Jeremy

new topic     » goto parent     » topic index » view message » categorize

35. Re: 2nd Contest ... Purpose, get people using RC2

jeremy said...

Just to be clear, the actual deadline is not until Wednesday Dec 15 at 7PM EST. Some have said late submission. It's not late yet smile

Jeremy

Can we bump this to Dec 22?

new topic     » goto parent     » topic index » view message » categorize

36. Re: 2nd Contest ... Purpose, get people using RC2

jimcbrown said...
jeremy said...

Just to be clear, the actual deadline is not until Wednesday Dec 15 at 7PM EST. Some have said late submission. It's not late yet smile

Jeremy

Can we bump this to Dec 22?

I'd say nop

Chris

(That was meant to be no, but that was some sort of fortuitous slip)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu