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
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 20th Jun 2007 18:10 Edited at: 20th Jun 2007 18:34
Well, I got started... but it doesn't seem to know the or command .

I did


If I remove the "or comment$="moron"" it works, but if that's there then it gives me the error:
"unrecognised parameter"

E.D.


Shame I can't change my name
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 20th Jun 2007 18:32
Congrats TDK! Nice challenge, But mabye the deadline is a bit tight though...


Nothing is impossible...
No really, it is.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Jun 2007 18:57
Congratulations TDK!

This challenge seems a bit difficult. If I get some time, I'll give it a go.


@Eldest Dragon

Did you leave out the THEN or the ENDIF. This example seems to work ok - but with only a slight adjustment of your code.



Enjoy your day.
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 20th Jun 2007 19:10
Weird.... But anyway it works now, thanks very much!

E.D.


Shame I can't change my name
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 20th Jun 2007 19:30
Well done TDK.
Lets get to work...

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: 20th Jun 2007 20:23
Quote: "But mabye the deadline is a bit tight though..."


Fair enough - anyone else think two weeks would be better for this challenge?

TDK_Man

NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 20th Jun 2007 20:28
I think so, as it would allow for a more elaborate system of responses.

I also need clarification--you first said to make a program that you can talk to, then showed an example of a program that remembers what a cat is. Can we still create *any* type of program you can talk to? (e.g. 20Q or a simple one-topic chat)

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 20th Jun 2007 20:32
I agree with the increase of deadline, as this did seem to be a difficult challenge.
@NinJA999
I would follow the specifacation rather that the letter, I assume 20Q or 1 topic chat is fine.

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: 20th Jun 2007 21:07 Edited at: 20th Jun 2007 21:26
OK - the new deadline is:

Midnight GMT on Wednesday 4 July.

NinJA999:

The idea is to create a program that you can talk to - just like a human - though I'm not expecting any of your programs to pass the Turing Test...

It should respond to whatever anyone types in - regardless of the subject - by examining what the user types. So, if the user types 'Hello' then the program should respond with 'Hello' back.

If the user types 'What is your name?' then the program should recognize that it's been asked a question, (by the question mark on the end) and try to answer the question.

You can scan for basic keywords at the start of the question to identify questions too - like How, Why, When, Can and so on.

The save idea is optional to build up a database of subjects the program knows something about. (Anyone remember that old computer game from years ago where the computer had to guess the animal you were thinking of by asking questions about it when it guessed wrong)?

If your program cannot figure out what the user has typed, you can always have it say one of a set of 'Sorry I don't understand you' phrases chosen at random.

Oh yes - I forgot to mention...

In your game, you would scan for swear words and respond accordingly. In this challenge, we can assume that the 'user' won't be typing any swear words in...

So, it's basically creating fake AI to make your computer have a meaningful conversation with whoever is using it - and as mentioned before, what you end up with could be applied to any game which requires conversations with NPC's).

TDK_Man

MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 20th Jun 2007 21:12
2 weeks would be good... I've got a great idea.... .

E.D


Shame I can't change my name
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Jun 2007 21:22
This also might be of use to some of you:

http://forum.thegamecreators.com/?m=forum_view&t=102344&b=6

It's a set of additional string functions which may make the challenge task easier. This thread is Dark Coder's function collection, but my set of string functions is there also (scroll down to my post and the Download button).

If you use mine, check out the WordCount() and ArrayStr() functions.

TDK_Man

Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 21st Jun 2007 20:33
Imagine if one of these did pass the turing test... that would be special.

The below sentance is true.
The above sentance is false.
Paradox!
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 21st Jun 2007 20:40 Edited at: 21st Jun 2007 20:50
I doubt mine will.....

Currently 150 lines with no commenting at all :S


Mike B

