Nov 21, 2009

Ti-basic --- Slot Machine

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Ti-basic --- Slot Machine

KansukeKojima
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 tongue.gif 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.

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.

 

 

 


Comment/Reply (w/o sign-up)

coolcat50
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.
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

Comment/Reply (w/o sign-up)

KansukeKojima
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

Comment/Reply (w/o sign-up)

coolcat50
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.

Comment/Reply (w/o sign-up)

ShaggytheClown
Nice Ti-basic --- Slot Machine tutorial Kansuke

Comment/Reply (w/o sign-up)

KansukeKojima
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:

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?

 

 

 


Comment/Reply (w/o sign-up)

FeedBacker
Replying to KansukeKojima

I MAY BE ABLE TO HELP, BUT YOU HAVE TO TELL ME WHAT EACH VARIABLE MEANS

-reply by RANDOM

Comment/Reply (w/o sign-up)

KansukeKojima
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.

CODE
: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.

Comment/Reply (w/o sign-up)

seba1killer
Very good, i have never used that Basic. I started learning with your tutorial and probably i will continue in my own.
Thanks and regards

Comment/Reply (w/o sign-up)

hitmanblood
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

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Ti Slot


    Looking for ti, basic, slot, machine

Searching Video's for ti, basic, slot, machine
See Also,
advertisement


Ti-basic --- Slot Machine

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com