News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

BASIC 10Liners 2017

Started by darkdog, 21:53, 30 January 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darkdog

BASIC 10Liners 2017 is starting now  ;D

http://gkanold.wixsite.com/homeputerium/basic-10liners-2017

Would love to see a lot of CPC 10Liners

AMSDOS

#1
I've prepared a condensed letter alphabet here which anyone is welcome to use, it uses 3 Lines of code (most of the 1st line is a simple demonstration). I haven't got any numbers, but I could possibly add those without any additional Lines I think or could even just use numbers in 2 lines of code.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

@darkdog I was hoping you could clarify this following rule?:


Quote- all the code must be visible in the listing: self modifying code or hidden initialization is not allowed


I Understand part of the rule relates to hidden line numbers not being allowed when the "LIST" command is used, but I'm not sure what this hidden initialization means. For example, the game I've written blanks the screen inks briefly while drawing some graphics, the inks are then reset. Do you know if this is what their referring to as not allowed? If so, I can easily remove it.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

andycadley


I think it's more referring to initialising variables and such outside of the program listing. On some variants of BASIC, such as Sinclair BASIC, the value of variables gets saved with a program and will therefore be present after loading. So you can do things like:


10 PRINT a


then, in immediate mode type:


LET a = 1000
SAVE "a.bas" LINE 10


and you have a 1 line BASIC program that mysteriously prints a value of 1000 when you load it yet fails with a variable not found error if you subsequently RUN it (since RUN clears variables). It's not hard to imagine how this could be used to get around the 10 line restriction somewhat.

AMSDOS

#4
Yes, I found it documented in the ZX81 manual. As you said RUN clears the variables, so you use GOTO instead after you've loaded your program. My program sets up a couple of lines of string array's & also some data assigned from strings, to have that all predefined outside the program would be an advantage, anyhow I've managed to squeeze it all into 10 Lines.


I think the judges would become somewhat suspicious if they had to run a whole heap of programs using GOTO though, given RUN is the standard BASIC command for running a program.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

1024MAK

To be fair, it should be pointed out that the BASIC version used on the ZX81 only allows one command per line.
So the following line is not valid on a ZX81:-
10 LET A=1 : LET B=2

Mark
Looking forward to summer in Somerset :-)

andycadley


Quote from: AMSDOS on 09:11, 05 February 17
I think the judges would become somewhat suspicious if they had to run a whole heap of programs using GOTO though, given RUN is the standard BASIC command for running a program.
On the ZX81, perhaps. On the Spectrum though you can save the program with the LINE option and it will automatically start at the right place without clearing the variables (i.e. as if you'd done a GOTO), making the implicit set-up potentially less obvious. It's quite possible that other BASIC dialects would behave similarly even with a RUN command, 80's BASIC implementations were sometimes quirky in this regards after all.

darkdog

I think, this discussion clarified the question. The mentioned rule refers to Sinclair BASIC for ZX Spectrum.

AMSDOS

Great, that answers my query. :)
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

roudoudou




I sent my participation  8)
My pronouns are RASM and ACE

AMSDOS

Have sent mine through, though I haven't sent a screenshot along with it, so hopefully it'll be on display soon.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

darkdog

Quote from: AMSDOS on 07:19, 09 February 17
Have sent mine through, though I haven't sent a screenshot along with it, so hopefully it'll be on display soon.

Are you "Out Bush"? ;D

AMSDOS

Quote from: darkdog on 22:53, 09 February 17
Are you "Out Bush"? ;D


I wish, though funnily enough yes.  8)
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

roudoudou

Quote from: AMSDOS on 09:09, 10 February 17

I wish, though funnily enough yes.  8)


Cool to see your condensed alphabet in action!  8)
My pronouns are RASM and ACE

AMSDOS

Quote from: roudoudou on 10:05, 10 February 17

Cool to see your condensed alphabet in action!  8)