Call me Mike please
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 02:40 Edited at: 22nd Jun 2007 03:51
The challenge shouldn't be too hard for me... I hope
Which command (or function) returns any part of the string? For example, if the user enters "hate" and "cat" the computer would say "I disagree."

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 22nd Jun 2007 06:10 Edited at: 22nd Jun 2007 06:17
Well, Sinani201, in his String Library, it would be the InStr function.

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Jun 2007 06:27
The mid$ command will tell you what is in the string by letter. Syntax is
. You could get the length of the string and then search for [space] characters by changing the 'Value' in the command. The letters in between the spaces make up the words. An example:



This code is not all inclusive, but does show how to use mid$ to find words.

LB
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 22nd Jun 2007 07:33 Edited at: 22nd Jun 2007 07:35
Hmm...I don't mean to be a pest, but in my program, after I have had a conversation for a screen, the text doesn't scroll up (I am using print statements). This is a really stupid question, but how do I make it move up a line every time it goes offscreen (like DOS)?

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jun 2007 15:09
Sinani201:

Read the thread I posted above.

ArrayStr() will take a sentence and place each word into separate elements of a string array - and tell you how many words there were.

WordCount() will tell you how many words there are in a sentence.

GetWordStr(n) Returns the nth word in a string.

Midstr() is a modified version of Mid$() which works as it does in most other languages - ie: as it's supposed to! It uses the syntax:

A$ = Midstr(StringVar$,Position,Length)

So:

A$="ABCDEFGHI"
Print Midstr(A$,3,5)


would print 5 characters starting at position 3 - 'CDEFG'.

NinJA999:

You need to manually scroll an on-screen text area by placing your text into string arrays. I did a code snippet to do this years ago. I'll see if I can find it for you.

TDK_Man

MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 22nd Jun 2007 16:00
Currently my program is just a print and input program, so I'm just using cls.

But it'll get pretty once I've got the shell .



Mike B

Call me Mike please
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 18:09 Edited at: 22nd Jun 2007 18:11
@LBFN
Great code. I'm using it a lot, so thanks!

@Mike (Eldest Dragon)
That's just like my program!
But if I have time later, I'll probably add more detail to it. So far no detail at all

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Jun 2007 05:04
Here is another way you can scroll text. It does not use arrays. You have a blue input area that is always at the top of the screen. The entered text is then scrolled down and eventually off the screen.

The program assumes that only one line of text will be input before the user presses {RETURN}.


LB
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 23rd Jun 2007 06:31 Edited at: 23rd Jun 2007 06:35
Agh! Is anyone else having screen flashing problems? It's driving me NUTS!!! It happens on both of my computers, and will probably end up giving me a seizure! If anyone knows why it is happening, is there a way to stop it?

EDIT After putting a few strategic cls's, it seems to cut down on the flashing. But, every once in a while it will suddenly start flashing, out of the blue! Any knowledge/cures of this?

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 23rd Jun 2007 07:34
perhaps you are using the sync on and sync commands incorrectly?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Jun 2007 07:42
@ NinJA999
I assume by the term flashing, you mean it flickers (please tell me if you mean something else). Without seeing your code, it is a little hard to say. The first place I would look would be with regard to when/how you are using the sync command. If that isn't it, perhaps it has to do with grabbing sections of the screen, using the cls command and then pasting the image. If you are doing this on bitmap 0, you could get some flicker. It seems odd to me that adding cls commands reduces your flicker.

If this still isn't it, I would like to take a look at your code.

LB
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 23rd Jun 2007 08:01 Edited at: 23rd Jun 2007 08:08
Quote: "screen flashing problems"

It happens to me too. No, this has NOTHING to do with syncing. If you put CLS at the top of your program it fixes it all up

Just put it at the top, and don't put more, unless it's necessary.


I thought of a simple way to stop the chatting text to fall off thee screen. I don't have a written code for it yet, but the idea seems good.
First, use a DO...LOOP command to start the chat. then use a REPEAT...UNTIL command within it. create a variable, and every time the computer posts a message increment the variable. When it gets to a certain value you can clear the screen and the chat should run smoothly.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 23rd Jun 2007 10:39
I've got about the first half of the shell now .


Mike

Call me Mike please
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Jun 2007 16:18
All,

I would recommend that you visit TDK's personal website/forum at http://www.computechtenerife.com/forum/index.php. It is well thought out and easy to use.

