20 Line Programming Challenge

Anything QL Software or Programming Related.
User avatar
dilwyn
Mr QL
Posts: 3118
Joined: Wed Dec 01, 2010 10:39 pm

Re: 20 Line Programming Challenge

Post by dilwyn »

Just to stay one step ahead of Mr Navigator :D here's another effort. This is a Guess The Animal game where you have to think of an animal and the computer tries to guess it. As it fails to guess the answer it asks more questions to help it distinguish between the various animals, e.g. does it go moo would have na answer of y for yes for a cow but no for a pig. The longer you play it, the bigger the database becomes and the better it becomes at guessing everything. If the facility to save the database was added (aw, come on, i'm only allowed 20 lines!) it would rapidly build up a good knowledge of the animal world. Trivial as it stands, I guess it could be taught to ask medical questions to become an expert at diagnosing illnesses by asking all sorts of Yes/No questions. It's adapted from a much longer program I wrote back in 1985 IIRC :roll:

Code: Select all

100 REMark Guess The Animal: think of an animal,computer guesses it
110 CLS : CLS #0 : DIM question$(50,56),p(50,2) : free = 2
120 question$(1)='a monster' : num=1 : REMark start from somewhere,I suppose
130 PRINT'Think of an animal, computer will try to guess it and learn from replies.'\\
140 REPeat ask
150   IF p(num,1) = 0 THEN
160     PRINT'Is it ';question$(num);'?'
170     IF INKEY$(-1)=='y' THEN
180       PRINT'I knew that!'\\'Think of an animal' : REMark a correct guess
190     ELSE
200       question$(free) = question$(num) : INPUT'What was it?';question$(free+1)
210       INPUT'Enter a question to distinguish between them:';question$(num)
220       PRINT'What is the answer for ';question$(free+1);'?'
230       IF INKEY$(-1) == 'y' THEN p(num,1) = free + 1 : p(num,2) = free:ELSE p(num,1) = free : p(num,2) = free+1
240       free = free + 2 : PRINT'A new one!'\\'Think of an animal'
250     END IF : num = 1
260   ELSE
270     PRINT question$(num);'?' : IF INKEY$(-1) == 'y' THEN num = p(num,1) : ELSE num = p(num,2)
280   END IF
290 END REPeat ask
animals.jpg


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: 20 Line Programming Challenge

Post by Mr_Navigator »

Hey DJ, it's not a competition you know...









oh wait a minute, yes it is :lol:


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
vanpeebles
Commissario Pebbli
Posts: 2853
Joined: Sat Nov 20, 2010 7:13 pm
Location: North East UK

Re: 20 Line Programming Challenge

Post by vanpeebles »

I think you're getting beaten up a bit :lol:


RWAP
RWAP Master
Posts: 2893
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: 20 Line Programming Challenge

Post by RWAP »

A guess the animal program was even sold as a commercial title back in the day !

It was however, written in Archive BASIC - see http://www.rwapadventures.com/ql_wiki/i ... AL&lang=en

Now if only I had time to do some QL programming - I am sure we could manage a cut down space invaders in 20 lines... (although it would be slow...!)


User avatar
dilwyn
Mr QL
Posts: 3118
Joined: Wed Dec 01, 2010 10:39 pm

Re: 20 Line Programming Challenge

Post by dilwyn »

My original was on a PD disk from CGH Services.
There was an expanded version and databases, but I can't get the disk to fully read on my PC.
If I can get my ED drives and QL set up, I might be able to copy and rescue it and put it on my website as I don't think it's there already.
At the time, there was a lot of Animal-type program listings as there was a lot of interest in AI-type programs back then (not that this one is in any way intelligent!)
Space Invaders in 20 lines, now there's a challenge... :geek:
Get out the old ZX81 books and adapt a 1K space invaders, that should be fun.

Dilwyn


thorsinclair
Trump Card
Posts: 209
Joined: Mon Jan 10, 2011 5:08 pm

Re: 20 Line Programming Challenge

Post by thorsinclair »

Hi all,

Congratulations to the programmers! Very well done and very interesting. To support your efforts, today I sat down for a couple of hours and pixeled the original Space Invader Sprites - as can be found in the original Arcade Edition - using DP's Super Sprite Generator. I was doing this on QEmulator on my Mac and it was a bit of a mess as the screen is not always looking as it should, but anyway, it was also great fun. I try to post the sprites, partly animated, attached as a ZIP file and I hope that somebody can pick them up and do the real deal - coding the game :mrgreen:
.... just found the original artwork of Galaga .... hmmm .. worth a try I think.

I would be interested if DPs Super Sprite Generator is the best tool to create animated sprites with frames etc. or if there is a better piece of software around. Can somebody let me know? Thanks.
Best,
Thor
Space Invaders Sprites.zip
Space Invaders Sprites
(15.42 KiB) Downloaded 343 times


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: 20 Line Programming Challenge

Post by Mr_Navigator »

I found problems running this software on Qemulator, the X-axis was jumping by 4 pixels at a time, how does yours fair?

See
http://www.theqlforum.com/viewtopic.php? ... ator#p764


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
thorsinclair
Trump Card
Posts: 209
Joined: Mon Jan 10, 2011 5:08 pm

Re: 20 Line Programming Challenge

Post by thorsinclair »

I just did the artwork Job with this sprites using the Design and Construct programs. I tried the Demo program and noticed that it is flickering a lot which apparently is caused by the 4 pixels a time movements you have experienced. It's far from smooth movements ... Do you know any other sprite packages you know of?

Cheers
Thor


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: 20 Line Programming Challenge

Post by Mr_Navigator »

I am afraid not as I would like to do more in this area but SSG doesn't cut the mustard for me RWAP did mention at one point I think, that there were other(s). However this is going off topic for the post :)


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
thorsinclair
Trump Card
Posts: 209
Joined: Mon Jan 10, 2011 5:08 pm

Re: 20 Line Programming Challenge

Post by thorsinclair »

Yes, this gos off topic and I have just created a new thread, let's go there. I have always some spare time to do some pixel work on sprites, just started to do some Galaga bees ;)
Just looking for somebody who could do the coding. Would be cool to create a nice retro arcade game for the QL!

Best,
Thor


Post Reply