Yeah, I have been working on another game today for this comp. At the moment it looks like I might be able to submit it as a PUR-120, but if I use the condensed characters again, it may make it an EXTREM-256, it's hard to say because I don't need the numbers for this game and possibly less characters.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Sykobee (Briggsy)

Is there anything in the rules about sharing entries (screenshots, dsks) elsewhere, or is it solely for the competition until the results are announced?


Anyway, I actually have something that works, in ten lines :o - yeah, i started it for the competition previous, then life happened, but it's done now.


But I have to do that annoying 'write it one instructions per line' thing now. Luckily there's no GOTOs or GOSUBs. Locomotive BASIC really limits you with it's IF-THEN-ELSE-NEVERENDIF construct doesn't it!


I had to switch to an ancient Arnold on Mac to test - JavaCPC was running at 10fps. :/

darkdog

Quote from: Sykobee (Briggsy) on 17:10, 12 February 17
Is there anything in the rules about sharing entries (screenshots, dsks) elsewhere, or is it solely for the competition until the results are announced?


Anyway, I actually have something that works, in ten lines :o - yeah, i started it for the competition previous, then life happened, but it's done now.


But I have to do that annoying 'write it one instructions per line' thing now. Luckily there's no GOTOs or GOSUBs. Locomotive BASIC really limits you with it's IF-THEN-ELSE-NEVERENDIF construct doesn't it!


I had to switch to an ancient Arnold on Mac to test - JavaCPC was running at 10fps. :/

Sorry to annoy you with the new rule.

Some people release it before the deadline some are waiting until the end of the contest. Both is ok.
Curious about your game...

Sykobee (Briggsy)


Luckily it's not too difficult on a modern computer :-)For the deconstructed listing - is it helpful to add comments that aren't in the 10-liner?
As one of the aims is to get newbies programming, it might help to see what the variables, etc, are?

Sykobee (Briggsy)

#18
Emailed :-)

It's a Roguelike-Viewpoint Gold Collect-em-up (Grinding) with Monsters you can kill if you want (they can kill you too but it'll take some time).

AMSDOS

Quote from: darkdog on 21:20, 12 February 17
Sorry to annoy you with the new rule.

Some people release it before the deadline some are waiting until the end of the contest. Both is ok.

I think other programming competitions which have been done in the past through the forum have been strict when it comes to making the programs available. On your website, I've noticed previous years entries are available through Dropbox, but this years entries haven't been made available, which gave me the impression that you're not releasing the programs as yet, so I didn't release mine in case I'd be forfeiting, even though I noticed games like Brickhunter had it's source code released on that machines forum, I was sure if that program was still in WIP stage.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Sykobee (Briggsy)

Yeah, that's why I asked :-)


It's nice if the code is available after the competition, so we can port them. I remember last year there was that dev competition that was demanding previously unannounced entries which I found odd.


I was surprised to get to over line 1300 when I deconstructed the ten liner (albeit with a few added comments)!


My learning from this competition is to avoid IF as much as possible. E.g., instead of: "IF map[x,y]=3 THEN gold=gold+1" use "gold=gold-(map[x,y]=3)" because you can then have more statements on that line that are unrelated to the IF. This works well with INKEY too, nx=ox-INKEY(right)+INKEY(left) checks keypresses and moves you. It's a shame that IF has no ENDIF to fix this. BBC BASIC has ENDIF, but it is optional, and requires multiple lines to work (and thus is horribly unsuitable for this competition).


Also keep notes of your variable use, as you have 26 single char variable names (52 on the CPC - ints and str$ - can any other symbols be used?) which is usually enough for 10 liners. And on the CPC it appears that single character variables use less BASIC tokens than multiple character variables, and there is a BASIC token limit per line, not just a character limit (I ran into Line Too Long errors way before hitting the character limit, and i fixed some by switching to single character variables).

AMSDOS

Quote from: Sykobee (Briggsy) on 12:01, 13 February 17
I was surprised to get to over line 1300 when I deconstructed the ten liner (albeit with a few added comments)!


