1. 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 08, 2010
- 3002 views
- Last edited Dec 11, 2010
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 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.
2. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 08, 2010
- 2854 views
Please state here on this message if you are going to participate.
I'm in.
3. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 08, 2010
- 2872 views
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?
4. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 08, 2010
- 2833 views
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
So... to clarify, the only output from the program should come from the ? and ?? instructions. No other output is expected.
Jeremy
5. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by PeteE Dec 08, 2010
- 2849 views
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
6. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 08, 2010
- 2806 views
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.
Q: Is RAM indexed zero or one-based?
Zero based index, 0-9 = 10 registers total
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.
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
7. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jimcbrown (admin) Dec 08, 2010
- 2814 views
I'm in.
8. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 08, 2010
- 2817 views
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
9. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 08, 2010
- 2825 views
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 ...).
10. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 08, 2010
- 2807 views
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
11. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2783 views
UPDATE: Ram address 0 should be initialized in Euphoria to -1. This will enable much easier looping structures and the ability to subtract.
Jeremy
12. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by mattlewis (admin) Dec 09, 2010
- 2753 views
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.
20% bonus if you are in the top 20% for execution speed.
Interpreted? Translated? Bound? Average of all?
Matt
13. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2704 views
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
14. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by ChrisB (moderator) Dec 09, 2010
- 2692 views
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
15. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by mattlewis (admin) Dec 09, 2010
- 2674 views
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
16. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2708 views
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 The loop and fibonacii in the examples thread, message:113871 will certainly be used.
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
17. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by PeteE Dec 09, 2010
- 2681 views
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.
18. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2674 views
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
19. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2654 views
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
20. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by mattlewis (admin) Dec 09, 2010
- 2683 views
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
21. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by ChrisB (moderator) Dec 09, 2010
- 2683 views
Hi
I'm in BTW
4dn multiply d by n
and do what with the result?
22. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by mattlewis (admin) Dec 09, 2010
- 2650 views
Hi
I'm in BTW
4dn multiply d by n
and do what with the result?
It's like: d *= n
Matt
23. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by PeteE Dec 09, 2010
- 2592 views
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".)
24. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 09, 2010
- 2578 views
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!.
25. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by PeteE Dec 09, 2010
- 2587 views
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 |
26. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 09, 2010
- 2580 views
Hmm, I think it should be:
4dn | multiply register d by n |
Ok, fixed it now.
27. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 09, 2010
- 2562 views
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
28. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by DerekParnell (admin) Dec 09, 2010
- 2595 views
Are blank lines allowed?
I regard blank lines as 'comments' and just ignore them, as if they weren't there.
29. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 11, 2010
- 2472 views
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
30. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by heber Dec 11, 2010
- 2434 views
I'm in too
31. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 14, 2010
- 2353 views
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
32. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by ne1uno Dec 14, 2010
- 2384 views
emailed entry
33. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by petelomax Dec 14, 2010
- 2249 views
I just emailed an entry as well.
34. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jeremy (admin) Dec 14, 2010
- 2243 views
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
Jeremy
35. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by jimcbrown (admin) Dec 14, 2010
- 2274 views
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
Jeremy
Can we bump this to Dec 22?
36. Re: 2nd Contest ... Purpose, get people using RC2
- Posted by ChrisB (moderator) Dec 15, 2010
- 2286 views
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
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)