Best "Anything" in 20 Lines (Choose Your Language)
Author |
Message |
Artimes
|
Posted: Thu Sep 28, 2006 10:17 pm Post subject: (No subject) |
|
|
Well seeing as I don't expect mine to win over the 3D renderer... I'll post mine for kicks. Click and hold the mouse, watch the balls accelerate towards the pointer!!
Velocty 19
code: | View.Set ("graphics:500;500,offscreenonly,nobuttonbar")
var x, y, vx, vy : array 1 .. 15 of real := init (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
var mx, my, mb : int
loop
Mouse.Where (mx, my, mb)
Draw.FillBox (0, 0, maxx, maxy, 7)
for i : 1 .. 15
if (mb = 1) then
vx (i) += (mx - x (i)) / abs (mx - x (i)) * (16 - i) * 0.005
vy (i) += (my - y (i)) / abs (my - y (i)) * (16 - i) * 0.005
end if
x (i) += vx (i)
y (i) += vy (i)
Draw.FillOval (round (x (i)), round (y (i)), (i + 5) div 2, (i + 5) div 2, i + 60)
end for
Time.Delay (10)
View.Update
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
BenLi
|
Posted: Fri Sep 29, 2006 7:58 am Post subject: (No subject) |
|
|
two lines worth adding to this program
code: |
assert abs (mx - x (i)) * (16 - i) * 0.005 not= 0
assert abs (my - y (i)) * (16 - i) * 0.005 not= 0
|
|
|
|
|
|
|
md
|
Posted: Fri Sep 29, 2006 10:33 am Post subject: (No subject) |
|
|
BenLi wrote: two lines worth adding to this program
code: |
assert abs (mx - x (i)) * (16 - i) * 0.005 not= 0
assert abs (my - y (i)) * (16 - i) * 0.005 not= 0
|
You are assuming Turing follows bedmas... it might just do in-order evaluation. If it does follow bedmas it'd be better to add those conditions as if statements... were it C++ you could do
c++: | vx[i] += abs(mx - x[i]) * (16 - i) != 0 ? (mx - x[i]) / abs(mx - x[i]) * (16 - i) * 0.005 : 0 |
Oh, and proper formating of code is nice... func() as opposed to func () |
|
|
|
|
|
ZeroPaladn
|
Posted: Fri Sep 29, 2006 11:45 am Post subject: (No subject) |
|
|
That is amazing Cornflake! Yours is interactive, so it could stand a chance at beating Zylum's 3D Rendering program. (a very slight chance, but a chance nontheless)
+20 bits to Cornflake |
|
|
|
|
|
[Gandalf]
|
Posted: Fri Sep 29, 2006 3:30 pm Post subject: (No subject) |
|
|
Cornflake wrote: Oh, and proper formating of code is nice... func() as opposed to func ()
Turing convention is func (). |
|
|
|
|
|
Silent Avenger
|
Posted: Fri Sep 29, 2006 10:16 pm Post subject: (No subject) |
|
|
Hey Freakman, just out of curiosity how many enteries do you have now for this contest? |
|
|
|
|
|
md
|
Posted: Fri Sep 29, 2006 11:36 pm Post subject: (No subject) |
|
|
ZeroPaladn wrote: That is amazing Cornflake! Yours is interactive, so it could stand a chance at beating Zylum's 3D Rendering program. (a very slight chance, but a chance nontheless)
+20 bits to Cornflake
Wha? |
|
|
|
|
|
md
|
Posted: Sun Oct 01, 2006 6:55 pm Post subject: (No subject) |
|
|
System performance measure, really not very useful at all
My workstation: 30864197.5308642JHz
My server: 8646031.471554557JHz
** Note, standard SI rules apply, so my workstation is really 30.8MJHz
jibahertz.cpp
c++: | #include <ctime>
#include <iostream>
#include <pthread.h>
void* RunJiba(void*) {
int i, i_op; double f_op;
for( i = 0; i < 500000000U; i++) { // one jiba
f_op = (f_op + 0x16680339) / 0x29979245;
i_op = (i_op + 0x31415926) / 0x27182818; }
}
int main(int argc, char **argv) {
std::clock_t tstart, tend;
int ret; pthread_t thread1, thread2;
tstart = clock();
ret = pthread_create(&thread1, NULL, RunJiba, NULL) + pthread_create(&thread2, NULL, RunJiba, NULL);
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
tend = clock();
double jibahertz = 1000000000U / (((tend-tstart) * 1.0) / CLOCKS_PER_SEC);
std::cout.precision(16); std::cout << jibahertz << "JHz" << std::endl;
}
|
compile and run with code: | g++ jibahertz.cpp -lpthread -o jbhz && ./jbhz |
[edit] changed the code to a pthreaded version... it should make things more accurate for dual-core/hyperthreading machines. At least in that it should use both cores atthe same time... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Sun Oct 01, 2006 7:00 pm Post subject: (No subject) |
|
|
The Jibahertz name is © 2006 [Gandalf] though.
My normal Jibahertz: 33967392
My uber computer Jibahertz: 76219512
Anyway, my vote is an even split between my flying circles and md's amazing creation.
*edit* Phew... Updated! |
|
|
|
|
|
apomb
|
Posted: Mon Oct 02, 2006 7:31 am Post subject: (No subject) |
|
|
54MJhz here ... seems this test runs well on Athlon64s cool little deal cornflake, i cant get it to run in VC++ here at school though. pthreads not included in the libraries i guess |
|
|
|
|
|
md
|
Posted: Mon Oct 02, 2006 12:52 pm Post subject: (No subject) |
|
|
you'd need to get teh win32 pthread library manually. Windows implements it's own threading API; and it's much more complex, no way it'd fit in 20 lines. |
|
|
|
|
|
Clayton
|
Posted: Sat Oct 07, 2006 4:47 pm Post subject: (No subject) |
|
|
One week left guys, get those submissions in!
(Could a mod lock this afterwards, as im going to be away on the 13th and wont be back till the 17th) |
|
|
|
|
|
apomb
|
Posted: Sat Oct 07, 2006 6:43 pm Post subject: (No subject) |
|
|
68HC11: | ORG $1
MYSTRING FCC 'HI HOW ARE YOU DOING?'
L EQU *-MYSTRING-1
SWAP RMB 1
LOOP1 LDX #MYSTRING
LDY #L
CLR SWAP
LOOP2 LDD 0,X
CBA
BLS R1
STAB 0,X
STAA 1,X
INC SWAP
R1 INX
DEY
BNE LOOP2
LDAA SWAP
BNE LOOP1
BRA * |
yeah, i know its not all graphics oriented, but it does sort the array for you ... IN MEMORY |
|
|
|
|
|
md
|
Posted: Sat Oct 07, 2006 7:17 pm Post subject: (No subject) |
|
|
If we're going to do assembly we might as well jsut go all the way to Corewars |
|
|
|
|
|
Clayton
|
Posted: Wed Oct 11, 2006 6:46 pm Post subject: (No subject) |
|
|
Two days left guys, Get those submissions in, contest closes 11:59pm October 13th |
|
|
|
|
|
|
|