Well I can't wait to check it out (hopefully in April).  :D  You'd be surprised to know my Silly Guessing Game is slightly bigger than that.  :o


QuoteMy learning from this competition is to avoid IF as much as possible. E.g., instead of: "IF map[x,y]=3 THEN gold=gold+1" use "gold=gold-(map[x,y]=3)" because you can then have more statements on that line that are unrelated to the IF. This works well with INKEY too, nx=ox-INKEY(right)+INKEY(left) checks keypresses and moves you. It's a shame that IF has no ENDIF to fix this. BBC BASIC has ENDIF, but it is optional, and requires multiple lines to work (and thus is horribly unsuitable for this competition).


Also keep notes of your variable use, as you have 26 single char variable names (52 on the CPC - ints and str$ - can any other symbols be used?) which is usually enough for 10 liners. And on the CPC it appears that single character variables use less BASIC tokens than multiple character variables, and there is a BASIC token limit per line, not just a character limit (I ran into Line Too Long errors way before hitting the character limit, and i fixed some by switching to single character variables).


Unfortunately my game relies heavily on IF statements and the one I'm working on now also has lots of them as well as variables 2 bytes long, mainly name to help give meaning, so yeah I'm too lazy to write on a sheet of paper what each variable is for like what the magazines used to do back in the early days, so it'll be interesting to see how well they go when the results are announced. Earlier I was looking at the MAX & MIN functions to see if I could use those to any benefit, but to no avail. Only problem I've encountered with IF in my programs was it I was in a Loop, there's just no way of having the loop work properly once I've initiated an IF condition, and I even tested this with ELSE to see if that would work.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Sykobee (Briggsy)

If it fits in 10 lines then all's good :-)
To fix the FOR .. IF .. NEXT issue, put the NEXT on the next line. WHILE .. WEND is another useful construct for game loops instead of IF .. GOTO.
I developed in Arnold so I had my notes on screen. TBH I haven't tested on the real hardware, my key choices could be a problem...

AMSDOS

Quote from: Sykobee (Briggsy) on 13:12, 14 February 17
If it fits in 10 lines then all's good :-)


For my Silly Number Guessing Game, I just managed to make it work in 10 Lines  :laugh: 


I don't know if I'll score points for writing it structurally, I think writing it without one GOTO being in there is a fair achievement, the game itself is just a simply computer selecting a random number and you have to get lucky by matching the musical note played at the start of it with your musical number increment device, the use of sound was a last minute idea, but implementing the condensed character/number set & calculating to display the correct numbers was a bit more complicated, I also found a bit of a bug (not a BASIC error), but numbers not adjusting accordingly, fortunately I was able to resolve that too before sending it in.  :D  My other game is almost complete, but I've got 1 Line I don't know what to do with it, perhaps like my other game put a graphical character on the screen.

QuoteTo fix the FOR .. IF .. NEXT issue, put the NEXT on the next line. WHILE .. WEND is another useful construct for game loops instead of IF .. GOTO.


Yeah sorry, that was what I was trying to lead to for the FOR...IF...NEXT issue, it's a little bit annoying that once the IF is setup in the Loop, if you don't get it close to the 256 Character limit, you're forced into placing your NEXT on the next line. Yes, I've used WHILE...WEND in some of my Pascal examples if I need to exit without executing a bunch of code.

QuoteI developed in Arnold so I had my notes on screen. TBH I haven't tested on the real hardware, my key choices could be a problem...


I just use the Cursor Keys, Space, so there's no problems for me when I test on an emulator or the real computer.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

darkdog

Quote from: AMSDOS on 09:54, 15 February 17


I don't know if I'll score points for writing it structurally, I think writing it without one GOTO being in there is a fair achievement,

The jury contents of 7 members. All of them are interested in more than one 8 bit platform. Some of them are gamers, some are (basic-)programmers. The look on the games will differ. Elegant programming will be noticed und appreciated by the coders among the jury.

Powered by SMFPacks Menu Editor Mod