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
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jun 2007 06:54 Edited at: 28th Jun 2007 15:04
Here's a website I am finding very useful for this task. If you want to make a program that breaks up the user input, and creates its own responses (and if you are as bad at English as me) you'll find this very helpful.

http://www.gcse.com/english
and for more advanced versions:
http://www.arts.uottawa.ca/writcent/hypergrammar

PLUS HERE IS THE CURRENT CHALLENGE AGAIN: POSTED BY TDK
I for one keep losing it, we need to make a special formatting style for challenges.



Trying to format text:
Challenge Text Doh!
[size=20]Challenge Text[/size] Doh!
Here are some sprites that i think could work (and I just like the linux penguin) The book stands out well too.
Challenge Text
Challenge Text
Challenge Text
Challenge Text
Yeah I really like the book, what does everyone else think about putting it at the start of a challenge post? Do you guys have any other ideas on how to make them stand out?

This challenge is extremely complicated!!! I'm trying to make one without any pre-written sentences, but I'm finding it hard breaking down a sentence to analyse let alone have the computer construct its own!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jun 2007 19:19 Edited at: 29th Jun 2007 19:21
Is this thread dead?

[EDIT]

I guess not, and woooh I'm not a noob anymore!
Can I delete this post?
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 29th Jun 2007 19:23
I keep following these challenges, though i cannot complete the majority of the tasks, I learn a lot by reading the problems and solutions from the other users. I"ll find one that i can do and then i'll be back. Wow, i've said that about four times...

Anyway, these entries are looking very well done and I"m looking forward to the winner. Keep it up guys.

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Jun 2007 21:16
Quote: "This challenge is extremely complicated!!! I'm trying to make one without any pre-written sentences, but I'm finding it hard breaking down a sentence to analyse let alone have the computer construct its own! "


You can make the task a little easier for yourself and approach it like the computer is a baby or a parrot. You can have a few keywords that trigger the computer's responses, and you can have the computer grab pieces from your sentence so it seems that it understands the topic.

Here is a super basic example that I just put together. I grabbed TDKs string functions for this one. The computer will only respond when there is a direct reference to "I" (yourself) or "you". This can easily be expanded upon, in fact you could use arrays and make a database to store past responses - and of course include other keywords besides I and you.



Enjoy your day.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Jun 2007 02:45 Edited at: 30th Jun 2007 03:08
@ Latch

Thanks Latch, very useful. I was thinking about how to categorize words (Nouns,Verbs,etc) and then how to build sentences from them, but starting with the response and working back might be a lot easier.

@TDK

Your code is so easy to read
I didn't know you could STEP -1 in a FOR loop!
I particularly like the MIDSTR() function, I might steal that for this challenge if you don't mind.
My only disappointment with this is, although it is clever recognising strings with the INSTR() it can't then use these words to construct its own sentences, which is what I really want to do and am having trouble with, obviously I'm not asking you to hand over code to do this but I'm finding it really difficult. I've looked at various english language websites and it's all getting very complicated.
Do you think I am aiming too high for the limited time?

PS Unless I'm wrong, you've missed a trick in your INSTR() function, you could have called the MIDSTR(), or was the idea that these are all independent?

Did I do good?

There are so many functions in this program! I'm saving it
Thanks again guys.
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 30th Jun 2007 02:50
Wow, haven't been on in a while, and suddenly realized I might have missed the deadline! I know I'm not gonna win, but I agree with Zombie20 about learning every time. I'm glad I have till (our (the US's)) Independence Day! I can shoot off fireworks while coding!

PS I have lame jokes. Get over it.

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Jun 2007 03:27 Edited at: 1st Jul 2007 14:42
What do I do if I want to ask someone about something unrelated to this thread? I don't want to mess it up.

PS can you use an array in a function?

This is the kind of thing I was thinking of making, I don't think it's very clear and not sure if I can do it


[EDIT] Wooo! this is the 11,000th view of this thread!!!

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 3rd Jul 2007 18:11
Is this challenge going ahead I haven't heard anything for ages? (or are you all just hard at work?)

I'm struggling with this one, haven't really even decided what I'm going to do and the deadline is the 4th 0:00GMT!
Can't see me winning this one

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 3rd Jul 2007 18:16
There's no way I'm gonna get this done in time...

