Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / The DB Classic Programming Challenge Thread

Author
Message
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Sep 2008 00:22


Enjoy your day.
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 24th Sep 2008 01:36
Nice Ashingda!

*Ignores Masterful Latch*


I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 02:48
LOL thanks, yeah Latch you rock. Anyone know how to fill an irregular shape like a star?
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Sep 2008 02:54
A quicker way to make a filled circle would be to use this code:




"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 03:04 Edited at: 24th Sep 2008 03:12
That doesn't fill in the whole circle. By the way your t and y variables are swaped or is it supose to be that way.

Just a thought, how does the paint program or other drawing program do the fill color tool? I can't figure out how to do it.
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Sep 2008 03:19 Edited at: 24th Sep 2008 03:19
Quote: "That doesn't fill in the whole circle."

That's because I accidentally typed it in wrong without testing it. Now, it works. I just mixed up the positions of the variables.




"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 03:33 Edited at: 24th Sep 2008 03:35
That works greate on small circles but it doesn't completely fill large ones.

Danget, I know BN2 knows a bit about Filling areas!
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 24th Sep 2008 03:43
I experimented with yours Ashingda, and Interestingly enough, It turns out yours doesn't fill in the circle either:




I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 03:52 Edited at: 24th Sep 2008 04:03
Thats good find Irojo, that's why we need to figure out how to do a color fill!!

BN2 if you read this please explain about your floodfill function. Or I can just look at it for hours and maybe I'd click.


Wow I did just that and I'm begining to understand, I can't believe you call the same function within that very function multipule times!! I'm going to try use your function on pixels.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Sep 2008 04:29
@remarks

A forum member named SvenB came up with a super fast filled circle function. It uses BOX to fill the area quickly -



Enjoy your day.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 04:53
That is DAMN FAST!!
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Sep 2008 04:56
Wow!! That's a good function.


"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 05:05 Edited at: 24th Sep 2008 05:18
You know what, this is bull !!!! I replaced the BOX command with LINE and it's going 10x slower! What's up with this, why is LINE so slow compared to box!?


LOL I threw a BOX command into my code replacing a Line command and it went Fast! This is crazy, but the challenge was to not use BOX
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 24th Sep 2008 05:57
Bizarre potential triange?




I download memory.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 24th Sep 2008 19:04
Quote: "Wow I did just that and I'm begining to understand, I can't believe you call the same function within that very function multipule times!! I'm going to try use your function on pixels. "


Like I said before, I didn't think of it, I just converted it from c to darkbasic. It isn't usually a good idea to have a function call itself, but it works. It DOES take a while for it to work with pixels though, for some reason.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 20:48
Yeah I was messing around and it does work on pixels but the Point(x,y) and Dot x,y are horriblly slow! Maybe we need to use memblock with image, but that's confusing to use also. How the hell do you read bytes anyways I always get a return of zero.
NanoGamez guy
19
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th Sep 2008 22:17 Edited at: 24th Sep 2008 22:26
If you want to understand the flood fill function, look at mine. It's clearer and doesn't call itself .



The idea of the fill function is:

First create three arrays: a 2D array where the fill data is kept and two arrays for the x and y coordinates of each fill pixel. Start at a particular point (as specified in the function parameters). Then look left right up and below the pixel to see if that is the right pixel to fill with (i.e. the same value/colour as the start pixel) and that hasn't already been filled. If it is, add it to the fill arrays.

Next you'll need to keep going through each filled pixel (by using the the two arrays for the x and y coordinates of each fill pixel) and check left right up and below until you cannot find any more pixels of the right value/colour or you have filled the entire area. Then just transfer the 2D fill array to the original array, and you're done

This code can be optimised (for example, using a stack array), but that's the basic idea.

Quote: "You know what, this is bull !!!! I replaced the BOX command with LINE and it's going 10x slower! What's up with this, why is LINE so slow compared to box!?"


That is probably because the DBC line uses cos and sin (I think) which wouldn't be as fast as two for loops (as used to make the box).

[EDIT]
Quote: "Maybe we need to use memblock with image, but that's confusing to use also."


You can't use memblocks in this challenge because you can only get them if you have the enhancement pack, and, as stated in the challenge rules, challenge entries must not contain command only available with the enhancement pack


"To succeed is not enough, others must fail" - Gore Vidal
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Sep 2008 23:03 Edited at: 24th Sep 2008 23:56
Quote: "you can only get them if you have the enhancement pack"
Wow I didn't know that.

