My one-line guess the number game with feedback in Family BASIC - New topic

Started by childishbeat, April 18, 2020, 04:10:51 am

Previous topic - Next topic

childishbeat

Old topic: https://famicomworld.com/forum/index.php?topic=14576.0
Yesterday, I managed to make the grammar I wanted to use in my one-line guess the number game with feedback in Family BASIC fit in the game's code. Even with the extra size the new grammar required, I managed to reduce the code from 245 characters to 138 characters (that's less than the previous maximum length of a Tweet as of this comment's original posting, which is 140 characters; also as of this comment's posting, the current maximum length of a Tweet is 280 characters), a reduction of 107 characters. Here's the old grammar compared with the new grammar:
Old grammarNew grammar
RIGHT.CORRECT.
TOOLOW.TOO LOW.
TOOHIGH.TOO HIGH.
And here's the old code compared with the new code:
Old code:
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.New code:
0N=RND(10)+1:DIMT$(2):T$(0)="CORRECT.":T$(1)="TOO LOW.":T$(2)="TOO HIGH.":F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:?T$(-(G>N)-T):N.But can I reduce the length of the code further, and if so, how? I've mostly experimented with finding a working shorter version of -(G>N)-T, which is how which outcome for the program to say is calculated, but have only failed to find such a solution so far.