The below sentance is true.
The above sentance is false.
Paradox!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2007 03:33
Quote: "PS can you use an array in a function?"


Yes. If you dimension it outside of the function it is global, if you dimension it inside the function, it is local.

@Obese

Your approach is fine, but it is also very specific and might be limiting. If you approach it a little bit more generically, instead of teaching it a language specifically, try and get it to respond and store responses based on what is being typed. That way it can be any language. One method is using pairing. When the program first starts, it is dumb. It's the user's job to teach it. When the user types in a series of words, the computer will break out each word and store it, maybe give it a weight (how frequently that word is used). Now the next time the user types something, the computer searches through it's words to see if it has any of them stored. If it does, it increases their weight and adds the new ones with lower weight. Then it looks for pairs.
Any words that appear in succession are given another weight as a pair (or larger group). This process gets repeated over and over and each time the computer tries to pull out words or pairs that have the highest weight. At first, the user has to type in the appropriate responses to teach the computer - it is from these responses that the computer should do it's cataloging. Eventually, the computer will start responding based on what responses and word pairs have the highest weight for whatever input the user is typing. So in theory, it could be any language, or a mixture of languages because the repsonses would be keyed from what the computer has learned from how the user responds. Add a little randomness for words with low weights that don't appear often, and it opens the door to increase the computers responses.

Enjoy your day.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Jul 2007 05:08
@ Latch
I see what you're saying, maybe I could have pre-programmed responses and then substitute words. It is a shame as I wanted the computer to construct it's own sentences using nouns and verbs etc
If I do enter anything it certainly wont be
User: I have a cat.
PC: So you say you have a cat.
That is lame lol.
I've just had a good idea, I could make sentence "maps"
e.g. [noun] [verb] [noun].
becomes Dogs chase cats.
and these "maps" could be applied to different user input sentence types. I'm still stuck on how to store the data.
Thanks Latch the weighting is a good idea.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Jul 2007 19:43
Last call...

This challenge closes in just over six hours!

TDK_Man

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Jul 2007 05:16
No one entered?
I told you this was a hard challenge lol
If were going to vote I vote for a change of challenge cos I can't seem to get anywhere with this and I don't want to do a rubbish "parrot" version

What does everyone think of my red book idea for making challenges stand out?

I make music and art. Here is a sample of my art: done in Paint! It's all I have
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 5th Jul 2007 06:56
I was too busy watching the fireworks...oh well.

@OBese87: I think maybe:

CHALLENGE: blahblahblah
expanded info

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Jul 2007 14:45 Edited at: 5th Jul 2007 16:35
@ Ninja

I think thats a good idea because sometimes you want to just check the rules or whether there need to be any graphics etc without having to read through the whole challenge.
You could take it as far as you wanted

Challenge
Rules
Extra info
Graphics

As long as your sections were useful and the sprite had something to do with that area, I think it would make it easier to read (and find).

[EDIT]
The fact that I can't do it makes me want to lol.
This is a huge project though (if you want to make a decent one) it would be so awesome but I don't know if I have time to be able to get one done for a challenge. I will keep working on it until I hear from TDK.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jul 2007 17:41
@Obese87
Quote: "I see what you're saying, maybe I could have pre-programmed responses and then substitute words"

No, not really what I meant by pairing and weighted words. This method, you'd have to talk to the computer for a long time for it to build up an adequate database where it is able to put words together in the correct order based on how often they are used and how they are paired with other words. It doesn't presuppose language syntax, it learns based on user input.

@TDK
This was an interesting challenge and I had something prepared to enter, but I was hoping that there would be some entries from others that hadn't entered a challenge before.

Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Jul 2007 18:16 Edited at: 5th Jul 2007 18:28
OK - back from work now, sorry for the delay - had to go on a call-out.

The challenge is now over!

Pens down - no talking...

Quote: "This was an interesting challenge and I had something prepared to enter, but I was hoping that there would be some entries from others that hadn't entered a challenge before."


Well I thought it was a very easy challenge that anyone could have entered. It was deliberately worded in such a way that allowed you to write it very simply if you were a beginner and make it a lot more complicated if you were more experienced.

I'm afraid that yet again, we just saw a lot of lame excuses...

To those of you who wasted time making irrelevant posts instead of writing your program for the challenge, I say this:

You are wasting an opportunity to learn stuff you don't know in DB.

