Jump to content
xisto Community
Sign in to follow this  
KansukeKojima

Ti-basic --- Slot Machine

Recommended Posts

Description

 

Ok, so this is my first TI-BASIC tutorial. In this tutorial you will learn how to create a very simple slot machine, so you can entertain yourself in math class :lol: You will need at least a TI 83 Calculator.

 

Try it out

 

Ok, first create a new program called 'SLOT MACHINE'. Hit the enter key.

 

Now input the following code.

 

:ClrHome:Lbl 1:Output(1,1,"--Slot Machine--"):Output(2,1,randInt(0,9,1)):Output(2,4,randInt(0,9,1)):Output(2,7,randInt(0,9,1)):Goto 1

**EDIT** (Sorry, I didn't have enough time to finish this yesterday)

 

Ok, now exit the program editing screen, and run the program.

 

You have created your first TI-Basic slot machine! You may be wondering how to stop the slots. Simply hit the 'On' button while the program is running. It will force the program to error. It will ask you to quit, do it. After you quit, you will see whatever numbers you stopped the slot machine on. To run it again, simply hit enter.

Edited by KansukeKojima (see edit history)

Share this post


Link to post
Share on other sites

Very nice Kansuke, I advise though using a better form of stopping it. Also, labels suck in Ti-BASIC. They can cause the calculator to output an error message.

Here is a little better version of the code.

:ClrHome:A=0:While(A=0):getKey -> K:Output(1,1,"--Slot Machine--"):Output(2,1,randInt(0,9,1)):Output(2,4,randInt(0,9,1)):Output(2,7,randInt(0,9,1)):If K=105:Stop:End

EDIT: Fixed Output statements
Edited by coolcat50 (see edit history)

Share this post


Link to post
Share on other sites

Thanks man! I wasn't quite sure how to use the Enter Key to get it to stop... I kind of just figured out how to do this by messing around with stuff and learning how to use the output command XD

Share this post


Link to post
Share on other sites

No problem! You use getKey to retrieve a key value and you compare the key value from getKey with a key value of a certain button using an if statement. I've made a few neat games using getKey and the Graph.

Share this post


Link to post
Share on other sites

Hello again everyone. In my recent math classes, I've been able to improve my slot machine.
It now includes:
1. A coin counter

So if you want this on your TI calculator, then copy this code:

:ClrHome:If Z=-1:10->Z:0->A:0->K:Output(6,1,"COINS:"):Output(7,1,Z):Output(1,1,"--SLOT MACHINE--"):Output(5,1,"----------------"):While (A=0):getKey->K:Output(3,4,randInt(0,9,1)):Output(3,7,randInt(0,9,1)):Output(3,10,randInt(0,9,1)):If K=105:Z-1->Z:If Z=-1:Output(6,1,"PLAY AGAIN?":If K=105:Stop:End

All this modification does: you start the game with ten coins, every time you play, you lose a coin. Once the coins reach zero, you are asked to play again. If you hit enter, you'll get ten new coins to play with.

Also, if anyone knows how to do this, could you please modify this so that you will win coins when you get three numbers in a row?

Share this post


Link to post
Share on other sites

Hello Again everyone! I have finally perfected the slot machine! It now gives you more coins when:
1. You get three of the same number in a row (example: 1,1,1)
2. You get a series of numbers in a row. (example: 1,2,3)
3. You get two of the same numbers. (example: 1,1,2)
4. You get two numbers that add up to the other (example: 5,2,7 (5+2=7))

Anyways, just type this into the program mode on your calculator and you should be able to play.

:ClrHome:If D=E and E=F:Z+10->Z:If D=E or E=F or D=F:Z+2->Z:If F=E+1 and E=D+1:Z+2->Z:If F=D+E or E=D+F or D=E+F:Z+2->Z:If Z=-1:10->Z:0->A:0->K:Output(6,1,"COINS:"):Output(7,1,Z):Output(1,1,"--SLOT MACHINE--"):Output(5,1,"----------------"):While (A=0):getKey->K:randInt(0,9)->D:randInt(0,9)->E:randInt(0,9)->F:Output(3,7,D):Output(3,10,E):Output(3,10,F):If K=105:Z-1->Z:If Z=-1:Output(6,1,"PLAY AGAIN?"):If K=105:Stop:End

That should work, if it does not, then please post in response saying so, and I will try to fix it.

If your coin count ever gets to high just type in 10->Z to reset how much your coins are worth.

Enjoy.

Share this post


Link to post
Share on other sites

hoho TI basics I haven't made program in that language in long time. I remember writing Horner's algorithm so that it would solve me for any power of equation and simple stuff like solvers for the quadratic equation and so on. Just to make my life easier. But one thing I wanted to say. If you are writing tutorial Kanasuke then you should try to explain what everything means and represents because when noob comes here without any pre knowledge then he wouldn't figure out anything. Also try to add some graphics to the game they are always more appealing.Best Regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.