Hello. This is an update to my first post, which is since long gone. I have successfully developed and tested a fully functioning code for mastermind in TI-Basic.
However, this basic is for the TI-92 family. I have notes included on how to possibly do it in the TI-84 family, but not 100% sure, so don’t quote me on anything, as I have not built this code for it or have tested that version of code. However, the TI-89 titanium should handle well with this code.

Feel free to do whatever you want with this code. I, however, am not responsible for the misuse of this code for malicious intents or any other equally inappropriate use.

Code is below for convenience:
(Notes are denoted with a //: before them)
(To end game because guess limit reached, enter 3.14. That will direct you to the Game over sequence)


Code:
mastmind() (//:not necessary for 84 family)
Prgm (//: also not necessary for 84 family)
ClrIO (//:ClrHome for 84)
Local a,b,c,d,e,v,w,x,y,z
Lbl f
rand(9)-->a (:// Can change to add more or less variables as well as rand possibilities.)
rand(9)-->b
rand(9)-->c
rand(9)-->d
rand(9)-->e
Disp  “Welcome to Mastermind”
Disp  “You have 15 guesses”
Disp  “Otherwise it is game over”
Disp  “Your time starts now”
Loop (//: Lbl for 84 family, can omit loop)
Input “z=”,z
If z<a Then
Disp “Too Low”
EndIf
If z>a Then
Disp “Too High”
EndIf
If z=3.14 Then
Disp “Game Over”
Goto u
EndIf
If z=a Then
Disp “Next level”
Goto g
EndIf
EndLoop (//:Doesn’t exist in 84. I don’t think it is necessary so can be omitted in that family)
(//: I think Goto (letter) works for 84 family)
Lbl g
Loop (//: Lbl for 84 family, can omit loop)
Input “y=”,y
If y<b Then
Disp “Too Low”
EndIf
If y>b Then
Disp “Too High”
EndIf
If y=3.14 Then
Disp “Game Over”
Goto u
EndIf
If y=b Then
Disp “Next level”
Goto h
EndIf
EndLoop (//:Doesn’t exist in 84. I don’t think it is necessary so can be omitted in that family)
Lbl h
Loop (//: Lbl for 84 family, can omit loop)
Input “x=”,x
If x<c Then
Disp “Too Low”
EndIf
If x>c Then
Disp “Too High”
EndIf
If x=3.14 Then
Disp “Game Over”
Goto u
EndIf
If x=c Then
Disp “Next level”
Goto i
EndIf
EndLoop (//:Doesn’t exist in 84. I don’t think it is necessary so can be omitted in that family)
Lbl i
Loop (//: Lbl for 84 family)
Input “v=”,v
If v<d Then
Disp “Too Low”
EndIf
If v>d Then
Disp “Too High”
EndIf
If v=3.14 Then
Disp “Game Over”
Goto u
EndIf
If v=d Then
Disp “Next level”
Goto j
EndIf
EndLoop (//:Doesn’t exist in 84. I don’t think it is necessary so can be omitted in that family)
Lbl j
Loop (//: Lbl for 84 family)
Input “w=”,w
If w<e Then
Disp “Too Low”
EndIf
If w>e Then
Disp “Too High”
EndIf
If w=3.14 Then
Disp “Game Over”
Goto u
EndIf
If w=e Then
Disp “Congratulations!”
Goto t
EndIf
EndLoop (//:Doesn’t exist in 84. I don’t think it is necessary so can be omitted in that family)
Lbl u
Disp “Game Over”
Lbl t
Input “Play again?”, s
If s=0 Then
Goto f
EndIf
If s>1 Then
Disp “Error 404”
Disp “Resetting system…”
Disp “Really? Really? You just had to type in something bigger than 1, didn’t you?” (//: Comedic effect. Can be changed for more or less humor, i.e. I have mine call whoever typed in anything greater than one a dumb donkey lol)
Goto t
EndIf
If s=1 Then
Disp “Thanks for playing”
EndIf
EndPrgm
I looked at your profile, but I didn't find any other documentation on what this program is or does. It looks like some sort of number guessing program, but it has lots of other bits I haven't seen. Could you clarify how this game works? I see lots of potential for optimization, but first I have to know how it works.
Originally, I found this game as an assembly file and converted it to BASIC. The game's original format was to display five blanks, be set on a Loop or Lbl, to which five numbers would be entered. The plus would Mean the number was too high, and the - was to display numbers that were too low. I rearranged the code to do this sequentially and to also be edited to whatever the player likes (i.e., more numbers, fewer guesses, etc.). The original format was 5 numbers 1-9 (Rand(#) and 15 guesses for the code.

The original code for the TI-84 version was on TI-Developer, and free to use without copyright restraint.
Link is here: http://tibasicdev.wikidot.com/mastermind

(P.S.: If someone could inform me on how to use lists and strings for the TI-
92 family that would be fantastic. Thanks in advance.)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement