[Help] My guess the number game one-liners in Family BASIC

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
childishbeat
Posts: 7
Joined: Sun Aug 18, 2019 2:17 pm

[Help] My guess the number game one-liners in Family BASIC

Post by childishbeat » Mon Aug 19, 2019 9:02 am

How can the following code be reduced in characters while still being all in one line, as well as, with the "With too low/too high feedback" code, have a space between the words TOO and LOW, as well as the words TOO and HIGH, without a space being rendered along with the winning text (CORRECT, which I changed to RIGHT due to Family BASIC having maximum characters on one line limitations)? (I've asked both questions on the Famicom World forum (At http://famicomworld.com/forum/index.php?topic=14558.0 and http://famicomworld.com/forum/index.php?topic=14576.0 respectively.), but no one's even responding to them. I also tried asking for help at AtariAge (http://atariage.com), but I had issues with the required sections to post a new topic.):
Without too low/too high feedback (97 characters)

Code: Select all

0N=RND(10)+1:F.I=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:I=G<>N:?CHR$(I*-73)CHR$(I*-78)"CORRECT.":N.
With too low/too high feedback (245 characters)

Code: Select all

0N=RND(10)+1:F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:L=G<N:H=G>N:R=G=N:A=T*-79:B=H*-71:C=R*-71:?CHR$(A+5)CHR$(A)CHR$(A)CHR$(L*-76)CHR$(L*-79)CHR$(L*-87)CHR$(B+1)CHR$(B+2)CHR$(B)CHR$(B+1)CHR$(C+11)CHR$(C+2)CHR$(C)CHR$(C+1)CHR$(C+13)".":N.
Here are some examples of Family BASIC code to hopefully help you help me reduce the "With too low/too high feedback" code in characters because I've attempted to use them, all in failure (along with the names of their distinct differences):
Changed math

Code: Select all

0N=RND(10)+1:F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N*-79:L=G<N:H=G>N*-71:R=G=N*-71:?CHR$(T+5)CHR$(T)CHR$(T)CHR$(L*-76)CHR$(L*-79)CHR$(L*-87)CHR$(H+1)CHR$(H+2)CHR$(H)CHR$(H+1)CHR$(R+11)CHR$(R+2)CHR$(R)CHR$(R+1)CHR$(R+13)".":N.
Prints legibly and uses for loops

Code: Select all

0N=RND(10)+1:F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:L=G<N:H=G>N:R=G=N:F.X=0TOLSTEP1:?"TOO LOW.":N.:F.Y=0TOHSTEP1:?"TOO HIGH.":N.:F.Z=0TORSTEP1:?"CORRECT.":N.:N.
Uses DATA and READ in a for loop

Code: Select all

0N=RND(10)+1:F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:L=G<N:H=G>N:R=G=N:A=T*-79:B=H*-71:C=R*-71:0F.S=1TO15:DATAA+5,A,A,L*-76,L*-79,L*-87,B+1,B+2,B,B+1,C+11,C+2,C,C+1,C+13:READS:?CHR$(S);:N.:?".":N.

User avatar
zeroone
Posts: 934
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: [Help] My guess the number game one-liners in Family BAS

Post by zeroone » Mon Aug 19, 2019 1:33 pm

Why only 1 line?

childishbeat
Posts: 7
Joined: Sun Aug 18, 2019 2:17 pm

Re: [Help] My guess the number game one-liners in Family BAS

Post by childishbeat » Mon Aug 19, 2019 4:31 pm

zeroone wrote:Why only 1 line?
I'm challenging myself to make those two guess the number one-liners in as little code in Family BASIC as possible.

User avatar
tokumaru
Posts: 11766
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [Help] My guess the number game one-liners in Family BAS

Post by tokumaru » Mon Aug 19, 2019 5:49 pm

But once you go asking for help you're no longer challenging yourself, are you? :lol:

childishbeat
Posts: 7
Joined: Sun Aug 18, 2019 2:17 pm

Re: [Help] My guess the number game one-liners in Family BAS

Post by childishbeat » Tue Aug 20, 2019 6:18 am

tokumaru wrote:But once you go asking for help you're no longer challenging yourself, are you? :lol:
I allow myself to ask other living beings if I'm stuck somewhere in that challenge, and, as of this comment's posting, I currently am stuck somewhere in that challenge.

User avatar
zeroone
Posts: 934
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: [Help] My guess the number game one-liners in Family BAS

Post by zeroone » Tue Aug 20, 2019 6:36 am

childishbeat wrote:
zeroone wrote:Why only 1 line?
I'm challenging myself to make those two guess the number one-liners in as little code in Family BASIC as possible.
I was kind of hoping that someone was running a Family BASIC contest or code golf. 1-line challenges in a multitude of languages have been around for ages. And the problem has always been that it's difficult to define line length. These days I usually see things like "an entire program that fits into a single tweet" instead. But I played around with Family BASIC a few years back and I remember the editor having a lot of difficulty with long lines. If I remember correctly, it wasn't about the number of characters; rather, it seemed to have a cap on the number of parsed elements/tokens.

On a related topic, have you coded up anything really interesting in Family BASIC? Has anyone really pushed the boundaries of it? Any cool games?

childishbeat
Posts: 7
Joined: Sun Aug 18, 2019 2:17 pm

Re: [Help] My guess the number game one-liners in Family BAS

Post by childishbeat » Wed Aug 21, 2019 1:12 am

zeroone wrote:
childishbeat wrote:
zeroone wrote:Why only 1 line?
I'm challenging myself to make those two guess the number one-liners in as little code in Family BASIC as possible.
I was kind of hoping that someone was running a Family BASIC contest or code golf. 1-line challenges in a multitude of languages have been around for ages. And the problem has always been that it's difficult to define line length. These days I usually see things like "an entire program that fits into a single tweet" instead. But I played around with Family BASIC a few years back and I remember the editor having a lot of difficulty with long lines. If I remember correctly, it wasn't about the number of characters; rather, it seemed to have a cap on the number of parsed elements/tokens.

On a related topic, have you coded up anything really interesting in Family BASIC? Has anyone really pushed the boundaries of it? Any cool games?
Well, as anyone can always help me reduce the length of some code and render a space between the words TOO and LOW, as well as the words TOO and HIGH, without a space being rendered along with the winning text, this is kind of like a contest, like a contest ongoing forever.

And yes, I've made something interesting in Family BASIC: a game using text-based "graphics" where the goal is to make a ball collect all 545 apples. Here's the source code:

Code: Select all

10 CLS
20 X=1
30 Y=1
40 PRINT CHR$(222);
50 FOR I=1 TO 26
60 PRINT CHR$(227);
70 NEXT
80 PRINT CHR$(223);
90 FOR I=1 TO 21
100 PRINT CHR$(226);
110 FOR J=1 TO 26
120 PRINT CHR$(215);
130 NEXT
140 PRINT CHR$(226);
150 NEXT
160 PRINT CHR$(224);
170 FOR I=1 TO 26
180 PRINT CHR$(227);
190 NEXT
200 PRINT CHR$(225);
210 PRINT "APPLES";
220 LOCATE 6,23
230 PRINT APPLES;
240 LOCATE X,Y
250 PRINT CHR$(207)
260 IF APPLES=545 THEN CLS: END
270 I$=INKEY$
280 IF I$=CHR$(29) THEN IF X>1 THEN X=X-1: LOCATE X+1,Y: GOTO 330
290 IF I$=CHR$(28) THEN IF X<26 THEN X=X+1: LOCATE X-1,Y: GOTO 330
300 IF I$=CHR$(31) THEN IF Y<21 THEN Y=Y+1: LOCATE X,Y-1: GOTO 330
310 IF I$=CHR$(30) THEN IF Y>1 THEN Y=Y-1: LOCATE X,Y+1: GOTO 330
320 GOTO 240
330 IF SCR$(X,Y)=CHR$(215) THEN APPLES=APPLES+1
340 PRINT " "
350 GOTO 220

User avatar
zeroone
Posts: 934
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: [Help] My guess the number game one-liners in Family BAS

Post by zeroone » Wed Aug 21, 2019 6:20 am

Cool program. I collected all the apples :)

childishbeat
Posts: 7
Joined: Sun Aug 18, 2019 2:17 pm

Re: [Help] My guess the number game one-liners in Family BAS

Post by childishbeat » Thu Aug 22, 2019 6:56 am

zeroone wrote:Cool program. I collected all the apples :)
Oh yeah, and I made the source code of that apple-collecting game myself, finding that source code at http://famicomworld.com/forum/index.php?topic=14548.0. But I think this topic is getting off track to answering my question, and should be getting on track to answering my question instead.

Post Reply