LB
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 23rd Jun 2007 16:46 Edited at: 23rd Jun 2007 16:47
@LBFN:Yes, I do mean it flickers. I don't have any sync on or sync rate or sync commands, and I'm doing nothing with bitmaps.

@Sinani201:Yes, with a cls command at the top, they were greatly reduced (see my last edit), but still every once in a while it out of the blue starts flickering!

Oh, and I've got it moving text up pretty well now (string arrays). Now I'm working on the interpreting.

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Jun 2007 18:15
NinJA999:

Are you using the 2007 download of DBC? I had to switch from using it and go back to the previous version I was using for exactly that reason.

If not, use Sync because the problem is down to you not using it.

All:

I found my Scrolling Text Box function!!

The Function:



It's fairly straight forward and works regardless of font face and size used.

Parameters:

XPos,YPos - Screen position of top left corner of text box
ScrollBoxWidth,ScrollBoxHeight - Width and Height of box
NewLine$ - Text to print
R,G,B - Background colour of text box
Border - 0 for no border and 1 for a border around text box

Important!

You MUST include the two following DIM statements at the top of your program:

Dim Display$(100): Rem Array required for function
Dim LineCount(0): Rem Array required for function


Example Usage Demo Program:



The text scrolling box can be any size and placed anywhere on the screen. It does not word wrap, so the length of the text sent to the function must not be longer than what can fit in the box.

It caters for any size of text and any font.

Might be worth me posting this on the code snippets board again seeing as the original doesn't show up in a search...

TDK_Man

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 23rd Jun 2007 18:47 Edited at: 23rd Jun 2007 19:12
Why doesn't this work? It says it's an unrecognized parameter. When I cut it down to one string, it works fine. Why doesn't it understand the OR command



Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 23rd Jun 2007 19:00 Edited at: 23rd Jun 2007 19:02
Here's how I did it:



My real program has 800x600, but I lowered the res for this so that you could get to the scrolling part relatively soon.

Oh, and *now* my program uses bitmaps, but before when it did not it still occasionally did that.

@TDK:I'll use my older DB (2002...wow) and see if that works better.

@Sinani201:What is the code that is not working?

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 23rd Jun 2007 19:16 Edited at: 23rd Jun 2007 19:17
Here's my first entry, Probably the most intelligent conversation I've had in years! It's got a scrolling system which fades up. Feel free to use it.




Nothing is impossible...
No really, it is.
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 23rd Jun 2007 19:34
Optomized the code a bit...(it was written last night at about 12:00, so it was a little haphazard)



42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 23rd Jun 2007 23:52
Aaargh I don't stand a chance!

Your code looks a lot better than mine


Mike

Call me Mike please
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Jun 2007 00:30 Edited at: 24th Jun 2007 00:31
Quote: "What is the code that is not working?"


Oops, forgot about that.


Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 24th Jun 2007 01:10 Edited at: 24th Jun 2007 17:27
@Sinani201

Try:



