2
\$\begingroup\$

The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high.

Each line has to render below the previous line for me to accept the solution as the new code for the game (However, you can still share any solutions that break that rule.). For example, no lines can be rendered over other lines, such as "CORRECT." over "TOO LOW." or "TOO HIGH.".

Here's the 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.

As for how I'm running NS-HUBASIC code, I'm doing it in Family BASIC V3.0, which I'm running under Nestopia v1.40.

If you need any documentation, you can find it here: https://gamefaqs.gamespot.com/nes/938747-family-basic-v3/faqs/59317

\$\endgroup\$
4
  • 4
    \$\begingroup\$ I estimate a quite small number of NS-HUBASIC coders here. Maybe you could recommend some online documentation and/or environment/emulator so others could try jumping in. \$\endgroup\$
    – manatwork
    Apr 24, 2020 at 14:23
  • \$\begingroup\$ Where is the online documentation for NS-HUBASIC? \$\endgroup\$
    – user92069
    Apr 24, 2020 at 14:29
  • \$\begingroup\$ I just added a link to some documentation for NS-HUBASIC, which is online, to the initial post. But here's the link here (I hope it'll make it more convenient for you to find the link): gamefaqs.gamespot.com/nes/938747-family-basic-v3/faqs/59317 \$\endgroup\$
    – Niall Ward
    Apr 24, 2020 at 14:54
  • \$\begingroup\$ The ROM can be tried online here, but it seems to be complaining about the keyboard not being plugged and I don't think there's a way to enable it in this emulator. (Or is it?) \$\endgroup\$
    – Arnauld
    Apr 24, 2020 at 16:39

1 Answer 1

2
\$\begingroup\$

 134  133 characters

Note: I don't know for sure whether a line-break counts as 1 character.

0N=RND(10)+1:DIMT$(2):T$(0)="TOO LOW.":T$(1)="CORRECT.":T$(2)="TOO HIGH."
1I."WHAT'S MY NUMBER? (1-10) ",G:?T$(SGN(G-N)+1):IF G-N T.1

Example output

output

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I also asked this question at NesDev (I had found no answers where I had asked it before (NesDev (Link) and Famicom World (Link 1) and (Link 2) are those places), so I asked it at StackOverflow). Controllerhead there helped me get here, down from 133 characters to 131 characters. Code: 0N=RND(10)+1:F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:RES.0:F.I=0TO(-(G>N)-T):READC$:N.:?C$:N.:D.CORRECT.,TOO LOW.,TOO HIGH. \$\endgroup\$
    – Niall Ward
    Apr 24, 2020 at 22:24
  • 1
    \$\begingroup\$ @NiallWard I clearly couldn't have gone that far, as the above code snippet is the first (and perhaps the last) thing I ever wrote in this language. :-) \$\endgroup\$
    – Arnauld
    Apr 25, 2020 at 7:40
  • 1
    \$\begingroup\$ I thank you, Controllerhead and anyone else who may have helped me get the program to the length it's at now for the help. \$\endgroup\$
    – Niall Ward
    Apr 25, 2020 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.