If you don't know how to do something, ask! At least have a go at the challenges instead of complaining about them.

String manipulation is elementary stuff and will come in useful with most if not all of the programs you will write in the future.

End of sermon.

Now to double check that I've not missed any entries other than the one that is the winner by default...

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Jul 2007 18:49
Well, I found three snippets which could be classed as entries from Latch, NanoGamez guy and NinJA999.

Unfortunately, none of them were in the mood to talk to me lol!

Latch's entry didn't say anything at all.
NanoGamez guy's entry just repeated I am a computer over and over again.
Ninja999's entry only wanted to square a number - not talk.

I know that these were maybe not even intended as entries, but they were the closest thing to entries I could find and I didn't want to leave anything more than a handful of lines out.

Had there been just one entry I would declare it the winner - even if it didn't do what the challenge required.

As there was more than one entry - none of which fulfilled the criteria of the challenge, it's impossible to pick a winner and therefore I have no option but to declare this challenge null and void, and set another one.

Just choosing something now...

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Jul 2007 19:46 Edited at: 6th Jul 2007 16:37
OK, here's the new challenge (taken from the list on my forums if anyone wants to add to it):


The Great Grid Challenge!


Below is my MakeGrid() function.

In this challenge, you can write ANY program you want - so no excuses this time!

The only rule is that the function must be used and the resulting grid seen on screen and used by your program.

It doesn't have to be a game - what the grid does is left entirely to your imagination. It could be a demo you can sit and watch or have the user participate. It's up to you.

As usual, NO external media.

Closing date Thursday July 12th at midnight GMT.

Good luck!

The Function:



Usage:

This function will create a 2D grid on the screen and returns no values. It accepts the following parameters:

XPosition - The screen X position of the top left corner of the grid.
YPosition - The screen Y position of the top left corner of the grid.
Columns - The number of vertical Columns on the grid.
Rows - The number of horizontal Rows on the grid.
XSize - The pixel width of each cell on the grid. *
YSize - The pixel height of each cell on the grid. *
CellColourF - The colour of the grid foreground - you can use RGB() in the call.
CellColourB - The colour of the grid background - you can use RGB() in the call.

* This is the inside measurements of the cell - and doesn't include the grid lines so using XSize=8 and YSize=8 gives you an 8x8 box in the grid (10x10 if you include the lines).

Example Function Call:

Grid(100,100,8,8,32,32,RGB(255,255,255),RGB(100,0,100))

This places the grid at X=100, Y=100, has 8 rows and 8 columns, each cell being 32x32 pixels in size. The grid line colour is white and the grid background colour is dark purple.

TDK_Man

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Jul 2007 23:56 Edited at: 6th Jul 2007 03:53
Good challenge, this will be very interesting.
Sorry about the last one, I aimed too high and then just caved in, I guess I'm still a noob then

[EDIT]