Each separate statement has to stand on its own (eg you can't just say if "How do you do").


Don't forget to do a lowercase conversion incase someone types weird:



42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Jun 2007 15:47
@ Sinani201

I think I see what you are trying to do, in that the questions asked would equate to the same response. If you want to do it like that, you should code something like this:



If you are going to use lower$("text"), your t$ check strings will need to be completely in lowercase letters.

LB
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jun 2007 19:58
Quote: "if t$="How are you?" or t$="How do you do?" or t$="Whats up?" or t$="Hows it going?" or t$="What's up?" or t$="How's it going?""


The biggest problem with doing it like that is that it's hardly ever likely to recognise what the user has typed.

Standard phrases should be stored in data statements and read into an array. You can then check for them in a loop rather than the very long If X=A Or X=B Or X=C... method.

You should also look at splitting the entered sentence into separate words and try to figure out what the user means instead of trying to pre-guess what they might type.

TDK_Man

alien master
16
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 24th Jun 2007 20:49 Edited at: 24th Jun 2007 20:51
well im starting one and it already says there is something wrong and i cant find it?


it says the last line is unrecognized

ohhhh i found it forgot the = sign

Alienmaster
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 24th Jun 2007 23:01
alien master- you should use the lower$ command, so you don't have to check for different capitalizations of words.

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Jun 2007 23:09
@TDK

Good challenge! It's gonna be pretty complicated, this is my first challenge too!
Does anyone have any good ideas for how to create relationships
For Example:
An Ostrich is a type of bird.
A bird is a type of animal.

----
PS
Following TDK's link i found this conversation between two "bots", it's quite amazing.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Jun 2007 23:50
@noobs

since neither of you have replied to the "lower$" posts, I'm assuming you don't understand what it is or why you should use it?

The lower$(string$) command changes all letters in the string to lower case letters. This is useful when reading input as you can just check it against one string (e.g. "hello") rather than several ("Hello", "hEllo", "helLo", etc.)

If I'm being patronising just give me a slap lol.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Jun 2007 00:59 Edited at: 25th Jun 2007 01:00
Out of interest, I've always done exactly the same thing, but with Upper$() instead of Lower$().

The end result is the same, but if you need to do any work on the string then everyone knows that uppercase 'A' has an ASCII code of 65 whereas you don't tend to remember what the ASCII code for 'a' is...

Quote: "Does anyone have any good ideas for how to create relationships"


Your best bet would be to create a text file 'database' which your program can refer to.

As described a few posts above, when someone uses the word 'Ostrich', search the database and if it's not found, ask questions about it - adding the replies to the database.

This would allow something like:

User: I have an Ostrich

Your program sees 'I Have' and knows that the words after it ('an Ostrich') is what the user has. So the program would remove 'a' or 'an' and looks up Ostrich in the database.

If nothing is found, then the program could say 'What is' followed by the unknown object - 'an Ostrich?', followed by a few questions which define what goes into the database.

Next time, the program can reply with something like:

Program: Oh really - I only have a budgie called Tweety. Or...
Program: Cool - What do you feed your Ostrich?

If Ostrich is listed as an animal in the database, then you know you can ask what it is fed on - or select another 'animal' from the database to say that the program has.

TDK_Man

alien master
16
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 25th Jun 2007 05:02 Edited at: 25th Jun 2007 05:03
Well for one ive been gone all day LOL SIX FLAGS!!!!

so im sorry i know what that is.. i just uploaded this before i left...and on the way to six flags i was thinking of ways i could improve it and SNAP
or

i was like OMFG lol THAT WILL SAVE ME A LOT OF TIME

Alienmaster
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 25th Jun 2007 05:05
Except it is


42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jun 2007 08:36
Quote: "TDK: if you need to do any work on the string then everyone knows that uppercase 'A' has an ASCII code of 65"

That's a good point, and it would make the key words stand out when they are recalled! And... there's no need to worry about formatting for names or abbreviations.
Just goes to show how many choices there are to make lol.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jun 2007 09:33
I have a strange feeling that recursive functions would be very useful for this one, but I don't really know how to implement them.
Can anyone help?

What sort of thing is everyone thinking of doing?
I'm trying for a learning bot that remembers how things are related to each other.

If I'm posting a lot it's because I'm still a noob on the forum system. How long does it take to get instant posting? (I've been on a year but only just started posting)
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 25th Jun 2007 19:32 Edited at: 25th Jun 2007 19:42
In my experience, it takes maybe 5-10 posts. Make sure to use the "Edit Post" link instead of double posting though.

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jun 2007 00:22
Quote: "NinJA999: Make sure to use the "Edit Post" link instead of double posting though."


OK, will do in future, sorry didn't see that option .

(Testing to see whether my post time is when I posted it. Posted At: 22:22)
NinJA999
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: NH
Posted: 26th Jun 2007 04:46
Interesting...When you posted it, it showed up in my mailback, but not on the page until it was moderated...

42
http://www.nictitatingrabbit.com
http://penchantpages.nictitatingrabbit.com

Login to post a reply

Server time is: 2024-05-03 17:13:28
Your offset time is: 2024-05-03 17:13:28