Nice codes Nano, it is quite fast, I can use this on my Map Maker but do you also have one that is used on pixels?

[Edit]
I modified SvenB's code to NOT use the Box command and it's running somewhat ok. Just don't increase the circle Radius too much lol. Press left and right to move the dot filled circle.



[Edit]
I must say, the Point(xy) command is extremely slow! Is there a better way to check the pixels on screen? There's gotta be a faster way right?
NanoGamez guy
19
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 25th Sep 2008 00:51
Rather than drawing shapes to the screen and then scaning in what you've just drawn to fill it, it's best to draw shapes to arrays and fill the array in, which could then be drawn to the screen with some for loops.

Quote: "I must say, the Point(xy) command is extremely slow! Is there a better way to check the pixels on screen? There's gotta be a faster way right?"


You could use a dll, which isn't allowed in these challenges anyway. Another cool way that Latch used in a challenge entry a while back was to save an image to a bitmap file and then read it back byte by byte using open to read.


"To succeed is not enough, others must fail" - Gore Vidal
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 25th Sep 2008 02:02
Quote: "Another cool way that Latch used in a challenge entry a while back was to save an image to a bitmap file and then read it back byte by byte using open to read."

You know that just might be what I was looking for, thanks for mentioning it!
jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Sep 2008 02:33
Does Classic do memblocks? I forget - something says "NO" echoing in the back of my mind - if it did/does - then I would do the drawing to the memblock - and then make an image from it. One could ALMOST do the same thing with a screen size multidimensional array and then draw like that - using a compression algorythm - like jpg does or something. this is not as bad as it sounds btw - except for the memory demands (and probably speed of a big array in db classic) but the compression would work by calculating "lines" of a specific color - then when the color changes - draw the line from your last "START" to just before the color change in that one color - and go again until you have that first horizontal line across the top - then rinse and repeat for row 2 etc...

I'm just posting this based on the last couple of posts that hit my inbox

--Jason

BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Sep 2008 03:38 Edited at: 25th Sep 2008 04:13
Quote: "Does Classic do memblocks? "


Yeah, but you can't use it in the competition.

Also, can we have the program make a file? Wouldn't that require the judge to save the file to use it? If they did then that would violate the rule saying that it must be able to be copied and pasted (wouldn't it?)

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Sep 2008 04:31
Have your program make the file that writes it and reads it automatically.

Enjoy your day.
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 30th Sep 2008 17:45
Here's my entry...




I download memory.
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Oct 2008 02:15 Edited at: 1st Oct 2008 02:18
To clarify, "no boxes" meant that you can't enter a box as a shape because DB already has a box function so there's no point. You could still us BOX as long as you were drawing another shape.
Sorry I was a bit ambiguous with that.

The Entries

Ashingda's Circle
Well for a start it sounds like some sort of ancient Japanese secret society . The program ran well but larger circles had gaps. What was the "/abs(2)" for? I couldn't work out why abs would make the circle solid but it did!

Sinani's Circle
Not solid.

Irojo's Triangle
Very cosmic colours going on here, I liked how the triangle changed proportions.

Latch's Shapes
The circle and ellipse were drawn using the sneaky method of drawing a second circle one pixel away to cover up the gaps.
The triangle worked fine but seemed a bit ridged, I would have liked to have seen different lengths of sides. The radial shading didn't really fit the bill but it was pretty .

Nano's Fill
Something went wrong here, a couple of dots were outside the square and the square had gaps.

Results

Runner-Up:


Winner:


A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Oct 2008 02:24
@Ashingda
The problem with your function was that it only ran through the loop 360 times; that's fine for a small circle but for larger ones more accuracy is needed.
I've modified your code:


and here's a generalized one:

If you'd entered that, it would've won.

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 02:36 Edited at: 1st Oct 2008 02:48
YAY Thanks Obese!
Will set the challenge in a moment, so keep on refreshing...




Menu Maker
Challenge

Create a Menu Maker Program.




Bonuses go to:
-Making it save properly into a file.
-Maximum Options
-Ease of Use
-Creativity... But of course!


Deadline

14th OCT Midnight
--

For further clarifications:

You are supposed to make a Menu maker program. This includes buttons. The code should be a result of the program. For example, if the button x position is greater then 320, but less then 340 the final code solution would say if mousex()>320 and mousex()<340.... etc.

