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 Professional Discussion / - DBPro Coding Challenges -

Author
Message
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Aug 2005 18:29
@Rii - well, it didn't work quite right, but on the plus side, it did produce a really pretty pattern:





@Nick: the first token$ command returns the first part of a string up until the first instance of the character(s) you choose - in my case, a colon. The next token$ command returns the part of the string between the last point it found, and the next instance of that character. Pretty handy. Check out the other string parsing commands there are in the undocumented commands thread.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Aug 2005 18:50
Here's something tricky you guys might not have tried parsing yet.



Yes, colons could represent a new line, but in that example you would not want to treat them as such. It's actually the equivalent of this:



I'm sure you guys knew that, but does your parser know when and when not to break for new lines at a colon?

PETA - People for the Eating of Tasty Animals
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 2nd Aug 2005 19:57
yeah i'll enter how long we got ?

life's a game and a games a life More games at www.freewebs.com/halorc
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Aug 2005 21:03
Hopefully Rii's eagerly awaited if-then to if-endif converter will cope with that no problem - right, Rii?

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Aug 2005 03:47
Btw, I'm off on holiday for a week from tomorrow, so on the offchance I happen to win this challenge, the runner up rule can be put into motion straight away. See ya!

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 3rd Aug 2005 05:04 Edited at: 3rd Aug 2005 05:05
Have a great holiday Ric.

As far as the IF/THEN converter, I had to scrap what I had. I tried to run a global look at code, and it just got way too complex. Next attempt will be line-by-line conversions using functions to ID the IF/THEN line type, and then other functions to actually process the conversions depending on the line type that was found. This way Phaelax's point is covered as well (and yep, that was just one of the many complexities I ran into).

I did figure out eventually that the line-by-line method should work: because THEN has to be on the same line as the IF. And nothing on the same line that follows the THEN would be outside of the IF/ENDIF group. Pitch in if you see any problem with this logic.

Edit: @Ric: Oops. Back to the drawing board.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 3rd Aug 2005 05:10 Edited at: 3rd Aug 2005 19:05
Okay - missed an "s" in "words$". Making word$, which was equal to "" instead of whatever words$ was. So, Len(word$)=0. Got it.

Here it is..



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Aug 2005 06:26 Edited at: 3rd Aug 2005 08:52
I'm gonna be nice and help you fellows out. This should save you all from typing a lot of DATA statements. This'll also be nice if ppl are using 3rd party dll's and have kept the keyword.ini file updated.

You'll have to fix the pathname, the forum removed all "/"'s



I just realized I don't need any keywords. I was making this way too complicated. Time to start over.


riidii, your code seems to chop off the first letter of almost every line.

PETA - People for the Eating of Tasty Animals
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Aug 2005 08:42 Edited at: 3rd Aug 2005 08:44
Quote: "eg Print "damping: ",damping# will think the colon is the end of one command and the beginning of the next"


I found that part to be rather simple. Here's my submission. (alpha version) For some reason, some of the words aren't being recognized by the parser.

Anything inside quotations is ignored, and code is indented. (mostly)



PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 3rd Aug 2005 19:07
Okay, should work now (edited 3 posts up). Thanks Phaelax.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Aug 2005 04:08
What's the deadline for this one?

PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th Aug 2005 06:10
Aug 4th, I think.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th Aug 2005 08:01 Edited at: 4th Aug 2005 08:05
And here is the anticipated IF_THEN converter.

Use it the same way as Ric's converters (I copied his reader/writer anyway ). It keeps the statement all on one line and uses colons. To spread it out to more than one line, simply use Ric's 20-Line Code Decompiler .



And here's some test code lines I tried. Feel free to try more and see if you can fool it: I'll try and make it work for most any situation (except uncompilable code or extremely silly situations).



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Aug 2005 11:28 Edited at: 4th Aug 2005 14:56
anyone else gonna try indenting?

I shortened my code a bit.


PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Aug 2005 11:34
Seems not - I'll be judging this tonight and so far we have Ric, Riidii and Phaelax. We need more entries!!

Phaelax - you gonna do indenting? It cant be that hard can it?

My Website:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Aug 2005 11:47
well i already did it. there's a bug though, towards the end of the file, it stops recognizing the closing commands for control loops.

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Aug 2005 12:05
Would there be any chance you could make it work for PHP too? I maintain a website for my job and one of the people that wrote it seemed to either not have a tab key or was just unaware of what it did and the entire blooming thing is left aligned! lol

My Website:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Aug 2005 12:33 Edited at: 4th Aug 2005 14:50
How anyone could get a job when they can't even indent is simply beyond me. I might try making this in java. I could do an applet, then users could just select their language, browse for the source code, then watch it output.

Java program indents the DBP code just fine. Now why won't my actual DBP program do it?


Ok, I converted my java program (which I know works) into DBP, and yet I still get the same problem.

PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th Aug 2005 17:58
It would have been nice to get more people in on this one, but I think we came out with some pretty usefull utilities on this challenge. Good call Nicholas.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Aug 2005 18:15
T'is fine my minions Hehe..

Its a shame we cant modify the subject header in the board so we can easily show what the latest challenge is...

My Website:
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 5th Aug 2005 10:33
yeah true but i found this diffucult maybe the next challenge should be weather but this time using particles

life's a game and a games a life More games at www.freewebs.com/halorc
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 5th Aug 2005 10:58
we've done weather 2 or 3 times. The point in these challenges is not so much to make a pretty effect or anything, its to develop and teach each other skills. Its also media free - so pretty graphical demo's are good in 1 way (you learn to develop images on the fly) but bad in another that you normally end up with naff looking demo's due to the lack of textures.

I appologise for not "marking" this challenge last night, I was otherwise engaged and by the time I was able to do it - my brain had switched off. I owe this thread more than a sleepy brain, so I'll try to get it done tonight (although I'm going out for a meal after work). I'm AIMING to start marking between 9pm and 10pm BST.

DBMad, this challenge isn't THAT hard. You could learn a lot just by making a program that loads a file up and looks through the lines for stuff, for example if someone has done if a = 1 then print "hello" you could break it down to:
if a = 1
print "hello"
endif


Alternatively, look through the code that people have done above - you could get some really good techniques from here.

My Website:
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 5th Aug 2005 11:07
It's this sort of thing that confuses me
Quote: "
"


i Can tell it indents code but that's it

life's a game and a games a life More games at www.freewebs.com/halorc
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 5th Aug 2005 12:43
what specifically confuses you? It is rather a large program for a "beginner"...

If you post what you dont get - I'm sure we'll be able to help you out

My Website:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Aug 2005 23:54
Actually dbMAD, that code doesn't indent, nor does it seem to break lines.

Best way to understand what all this code parsing does is to look at a source file first. (grab something from the 20 liner board) Go line by line and follow the code to see what its doing to it.

PETA - People for the Eating of Tasty Animals
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Aug 2005 23:56
This code indents properly, from beginning to end. I've translated it into DB virually line for line, but just doesn't work the same. I think DB is just messed up.




PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 6th Aug 2005 01:01
Ok, will mark tomorrow morning. The meal took far longer than expected and I can barely stay awake.. Damn my hectic lifestyle!!

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Aug 2005 01:02
DB Mad
That code converts If/Then statements to If/EndIf groups.

Quote: "print "Code "IF Then" statements have been converted.""


It actually should be fairly easy to take it apart and look at what it does. I write a lot of my code using functions, which makes it easier to read. Plus, you don't have to understand the specifics of all functions, just the general principles. For example, the function that starts with:

Function Replace_Text(text$,find$,replace$)

is pretty easy to guess what it does without even seeing the code (or a help file). (Even though I wrote it) If I saw a function that started like this, it would be obvious that this function does a find/replace in a text string. Now I can't tell if it replaces the first occurence, or all occurences, but I can get the general idea. Have go at it. I think you can easily interpret about 80% of the code. It will take some reading and re-reading, but not that tough.

Also, like Nic said, post what you don't understand, and we will help out. For example: the first part of that code is right from Ric's code. It's a learning challenge more than a challenge to beat the pants off of everyone else.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Aug 2005 03:36
Quote: "It's a learning challenge more than a challenge to beat the pants off of everyone else."


Nah, its a challenge to beat the pants off of everyone else. Or have you forgotten about your fight with Ric for most wins?

PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Aug 2005 04:05
He started it!

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Aug 2005 04:14
we're waiting.......

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 7th Aug 2005 11:14
Whoops - got busy yesterday and now I'm working today :-(

My Website:
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 8th Aug 2005 00:59
Ok, I've looked through the code - all three entries...

Ric started us off well with some good base code for opening files which was then improved upon by Riidii.

Phaelax had a go at doing an indenter, however I cant get the code to work. I ran it and got it to read in a file and output a new one but all it seemed to do was expand all the data statements! The test for for Phaelax's was this which is one of Ric's previous entries with no indenting at all.. For reference, I use the most recent version I could find posted on 4th Aug 2005 at 09:28.

Its a shame - I think it Phaelax's had worked, he could have won, but seeing as I couldn't get it to work "out of the (code)box", I'm afraid we're down to Riidii and Ric...

Its tough because:
1) Ric made the base code
2) Riidii did quite a bit of improvement
3) Ric is away, so Ridii will be setting the next one anyway!

God this is a really taugh one!

Hmmm...

Well, both codes are equally good in what they do and how they do it, so I'm gonna have to base the result on how "usefull" they are.

Ric's is good because you can throw code at it and make/disassemble 20-liners. Very usefull, as the 20-liners are often hard to understand!

Riidii's addition makes it MUCH more compatible as most 20-liners require heavily stacked IF statements.

ARGH!!

Hmmm..

I'm gonna have to go....