Here's what I've done so far. I got the inspiration from the way you create objects in 3D Studio Max (download the trial, and it's awesome)
It's pretty badly written and I have two problems: I can't get the mouse to stay within the grid, and when you are sizing the columns/rows it goes from 1 to 20 in a single step, i want it to go 1,2,3,4,etc. It is now too late for me to think straight, I'd be very grateful if anyone can help. nite folks

[EDIT]
I'm so tired I forgot to put my code in lol.



[EDIT]
Sorry I should have explained what it does. You move the cursor and click the mouse to set the grid's origin, then you move horizontally to set the width and click, then you move vertically to set height etc

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 6th Jul 2007 03:34
TDK-Alright sir, this time i'm joining and not falling out!! Zombie is back and motivated thanks to your sermon above. I shall not fail you!!!

zombie(TheCheeseGrater)

NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 6th Jul 2007 05:02
Hmm...I'm sure I can find something to incorporate that function into...even while I'm on vacation...

NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 6th Jul 2007 06:29 Edited at: 6th Jul 2007 06:35
Here's my first entry. It runs slow on my laptop, but that might be because of the integrated graphics. Tell me how it goes!



[EDIT] I copied and pasted it into DBPro, just to see what would happen, and it ran way faster! (about as fast as I had initially envisioned it). I liked it so much I even put it as my own personal screensaver! Anyway, since it doesn't seem to work too well in my DBC, I'd like to see how well it's working in other peoples' DBC.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 6th Jul 2007 15:49
That's kind of cool. That really is an original idea. I can't believe you already have something done, I've hardly begun! It does "bunch up" a little at the bottom and on the right sides of the screen, but nice job.

LB
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 6th Jul 2007 17:26
Was it fast for you? Slow?

I just whipped it up quickly--my original idea was just a patchwork of flashing lights, but I made it better.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Jul 2007 18:41
it ran pretty slow for me (about 3fps) still looked ok, I like the different shades of colour. What are you gonna do with it now?

I've posted my "so far" a few posts up please check it out and any comments would be great.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Jul 2007 20:12
NinJA999

Rather than alter the iterator variables in For..Next loops:



you should use Step:



And for some reason, when I run it, I don't get ant change in colours. Everything is just red grids on black background...

TDK_Man

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Jul 2007 21:09 Edited at: 6th Jul 2007 21:21
@Ninja
Instead of your "up" variable and all that goes with it, I would have done this:

Change:


To:


does that still do what you want?
(Your's is much more original than my idea )

@TDK

It takes quite a while for the red to "heat up", try running it for longer.
Is mine too basic? I like it but it's not much of a thing to enter.

I make music and art. Here is a sample of my art: done in Paint! It's all I have
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 6th Jul 2007 22:37 Edited at: 6th Jul 2007 23:28
Arghhh, my Internet provider failed on the deadline day! (grumble-BritishTelecom-grumble) Oh well, I had nothing anyway.
This one looks interesting...
EDIT:
Ok, I have my entry! It's a bit tacky, but...


The below sentance is true.
The above sentance is false.
Paradox!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th Jul 2007 00:41 Edited at: 7th Jul 2007 01:13
@Insert Name Here

LMAO I love it, wasn't expecting that! 100000 points for originality.
Here is my entry so far, I just realised it was posted over only a couple of mins later.


Still can't get the mouse to be "stable" and stay inside the grid, can anyone help?

I make music and art. Here is a sample of my art: done in Paint! It's all I have
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 7th Jul 2007 02:01
OBese87

Help me out here. What is it that you want the mouse to do within the grid? I managed to make a grid, but it was a little tricky. Did you want to constantly keep re-drawing the grid through each do - loop iteration? The program seems to really lag. Maybe you could have a box drawn dynamically and then once the user let's go of the mouse, the grid is put in the middle of the box/rectangle.

LB
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 7th Jul 2007 06:22 Edited at: 7th Jul 2007 06:25
@TDK - As OBese said, it takes a while to warm up. I know it won't count for the contest, but paste it into DBPro and just see what I intended it to be like.

@OBese - As I don't really have much time now, I can't try that, but does it basically increment the col by one until it reaches 255, at which point it decreases to zero, and so on? That's what it does in mine.

@Insert Name Here - Cool! Didn't even think about drawing with it! Lol... Well, I have a long car trip tomorrow, maybe I'll come up with some other ideas.

[EDIT] I know it won't count towards the contest, but just so people can see what I intended the screensaver to be like, I've included the built scr file. Just double click it! Put it into your C:\windows\system32 folder to use it as your screensaver (as I did). It mesmerizes me.[/EDIT]

Attachments

Login to view attachments
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 7th Jul 2007 06:26
I am so ashamed of myself, I can't think of something to do, but I do think its because I'm distracted. Anyway..I've seen the other entries, they look cool and I hope I can come up with something lol.

Also LBFN-This has been driving me nuts I have to know, are you Lee Bamber?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 7th Jul 2007 07:07
Zombie 20
Lee Bamber!!

I assume this isn't some sort of cruel joke. I almost fell out of my chair! Mentioning me and Lee Bamber in the same sentence is like . . . close to being a sin. Anyway, you have shown a lot of kindness to others Zombie and I appreciate even the thought, so God bless you! You put a smile on my face

LB
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 7th Jul 2007 07:29
LBFN-I'm confused, flattered and laughing at the same time. No this is not a cruel joke, I actually thought you were Lee Bamber. And I'm glad I make people laugh and smile, thats a very good thing for me to hear. That made me laugh too.

Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 7th Jul 2007 13:20 Edited at: 7th Jul 2007 13:30
@NinJA999- It didn't work for me either, your program. It was just a load of black-background red grids like TDK said. I'll try the screensaver and see if that works.
Edit: Nope, just red on black again... I'll have a lok at the code.
edit2: This worked for me... but I don't know if it's what you did. It's a bit uneat, I'm rubbish at darkbasic


The below sentance is true.
The above sentance is false.
Paradox!
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 7th Jul 2007 14:28
No, actually that was what it had initially been going to be like. If you wait a little while while watching the screensaver, the grids (which should be shifting around) will gradually change color from red to black, while the insides of the grids will change from black to an assortment of random reds (each grid a different random color). Just open up the screensaver and wait a bit.

Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 7th Jul 2007 16:43
I was wrong and you were right.
Well an improvement would be to make it happen faster otherwise peaople would look at it for a few seconds then think that nothing else happens.

The below sentance is true.
The above sentance is false.
Paradox!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Jul 2007 20:18 Edited at: 7th Jul 2007 20:19
NinJA999

Having run it in DBPro and seen the effect you are after, I've modified your code snippet to do approximately the same thing in DBC.

It is however a good example of DBPro's additional speed.

As it is, the following code is still not as fast as DBP, but is probably as good as you are going to get with DBC:



[Edit] Lol - try running this version in DBPro...

TDK_Man

Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 7th Jul 2007 23:51
@OBese87
Your code was...intersting, but a little glitch. How come I couldn't move my mouse outside theboc from the top or left?

<font size=5>Your signature has been removed by someone becasue it was vaguely intelligent.</font>
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 8th Jul 2007 03:00 Edited at: 8th Jul 2007 03:09
@Insert Name Here - that's what I had been working on, and that TDK just did.

@TDK - Wow! I was trying to do that for a while now! And you did it seemingly effortlessly! Hope you win again.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Jul 2007 03:09
Quote: "Hope you win again"


I can't because a) it's your program, not mine (I only modified it) and b) I set the challenge!

TDK_Man

NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 8th Jul 2007 03:13
Oh right. But still, since you modified it, according to your rules, it's now a separate entry (and since done by you, doesn't count), so the only entry I have entered so far is the sloooow one.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Jul 2007 03:33
Quote: "so the only entry I have entered so far is the sloooow one."


