1

I made a Tycoon script for TI-84 Plus CE and I don't think it's really good. I'm not that good at calculator programming and I don't know much. I just learned some from a friend and a couple YouTube videos.

I was wondering, does anyone know how I can improve this script to make it better?

Here's what I have:

Btw the -> is the STO key.

:ClrHome
:13->S
:5->T
:13->X
:5->Y
:0->B
:5->C
:1->D
:Output(T,S,"CASH:"
:Output(Y,X,"M"
:getkey->A
:X->S
:Y->T
:If A=26
:Then
:X+1->X
:If X=27
:26->x
:End
:If A=34
:Then
:Y+1->Y
:If Y=11
:10->Y
:End
:If A=25
:Then
:Y-1->Y
:If Y=1
:2->Y
:End
:If A=11
:Then
:Stop
:End
:If X=D and Y=C
:Then
:B+1->B
:Output(1,6,B
:End
:If B≥200
:Then
:6->E
:1->F
:Output(E,F,"5"
:End
:If X=F and Y=E and B≥200
:Then
:B+5->B
:Output(1,6,B
:End
:If B≥1500
:Then
:7->G
:1->H
:Output(G,H,"10"
:End
:If X=H and Y=G and B≥1500
:Then
:B+10->B
:Output(1,6,B
:End
:End
Chillie
  • 1,030
  • 10
  • 28
  • 2
    I'm voting to close this question as off-topic because it might better belong to codereview.stackexchange.com (assuming it is working correctly), in case not, it should be stated what needs to be improved, what is the problem. – Gábor Bakos Feb 09 '17 at 06:40

1 Answers1

2

Future questions of this nature should be asked at codereview.SE, but I'll take a look at some optimizations for you anyway.

I will only be looking for optimizations in size, not speed (although they may make your program faster). Here are some:

  • First off, four of these lines can have their end quotes removed (-4)
  • 0->B:5->C can be DelVar B5->C (you can remove the following colon) (-1)
  • You don't need a Then or End with your If statement if the condition is one line. So, :If A=11:Then:Stop:End can just be :If A=11:Stop (-4)

Now for the major optimizations I see:

First, and perhaps more obvious, is the fact that you call :Output(1,6,B a lot. It looks like you can just move this outside your If block, and remove the Then and End for -4 bytes each

Second, which you may not have known about, are the min( and max( commands, which return the smaller or larger of two values or of a list, respectively. Here's an example:

:If A=26
:Then
:X+1->X
:If X=27
:26->X
:End

The above code is equivalent to:

:If A=26
:min(26,X+1->X

It looks like you can use this optimization four times, which is significant because it makes the program smaller, faster, and more readable.

Overall, I hope I was able to help you. If you have any questions at all, please ask :)

Timtech
  • 1,224
  • 2
  • 19
  • 30
  • while that optimization did help me, the point of the question was if there was a way to make the actual tycoon any better with the function of the tycoon. – Pyro Necrion Feb 14 '17 at 22:21
  • 1
    Well see, I am being objective in my answer -- you are requesting something more subjective (i.e. what is better?). Since you haven't told me what is "better" (other than faster/smaller which I addressed), I can't do any more but guess. And, if you have those ideas you can always try them yourself too :) glad I could help somewhat – Timtech Feb 14 '17 at 23:58