My Website:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 04:49
That's odd. Not only does my DB one not work on that code at all, now my Java version does the same buggy mistake as the the DB one used to do. I'm getting pissed off.

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 8th Aug 2005 11:13
any idea why it isn't working?

Its a shame as that looked really thorough and well programmed! I could tell what nearly everything did by just looking at it and thats something I appreciate in code. I hate looking at code and just seeing a random mess of letters (especially when its not indented )

My Website:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 11:34
Quote: "(especially when its not indented )"

Oh, you mean like Ric?

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 8th Aug 2005 12:43
*no comment*
(hmm.. next challenge could be an auto-commenter for DBP.. Like the JavaDoc hehe)

My Website:
PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 8th Aug 2005 12:46
Or a SyntaxHighlighter

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 13:17 Edited at: 8th Aug 2005 13:24
I already made a syntax highlighter.




JavaDoc
http://java.sun.com/j2se/javadoc/writingdoccomments/

PETA - People for the Eating of Tasty Animals

Attachments

Login to view attachments
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 8th Aug 2005 18:09
Nicholas - good call. I would have given it to Ric as well (mainly for leading the way, as I just took what he had and worked it).

As for the next challenge: Any thoughts? We need something people will be interested in coding for.

Here's one thought I had, but it was while I was mostly asleep so...

Create an RTS selection and movement engine. I know we had some similar projects, but this one would be more specifically around these aspects:

3D Unit Selection (from different angles, units at different heights, etc.)
Formation Movement (more formations = better code).
Obstical Avoidance and/or Terrain Navigation

In addition, I think I will be doing a tutorial of sorts as we go along (assuming no objections) to help encourage folks to join the compo. Maybe post segments a few times each week. Runs for 2 weeks.

Thoughts?

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 8th Aug 2005 18:23
I do like the obsticle avoidance idea.. thats a project in itself!

Also, the RTS selection thing would be good. Its a good way of learning how to use the pick vectors from the camera, etc...

I do like the sound of this.

However, it may be a smidge hard for the "entry level" programmer, such a Darkbasic MAD, etc..

Something more practicle and less theoretical than the indenter would be a good idea though..

Nick

My Website:
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 8th Aug 2005 19:06 Edited at: 8th Aug 2005 19:07
This thread is amazing. Been reading through it and I'm quite jealous of you all

Unfortunately, I'd consider myself not only 'entry level', but I've got DarkSDK, not Professional. Anyway, I look forward to seeing what your next challenge is, and even if I don't qualify for winning/entering - you can bet I'll be trying it on DarkSDK anyway.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 8th Aug 2005 19:13
well the quick answer to that is "buy DBPro"

My Website:
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 8th Aug 2005 19:24
*laughs* I only just bought DSDK! Unfortunately, I don't have a money hat
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 8th Aug 2005 19:30
Doesn't take much. I understand Nick got his for almost nothing. I even see a few sites offering it for free (I'm sure there is a string or two attached ).

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 21:32
*Ahem*
http://forum.thegamecreators.com/?m=forum_view&t=44248&b=6

Cmon guys, stop picking things I already did!

PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 8th Aug 2005 22:43
Heh-heh!

Good thing you mentioned that (I had forgot - I've read your post), you would of won hands down probably.

Okay - how about simple text-based or 2D style (can be top-down 3d) rpg game? Basic run-into-a-monster, computer handles combat, get treasure, and move on type game. I think something like that should be quick and easy, and it would be a good starting point for all but the newest coders. For those that are "experts", code also has to be posted often with lots of "tutorial" style comments. If we don't get a lot of participation, at least we might get more readers.

Features to look for:
Replayability
Game Balance (not too tough, not uber-easy)
General enjoyability

Graphics are encouraged, but will not be graded on (to give anyone a chance).


For anyone who wants to enter, but is not sure if they can compete: you will have several advantages:
1) No graphics to compete with. A text based game has as much chance of winning as a 3D roaming the dungeons game.
2) Plenty of help: Experienced coders will (should) be posting tutorials with their codes (I will post some stuff too)
3) Also, you can use previous posts in thread for ideas or code source. Just go to Nick's site and you can get any of the previous challenge entries.
4) If there are no objections: I'll be grading newcomers to DBPro a little easier than us old farts.

How does that sound? If you think it stinks - please post your thoughts. It's getting tough to come up with ideas now.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 22:52
Sounds ok. Shall we wait for Ric to make the final decision or is he still away?

PETA - People for the Eating of Tasty Animals
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 8th Aug 2005 22:58
He's still away. He won this last challenge, but left the runner up to call it. I figure a sort of group-decision is good; I'm just throwing out some suggestions. I think if Nick's good with it, or a few new people post approval, we'll give it a go then.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2005 23:01
roger that echo 1

PETA - People for the Eating of Tasty Animals

Login to post a reply

Server time is: 2024-11-23 08:39:55
Your offset time is: 2024-11-23 08:39:55