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
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 8th Dec 2009 19:59
no! I love this thread... db isn't working on my computer though... Will join in again once i fix it

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Dec 2009 23:33
Yea now that DBP is free, I really so no need for anyone to use DBC anymore. Shame....., oh well!


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 9th Dec 2009 00:04
I still like dbc, and I'll probably stick with it. Broken my keyboard as well though... Having to use on screen keyoard atm. So much hassle. It got beered last night...

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Dec 2009 00:33
Why stick with DBC when DBP is free and proven superiority?


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Dec 2009 00:43
I won't be using DBPro anytime soon. The only reason I use windows ( i.e. windows 98) at all is to use DBC and there's no way I'm gonna buy a new operating system... especially windows anything, unless I absolutely have to.

Quote: "Is this thread now officially abandoned? Should it be locked?"

And why lock this thread? Let it die if that's it's destiny but why actively lock it? Time has passed without people entering challenges before.

Enjoy your day.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 9th Dec 2009 00:55
Mostly because I'm stubborn and averse to change :p

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 9th Dec 2009 01:37 Edited at: 9th Dec 2009 01:37
I could'nt get the free DBP to work on my computer, so I'll be sticking with DB until I get me a laptop.(3-5 years)

If at first you don't succeed-Pause-Go to last checkpoint.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Dec 2009 02:13
Oh wow. I feel bad. I was last one to do it :/ sorry. I'm really busy right now. if anyone would still like to take this over i would be fine with it.

New Site! Check it out \/
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 9th Dec 2009 13:44
yea im having problems with the free dbp working on my computer too so i have to stay with dbc and i probably still wouldnt want to change lol
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Dec 2009 18:53
If we get interest again, we need to keep this rolling lol

New Site! Check it out \/
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 11th Dec 2009 20:34
I was going to make a bank thingy witch tells you all the ways you can get change from a certain amount but decided not to because some of you guys use a diffrent money system.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Dec 2009 08:17
Quote: "but decided not to because some of you guys use a diffrent money system."


Don't let that kind of stuff stop you(from now on ) these challenges(as stated before) aren't for full usable programs. they are for small parts to complete programs(like a banking system used for many different games) so yours(even if it used some other currency) would have been fine! and you would have won

New Site! Check it out \/
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Dec 2009 12:52
True...

And apart from that, all money systems are the same - ie decimal.

They all have 100 Plinks in a Plonk - or whatever!

In the USA, Plinks are 100 cents to the dollar, in the UK they are 100 pence to the pound and here there are 100 centimes to the euro. I can't think of anywhere there aren't 100 of them in the currency.

So, you could leave off the currency symbol or have the user enter their own currency symbol when the program first runs.

TDK

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 12th Dec 2009 15:40
Unless you had old English pounds.
New challenge or extend this one?
I have a keyboard now and time to spare (just got back from uni yesterday) - all I need to do is figure out why DarkBASIC isn't working right and I'll be good to go...

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Dec 2009 22:21
I got stuck on mine. The idea was to have several accounts that you post transactions to, but I couldn't work out how to make it expandable. Is there a clean way you can make an expandable database without copying arrays like this...

That's a very messy method.

I was thinking about using memblocks but I'm not sure how I could allocate more memory.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Dec 2009 01:32
That's more or less how other languages manage dynamic arrays. But instead of creating 2 arrays, just make the one you need. When it's time to expand, then create a temporary array but delete it when you're done. If your first array will initially have 10 elements, determine a growth factor to allow for more room and apply it. When that limit is reached, expand the array by that amount rather than just 1. True you will have some unused memory allocated, but it reduces the amount of copying you'll need to do, thus faster.

Here's sort of an example of what I mean.


Though arraySize has been set to 10, the expansion amount allows you to fill in 5 additional elements beyond that before it'll swap memory to a larger array and repeat the process over again. The code above won't compile, but it was more of an idea to show.


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Dec 2009 02:21
exept when you dim that array again inside the arrayExpand() function, it won't be global. it will be a local array.

New Site! Check it out \/
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 13th Dec 2009 02:31
I thought that arrays were always global in DBC?

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Dec 2009 23:34
Arrays declared outside of functions are global. A array declared inside a function is a local array.

New Site! Check it out \/
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Dec 2009 00:50
Hmm, maybe it's DBP that let me dim an array inside a function. I'm pretty sure I've done it before.

Ok, just checked some old code, and yes it's possible in DBP. Pro will keep arrays global even when defined inside a function.


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Dec 2009 02:56
Oh ok i didn't know that. that's useful info thanks lol.

BUT Just to make it clear in dbc a array defined in a function is local. even if you have undimmed a global array and redimmed it inside that function,

New Site! Check it out \/
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 14th Dec 2009 20:07
Well then could you not just use a gosub instead?

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Dec 2009 20:47
Yes you could. That would probably be the best or only alternative.

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Dec 2009 10:52
Dynamic allocation is pretty much always destructive and constructive. The OS uses whatever memory areas are available so when you resize memory allocations, you end up freeing the old reference and recreating a new one of the proper size.

With memblocks, it would go something like this:



Enjoy your day.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Dec 2009 23:46
Well, I guess the bank thing is over.

How about a new one? How about Roman numerals? Enter the Roman numeral and get the Arabic numeral (0,1,2,3 etc.) equivalent. Or enter the Arabic numeral amd get the Roman numeral equivalent. The program or function should be able to translate both types to the other. The numbers should be able to be large and not just I II III IV V VI VII VIII IX X .

What say you all?

Enjoy your day.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 29th Dec 2009 04:04
I liked the phase of challenges a while back where there was more of an opportunity to expand into a more game style system. On the other hand I'm currently considering NaGaCreMo so I'll be out of comission for a while (after finally gettingDB working again - I'm never going to run out of excuses)

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Dec 2009 04:46 Edited at: 29th Dec 2009 16:54
I like the challenge. While it may not seem game-oriented, any coding skill you develop through these challenges will likely help in games somehow. I'll code my entry tonight, if I don't fall asleep first.



Ok, here's my first entry; conversion from roman to arabic:


I'm still thinking how to go about arabic to roman. It's a little trickier than I first thought.


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Dec 2009 20:40 Edited at: 30th Dec 2009 21:05
This is cool.
Here's my entry Arabic to Roman.
The different symbols are very similar, there must be a way to simplify this code. Maybe use another variable which scales up as you get to new symbols.
[edit]tidied up display and added my signature backdrop [/edit]


"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 30th Dec 2009 22:20 Edited at: 30th Dec 2009 22:40
Did this Roman to Arabic yesterday but forgot to post it

Going to expand on it more though



EDIT: Here it is with Arabic->Roman as well but it looks horrible


I'll have a think about a better way of doing it.
Also I didn't realise at first I'm going to have to change the other bit because at the moment for example IX would return 11 not 9... whoops...

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 30th Dec 2009 22:45
Good idea. It is so simple, I might be able to write the program without a compiler (I'm on a Mac, remember?).

What is the deadline for this challenge?

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Dec 2009 22:55 Edited at: 30th Dec 2009 23:00
Obese, your program can't handle numbers above 500. It looks like it'd get stuck in an infinite loop.

Demons breath, your roman to arabic is inaccurate. Remember that a lower number followed a higher number (IV) equates to the higher minus the lower (V-I). So you're outputting 6 for IV when it should be 4.

I'm still baffled on arabic to roman. I've come very close but with minor errors. Demons breath did it pretty much how I was trying to do it. I think I see where I made my mistake. I'll post after I've found a way to simplify the globs of IF statements that seems to be the current method.


> SELECT * FROM users WHERE clue > 0
> 0 rows returned
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 30th Dec 2009 23:08
Yeah I realised that when I edited 20 minutes later, but I have to get up at half 5 tomorrow for work so I don't want to start coding because I can't stop for hours if I get into it

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Dec 2009 23:25 Edited at: 31st Dec 2009 00:00
I get the same one. Once I start, I can't stop. The hard part is getting me to start.

Here's my updated code. I'm still looking for a pattern that could help me reduce the array size, but this is the simplest I've managed so far.

Version 1 of arabic to roman and roman to arabic



> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Dec 2009 23:59
Version 2 of the arabic to roman conversion. No array needed, and the majority of the code you see is actually just convenience methods due to the limited string functions DB has.




> SELECT * FROM users WHERE clue > 0
> 0 rows returned
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Dec 2009 01:35 Edited at: 31st Dec 2009 02:17
Quote: "Obese, your program can't handle numbers above 500. It looks like it'd get stuck in an infinite loop."

I haven't added all the symbols yet, so at the moment it's trying to add up to a number that doesn't exist.

I've added all the symbols but boy is this an ugly program.
I'll have to find a way to tidy it up.


I'm so glad I'm back online

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Dec 2009 02:40
I hadn't really thought about how tricky this can be without using a ton of IF THENs. That's some interesting code you guys are posting!

@Phaelax
I would have never thought of using string formatting like that to do the conversion. Clever!

@Obese87 and Demons breath
You guys came up with similar methods. I guess great minds think alike.

I tried coding this too and came up with a million IF THENs. Is there a way just to use logic and math without all of the conditional tests? I wonder if Phaelax's string manipulation method could be used as a springboard...

As far as a deadline, how about Sunday January 3, 2010 midnight GMT (Monday morning)

Anyway, good work you guys! Putting the old mellons to the test on something that seems like it should be less tricky.

Enjoy your day.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 31st Dec 2009 04:35 Edited at: 3rd Jan 2010 19:06
I finally got Boot Camp working. Now I have Windoze 7 AND Snow Leopard all in ONE MacBook Pro!

Arabic to Roman



Roman to Arabic



Both (USE THIS!!)



Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jan 2010 16:35 Edited at: 4th Jan 2010 16:39
Some interesting entries!

Demon's Breath:


Obese87


Phaelax


Sinani201


The runner up is


The winner is


Enjoy your day.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 4th Jan 2010 21:04
Bottoms - never got round to updating that mistake. Oh well.

Well played Phaelax.

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jan 2010 02:11 Edited at: 5th Jan 2010 02:12
How would I be able to calculate numbers greater than 3999? M represents the largest number, and I can't make it possible to draw a line over the number (putting a line over a Roman numeral multiplies it by 1000).

Good job, Phaelax. Looking forward to the next challenge.

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jan 2010 03:20
Quote: "How would I be able to calculate numbers greater than 3999? M represents the largest number, and I can't make it possible to draw a line over the number (putting a line over a Roman numeral multiplies it by 1000)."


It's completely acceptable to write multiple Ms - MMMMMMMMM . If you really wanted to use the lines above the letters, I suppose you could make bitmap fonts, or create 2 rows, set the font to courier - for even spaced characters - write the roman numerals on 1 row and use the roaw above to print an under score.

Enjoy your day.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jan 2010 03:25 Edited at: 5th Jan 2010 03:40
Quote: "It's completely acceptable to write multiple Ms - MMMMMMMMM ."


Really? I'm sure it would work then, just get rid of the code that checks to see if the number is too big. Currently I am in Mac mode so I cannot test it, but I will reboot into Boot Camp now.

[EDIT] I tried that and it definitely works (even for numbers that are OVER 9000!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!).

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Jan 2010 05:48 Edited at: 5th Jan 2010 06:11
The logic would be the same as any other character. Just think of V with the line over it as a whole new character.

Sweet, I won! Time to think of a new challenge, thoughts?

Here's one idea, but it might be too similar to the last challenge. Given an integer, express that number written out in words.

ex. 2,456 -> two thousand four hundred fifty six


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Jan 2010 06:50 Edited at: 5th Jan 2010 06:50
Congrats Phaelax!
Haha, look what I found http://forum.thegamecreators.com/?m=forum_view&t=111489&b=10

challenges, hmmm.... Phaelax you forgot the "and" in 2,456
that's a decent challenge, follows on from the last.

Or how about a program that lets you build things by sticking objects together?

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Jan 2010 09:17
Ahhh, the challenge was already solved by you and Latch years ago! Although, it doesn't look like it'd work 100% of the time.

Technically, you should only say "and" to represent a decimal.

Interesting idea for a challenge, I think I'll go with that one and see how creative people can get.



Challenge: Plug n' Play
Deadline: January 13

Description:
Allow the user to interact with different objects(2D or 3D) to build something. This can be as simple as stacking cubes together, like a child's alphabet blocks, or make a Mr. Potato Head! Or snap a bunch of cogs together and watch them turn.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Jan 2010 19:34
Good challenge, Phaelax! Maybe I'll be able to cook something up; January 13th looks like a good deadline.

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 5th Jan 2010 22:55 Edited at: 5th Jan 2010 22:56
[edit] Nevermind, didn't realize there was an extra page.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2010 00:20
DBChallenge.com has been brought up to date. Any opinions on including the DBP challenges into the site?


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 10th Jan 2010 18:59 Edited at: 10th Jan 2010 19:00
TDK, remember when you got into that argument with heartbone in the flashing thread? Well, his method fixed the text in my program AND the flashing. Maybe it has to do with Windoze 7.

I'm working on something where basically you draw circles, and circles have gravitational pulls to each other, and objects with greater mass attract more objects. There are also black holes, which basically kill everything at infinite speeds unless there is another black hole, in which case whichever circle is closest will get sucked in.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Jan 2010 16:20
lol, i just scrolled through the thread to see what the new challenge was..... (i think i need more sleep)


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke

Login to post a reply

Server time is: 2024-04-20 00:12:15
Your offset time is: 2024-04-20 00:12:15