Why not alter the faster version a little (if you want to that is) and enter it as your second version. Or, stick with the original version as the one I posted can't be included as an entry - by me anyway.

The spirit of the rule you mention is that you can be given improved code, insert it into your program and re-enter it. No-one is able to take your program, alter it a bit (or just speed it up) and enter it as their own - it's still your program.

The bits you can 'steal' are the improvements - not the program idea itself. You can also steal a 'good' piece of code from someone's program and use it to create a totally different program and just credit them for it's use.

TDK_Man

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Jul 2007 13:09 Edited at: 8th Jul 2007 13:14
@Ninja999
I looked at your original version, it worked, a bit slow but was a cool idea! TDK's enhancement really did the trick.

@Obese87
I had a little trouble controlling the box making. Here's an entry that might be closer to what you were trying. Though this only allows you to make an equal number of cells in the x and y direction, it shouldn't be too hard to modify. Enter the numberof squares for the grid, press return, then hold the left mouse button and drag it to get the size of the grid. Release the button and the grid will be drawn to that size.



@Insert Name Here
That's pretty neat! I got a smile out of it, then I realized it blurs if you move the mouse! Bonus!
though you should avoid using language keywords as variables or labels:


You have next as a label. You really should avoid that kind of thing.

Enjoy your day.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Jul 2007 13:41
Ok, TDK said no excuses, so I had to rattle the old coconut around a bit to try and come up with something to do with the grid function. I came up with a waypoint marker for a matrix (it doesn't have to be just used on a matrix as long as you know the size and origin of your world object(s)).

I used the grid function for 4 things:
As a frame around the camera view
As a waypoint selection grid
As a matrix reference overlay
And as a texture

The screen is divided into 3 main sections:
On the top left is the green waypoint selection grid. It is here that you click on the various cells that represent the tiles of a 25x25 matrix to set waypoints.

The matrix is in the main camera view which goes from the center to the right side of the screen. Here you see the camera movement as a result of the waypoints you set or by moving the camera directly with the arrow keys.

On the lower left is an overhead map of the matrix. This is where you see the resulting path the camera is moved. If you press the CONTROL key, a blue grid overlay will appear that shows the matrix tile squares in relation to the map. Press CONTROL again to hide the overlay.

To set a way point, click on a square on the green grid. The waypoints are stored in the order that you click with the last selection being the last waypoint the camera will move towards. A set waypoint is red, but you may set that point more than once. If a waypoint has been assigned more than once, it will be colored grey. At this point, there's no way to tell by looking at the grid what the order of waypoints are. I may add numbers to the selected squares later on. Right now you can store up to 2000 way points. That allows each of the 625 cells to be set at least 3 times.

If you are unhappy with your waypoint selection, right click and everything will be reset with a new map. Press ENTER to have the camera move to each waypoint. Press SPACE to interrupt the cameras movement, at which time, you can enter more waypoints, or reset the map.

If you want, you can move the camera around freely with the arrow keys. The camera's path will still be recorded on the map.



Enjoy your day.
Data
19
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 8th Jul 2007 18:34
thats really cool Latch especially how you used it as a texture.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Jul 2007 20:45
Insert Name Here:

The whole point of the challenge thread is to teach newcomers the basics and good programming techniques with small programs which cover a single specific topic - rather than them jumping in at the deep end with writing an RPG or FPS and get completely lost as they don't understand what they are doing.

Far too many newcomers are asking questions on advanced topics like collision for their 'MMORPG', when they don't know the difference between integers and floats, how For..Next loops work or how many other incredibly basic aspects of programming work.

I took a look at your entry and with the above in mind, the following is not to demean your effort, but to point you in the right direction where you could be doing something better. (I did things the same as you many years ago when I first started - until I was shown the right way).


The Ink Command

A lot of newcomers use the Ink command like you have:

ink rgb(250,225,205),1

To me this says that the user doesn't know what the ,1 on the end actually does, (an assumption on my part admittedly).

The ink has a foreground colour and a background colour but the background colour is only used by the text command and even then, only if you have used Set Text Opaque. By default, the DB screen background colour is black - which is RGB(0,0,0) or 0 (zero) for short.

Using 1 for the background colour is not black, but is so close to black (0) it doesn't make sense - and the difference can't be seen so it's fairly safe to assume that the user thinks the 1 means something else.

So, unless you need a specific background colour for text and you have used Set Text Opaque then you should always use:

ink rgb(250,225,205),0

... because the background colour is invisible anyway.


The First Do..Loop

All programs should only have one main Do..Loop and you normally never exit from it, (you end the program inside it if required).

In your program, all the loop does is count to 200 and then exit with a very nasty Goto. This could be done much more effectively with a For..Next loop and more importantly means you can dump the Goto! Yay!

If you ever find yourself needing to use a Goto, think about a way to do the same thing without it. If you can't, then just ask - there's always another way!

And as Latch says it's very bad practice to use DB keywords as variables or labels - it's confusing to read and confusing to DB!

Blur Bitmap

With the Blur Bitmap command, 6 is the highest value you can use, so your blur bitmap 0,8 with a setting of 8 doesn't actually blur to level 8.


Multiple Circles

You have a section which draws 10 circles. They are all at the same location but have a radius from 1 to 10. Rather than do as you have and type the command 10 times, this is an ideal situation for a For..Next loop.

All your 10 lines can be replaced by just 3 lines:




Program Layout

Your program is quite small, so layout isn't all that important. But if you wanted to add to it later, making it 'modular' would make life a lot earlier. Besides, if you get into the habit of making the small programs modular, you'll be ready for when you write the bigger ones...

Put as much as you can into separate procedures and call them with Gosub. Functions are also available, but in DBC, procedures are better as you don't have to worry about local variables.

So, here's your whole program written the 'proper' way:



TDK_Man

Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 8th Jul 2007 23:23
Thanks TDK, I have absorbed and processed the assistance.

Your signature has been removed by someone becasue it was vaguely intelligent.
Bad Barnabe
16
Years of Service
User Offline
Joined: 6th Jul 2007
Location:
Posted: 9th Jul 2007 03:26
Mh... Is there some way to do "masking" in darkBasic? E.x.: make a circle that "masks" the grid everywhere except the part under itself? And also how long is this challenge? is it over???

Login to post a reply

Server time is: 2024-05-19 15:10:42
Your offset time is: 2024-05-19 15:10:42