If this isn't a challenge possible for beginners, or not enough room for creativity, or you don't understand it, then please say so. Thanks.


I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 02:39 Edited at: 1st Oct 2008 02:41
Congrats for winning Irojo, I knew there was something still missing with my circle! LOL

Quote: "Ashingda's Circle
Well for a start it sounds like some sort of ancient Japanese secret society"

That's hilarious.
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 02:43
Thanks. Alright the challenge is made, so look 2 posts up.


I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 02:52
Can you clarify a bit more, is this like a map maker except it's for menu? What is it supose to save, the picture of the menu?
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 02:54
It is supposed to save the entire code for the menu.

So all you have to do is copy and paste it into DBC, and it will run like a menu.


I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 02:59 Edited at: 1st Oct 2008 03:00
Wait are we making functions or sub routines? if it's functions I think I just made one and posted it on the DarkNOOB project post.


I use this as entry also?
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 03:08
This was more along the lines of what I meant. Except you can put in more then one button, lable them, maybe color them, etc.



I download memory.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Oct 2008 03:10
Quote: "LOL I threw a BOX command into my code replacing a Line command and it went Fast! This is crazy, but the challenge was to not use BOX"


Whether your line is straight or diagonal, the math will still go through the process of calculating the slop of the line. Take a look at my code for bresenham's line algorithm. (i needed this to draw lines directly to memblocks) There's no sin/cos functions, but the added division and multiplication is more than you'll find in a simple nested loop for a box.


Bresenham's Line:



Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 03:26 Edited at: 1st Oct 2008 03:37
@Phaelax
Nice line that might be usefull.

@Irojo
I see what you mean now, so are we supose to save the generated codes to a seperate file?
Kinda odd to use a compiler to make a programs that generate codes for it.

[edit]
Honestly as I'm trying to think of ways to write this I feel this challenge is impractical, but I'll give it my best shot anyways.
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 03:57
Would a competition for a game with only lines only work?

You could only use line to draw onto the screen. Text and print would be aloud, but only for instructions. Get image and sprite etc. would also be allowed. Do you like that more?


And saving the generated codes to a seperate file would be an option.


I download memory.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 04:06 Edited at: 1st Oct 2008 04:06
The challenge has already been declared, maybe we should just stick to it til it ends, the idea of switching it midway might promote unstableness in this thread. It doesn't matter if we like it or not I belive.
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 04:12
Okay.


I download memory.
jason p sage
18
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st Oct 2008 04:44
All Hail DB Classic Challenge Thread Stability!
LOL - you guys are doing some cool stuff
--Jason

Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Oct 2008 06:17
Ok I'm done this is my entry, I use a grip load of function but the end results are quite simple. Bahhh saving part was hell!



This saves to a file call Codes.txt
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 06:38 Edited at: 1st Oct 2008 06:40
That's Impressive!!!

Great Entry.


That's exactly what I meant.


I download memory.
NanoGamez guy
19
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 1st Oct 2008 09:22 Edited at: 1st Oct 2008 09:24
@Obese
The flood fill wasn't an entry! I was just explaining how it would work. By the way, I added the dots in myself, because a filled box on it's own didn't really look as impressive (although it didn't really show what I wanted it to show)

@Irojo
Congrats on winning! Nice Challenge!


"To succeed is not enough, others must fail" - Gore Vidal
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 14:38
Thanks Nano!


I download memory.
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 1st Oct 2008 22:50
I think there was already a challenge for making a menu, if I am not mistaken.


"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 1st Oct 2008 23:10
There was. This is for making a program that makes menus.


I download memory.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Oct 2008 20:50
As far as the saving goes, does it have to all be included in 1 single code file? I was thinking about saving some images for it and some arrays, or is that illegal (all images would be generated by the program, it would just make it so that it wouldn't be necessary to re-generate them again).

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 2nd Oct 2008 22:10
It doesn't have to be included in one single code file.

The images and arrays are allowed.

Easy access for the file would probably gain more points however.


I download memory.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Oct 2008 22:19
What about a program that doesn't necessarily create the menus, but builds the menus from a script? Like if I provided the scheme for an XML doc and the program built the menus from that?


Irojo
18
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 3rd Oct 2008 01:11
I'm not quite following that. Explain please.


I download memory.
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 3rd Oct 2008 06:02
Yeah, I don't really get it, either.


"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2

Login to post a reply

Server time is: 2026-06-07 19:11:59
Your offset time is: 2026-06-07 19:11:59