Author Topic: QB64 10-Liner programs or games  (Read 3584 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline Kiara87

  • Forum Regular
  • Posts: 164
QB64 10-Liner programs or games
« on: March 20, 2022, 07:21:12 pm »
I was checking on google if it is possible to create any program with a few lines of code and the answer is yes
some old BASIC programmers competing link ---> https://gkanold.wixsite.com/homeputerium
other 
https://github.com/Fabrizio-Caruso/10-LINERS-2020
https://github.com/Fabrizio-Caruso/Mines
https://github.com/Fabrizio-Caruso/CBM-BASIC-10-liners
it is also so nice even if you create a page of how to create programs in qb64 with a few lines of code and then reuse it using it as a reference

without any competition

I remember in the years 82 or 85 an Italian magazine was published with the name  Commodore Computer Club from magazine number 20 to number 33
who is Italian remembers this magazine and who used the basic
https://ready64.org/ccc/pagina.php?ccc=20&pag=012.jpg
https://ready64.org/ccc/pagina.php?ccc=20&pag=013.jpg

there was also an encyclopeptia of rutine
https://ready64.org/ccc/pagina.php?ccc=24&pag=017.jpg
https://ready64.org/ccc/pagina.php?ccc=24&pag=018.jpg
with its rules
all using a few code characters
they also explained the rules to be respected
returning to the subject of complete 10-line programs and functioning programs or games  --> https://gkanold.wixsite.com/homeputerium

they cannot use more than 80 characters
and they cannot use more than 10 if conditions
and other rules they use

I don't want to compete with anyone
I would like to create a one page idea in the forum
with small programs of a few lines

as i mentioned in commodore computer club magazine
like this --> https://ready64.org/ccc/pagina.php?ccc=21&pag=012.jpg
https://ready64.org/ccc/pagina.php?ccc=21&pag=013.jpg
here you will find all the magazines to those interested   in Italian language ---> https://ready64.org/ccc/index.php
but the ones that deal with one-line code topic are from number 20 to number 33
all the magazines of Commodore Computer Club n. 20 at the  Commodore Computer Club n. 33

the purpose was to create small programs to use
Is it possible to create a page suitable for creating small programs to be reused as a second qb64 wiki?
What do you think about it?


for those interested in Italian magazines that talk about a line of code, here is the link --> https://www.mediafire.com/folder/8c8emsc0dr6qp/Commodore_compiuter_club

kind regards
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: QB64 10-Liner programs or games
« Reply #1 on: March 20, 2022, 08:02:14 pm »
You mean something like this?

Code: QB64: [Select]
  1. x$ = LTRIM$(STR$(INT(RND * 10 + 1)))
  2.     try = try + 1
  3.     LINE INPUT "Guess a number between 1 and 10. "; num$
  4.     IF x$ < num$ THEN j = 1 ELSE j = 10
  5.     IF num$ = x$ THEN EXIT DO ELSE PRINT MID$("Too high!Too Low!", j, 9)
  6. IF try = 1 THEN PRINT "You guessed it in 1 try!" ELSE PRINT "You guessed it in"; try; "tries!"

Pete

- I'm really more of a one-liner kind of guy.
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: QB64 10-Liner programs or games
« Reply #2 on: March 20, 2022, 08:14:26 pm »
You mean something like this?

Code: QB64: [Select]
  1. x$ = LTRIM$(STR$(INT(RND * 10 + 1)))
  2.     try = try + 1
  3.     LINE INPUT "Guess a number between 1 and 10. "; num$
  4.     IF x$ < num$ THEN j = 1 ELSE j = 10
  5.     IF num$ = x$ THEN EXIT DO ELSE PRINT MID$("Too high!Too Low!", j, 9)
  6. IF try = 1 THEN PRINT "You guessed it in 1 try!" ELSE PRINT "You guessed it in"; try; "tries!"

Pete

- I'm really more of a one-liner kind of guy.

yes exactly both programs and games of a few lines
that even beginners can understand
and also to reuse the pieces of code in other programs
as well as many people may have other ideas how to use the instructions both qb64 and also in quickbasic 4.5
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: QB64 10-Liner programs or games
« Reply #3 on: March 20, 2022, 08:48:02 pm »
Sure, libraries. For instance, I made a keyboard / mouse routine I can use in any program. Steve has one of a similar nature. I suppose if the community promoted library routines, eventually we would wind up adding OOP support to QB64. The push against that. and count me in as a big pusher, is that the spirit of BASIC is to build these routines, not just utilize them. If the community became divided over such philosophical differences, I would simply recommend doing what PowerBASIC did, simply split the project. Have an OOP version and a BASIC version. In regard to PB, that would be their PowerBASIC for WIndows vs PpwerBASIC for DOS.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: QB64 10-Liner programs or games
« Reply #4 on: March 20, 2022, 09:12:55 pm »
Yeah that's a true 9 liner without the double parking with colons.

Course that's not the shortest Guess Number I've seen...

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: QB64 10-Liner programs or games
« Reply #5 on: March 20, 2022, 09:48:36 pm »
@bplus Sure, but then it starts to get ugly...

Code: QB64: [Select]
  1. x$ = LTRIM$(STR$(INT(RND * 10 + 1)))
  2. 100 try = try + 1
  3. LINE INPUT "Guess a number between 1 and 10. "; num$
  4. IF x$ < num$ THEN j = 1 ELSE j = 10
  5. IF num$ <> x$ THEN PRINT MID$("Too high!Too Low!", j, 9)
  6. IF num$ = x$ THEN PRINT "Yes! Number of tires to guess it was:"; try ELSE GOTO 100
  7.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: QB64 10-Liner programs or games
« Reply #6 on: March 20, 2022, 10:02:35 pm »
I've got 4 lines but not counting trys.

Ugly is my 1 liner!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: QB64 10-Liner programs or games
« Reply #7 on: March 20, 2022, 10:09:33 pm »
I think it was Steve who came up with nice replacement for your lines 1 and 2.

The 4 liner does not count trys but does recycle a new game.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: QB64 10-Liner programs or games
« Reply #8 on: March 20, 2022, 10:24:19 pm »
And then it gets even uglier...

Code: QB64: [Select]
  1. x$ = LTRIM$(STR$(INT(TIMER) MOD 10 + 1))
  2. 100 LINE INPUT "Guess a number between 1 and 10. "; num$
  3. IF num$ = x$ THEN PRINT "Correct!" ELSE GOTO 100

Pete

PS Steve? This is the first for me. I don't believe I made a guess a number routine before this.

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
Re: QB64 10-Liner programs or games
« Reply #9 on: March 20, 2022, 10:29:49 pm »
nobody ask me why, but i just made a game in 10 lines. keep your mouse on the money to gain it, otherwise you lose it. your total is in the title

Code: QB64: [Select]
  1. 1 i = i + 1
  2.     x = INT((_WIDTH - 1) * (_MOUSEX / _WIDTH))
  3.     y = INT((_HEIGHT - 1) * (_MOUSEY / _HEIGHT))
  4. PRINT SPACE$(INT(_WIDTH / 2 - 10) * (1 + .25 * COS(i / 20) + .25 * SIN(i / 30))); "|"; STRING$(7 * (1 + ABS(COS(i / 10))), "$"); "|"
  5. IF (SCREEN(1 + y, 1 + x, 0) = 36) THEN t = t + 1 ELSE t = t - 1
  6. _TITLE "$:" + STR$(t)
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: QB64 10-Liner programs or games
« Reply #10 on: March 20, 2022, 10:44:10 pm »
@Pete Wow nice 3 liner!

@STxAxTIC now I know why money doesn't grow on trees, too busy riding down that river. Nice spontaneous game!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: QB64 10-Liner programs or games
« Reply #11 on: March 20, 2022, 10:57:45 pm »
Ha ha. SCREEN 0. Bill finally made it to the Dark Side.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: QB64 10-Liner programs or games
« Reply #12 on: March 21, 2022, 04:03:55 am »
Cool... "10 Liners"...  Back in the mid 80's I ran an Amstrad CPC464... 4mhz cpu with only 64K of ram...  Learning to program efficiently was the thing back then. In the magazines that I purchased were "10 liners". It was amazing, back then, that so much could be done with so little coding. Mind you, the CPC, was capable of having long lines of code... But still... amazing...
Logic is the beginning of wisdom.

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: QB64 10-Liner programs or games
« Reply #13 on: March 21, 2022, 04:50:10 am »
Sure, libraries. For instance, I made a keyboard / mouse routine I can use in any program. Steve has one of a similar nature. I suppose if the community promoted library routines, eventually we would wind up adding OOP support to QB64. The push against that. and count me in as a big pusher, is that the spirit of BASIC is to build these routines, not just utilize them. If the community became divided over such philosophical differences, I would simply recommend doing what PowerBASIC did, simply split the project. Have an OOP version and a BASIC version. In regard to PB, that would be their PowerBASIC for WIndows vs PpwerBASIC for DOS.

Pete

I don't mean object-oriented programming but only creating programs based on the imagination of each user using very few lines of code other people do it for competence but here it could be done without any competence open the imagination using the instructions so that beginners understand what they are for the instructions
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: QB64 10-Liner programs or games
« Reply #14 on: March 21, 2022, 04:52:51 am »
nobody ask me why, but i just made a game in 10 lines. keep your mouse on the money to gain it, otherwise you lose it. your total is in the title

Code: QB64: [Select]
  1. 1 i = i + 1
  2.     x = INT((_WIDTH - 1) * (_MOUSEX / _WIDTH))
  3.     y = INT((_HEIGHT - 1) * (_MOUSEY / _HEIGHT))
  4. PRINT SPACE$(INT(_WIDTH / 2 - 10) * (1 + .25 * COS(i / 20) + .25 * SIN(i / 30))); "|"; STRING$(7 * (1 + ABS(COS(i / 10))), "$"); "|"
  5. IF (SCREEN(1 + y, 1 + x, 0) = 36) THEN t = t + 1 ELSE t = t - 1
  6. _TITLE "$:" + STR$(t)

very well with your imagination you have created a program of a few lines what I meant
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione