Author Topic: Barebones Mastermind Game  (Read 2579 times)

0 Members and 1 Guest are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Barebones Mastermind Game
« on: November 24, 2013, 03:17:57 pm »
This isn't TI|BD's [tibd]Mastermind[/tibd] game!

I made a version of Mastermind in 439 bytes (including the name, MSTRMIND). It uses numbers 0-9, keypresses instead of Input for inputting numbers, and it shows red and white pegs instead of right/part-right/wrong numbers.

I got the white peg formula from Wolfram Mathworld. This is it, as used in the program:



ci is how many times color i was in the code, and gi is how many times it was in the guess. r, of course, is how many red pegs thrown out.

The file is attached. You press the number pad to input numbers, ENTER to guess it, and CLEAR anytime to quit. A half-second after guessing, you will see the change in red and white pegs. You get 14 guesses.

Give tips for even more optimization, if possible!
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: Barebones Mastermind Game
« Reply #1 on: November 24, 2013, 07:34:38 pm »
Found  a bug! Because it checks for the winning number when I enter it, all I have to do is find 2 or 3 numbers then randomly enter the other digits, hit left to erase them, and repeat until it says I win!

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Barebones Mastermind Game
« Reply #2 on: November 24, 2013, 08:57:07 pm »
What do you mean by that? Give me an example.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: Barebones Mastermind Game
« Reply #3 on: November 24, 2013, 09:51:19 pm »
You know how you type in the 4 numbers then press enter and it copies the numbers to the side? If you never press enter you can press 0000 then press left to erase it, then 0001... eventually you would find the right number and win without ever using one guess! Instead of checking for the winning number after its posted, the game checks for it as its entered.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Barebones Mastermind Game
« Reply #4 on: November 25, 2013, 09:29:55 am »
Now that I know what you mean, I will fix it.

EDIT: I found the problem! Alternate download coming soon, but for now:
1. Replace DelVar TDelVar Gint(10rand(4→L1 with DelVar TDelVar GDelvar Rint(10rand(4→L1
2. Replace Repeat T=14 or K=45 or 4=sum(L1=L2 with Repeat T=14 or K=45 or R=4
3. Replace sum(L1=L2 with sum(L1=L2→R
4. Replace Output(1,1,"YOU "+sub("WIN!   LOSE...",1+7(T=14),7 with Output(1,1,"YOU "+sub("WIN!   LOSE...",8-7(R=4),7
5. Replace DelVar GDelVar KDelVar TDelVar XDelVar L1DelVar L2ClrHome with DelVar GDelVar KDelVar RDelVar TDelVar XDelVar L1DelVar L2ClrHome

Eats up an extra variable, but it has the same size!
« Last Edit: November 25, 2013, 11:17:52 am by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: Barebones Mastermind Game
« Reply #5 on: November 25, 2013, 04:47:55 pm »
Works perfect!

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Barebones Mastermind Game
« Reply #6 on: November 25, 2013, 06:44:07 pm »
Thanks for the small bugtest! Download in a few minutes!

EDIT: The file is attached here.
« Last Edit: November 25, 2013, 07:13:04 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?