Code Monkey home page Code Monkey logo

mastermind's Introduction

Mastermind

A CLI game based off of Donald Knuth's Mastermind

Live Preview

https://replit.com/@supersakana/mastermind?v=1

About this game

When game.rb is run, the user is introduced with 2 options(intro.rb) to be the code breaker or code maker. According to the user's choice, the game will select which file to run (breaker.rb or maker.rb).

The clues given is Black (B - displays number of correct values in guess) and White (W - displays number if values with correct value AND index)

At the moment, breaker.rb displays the cpu code after the user makes a guess. This is so the user can test the game to make sure it is working when a guess is correct.

In the maker.rb file, the computer strategy first finds the correct numbers but sifting though avalible values with each number (one at a time), then once it know all of the values include the user's code, the CPU shuffles it's guesses until it hits the correct code.

I've added comments on each method to describe what is happening in the code.

The game ends once a winner is declared.

Reflection

Overall, for my first take on this project, I'm happy with how it turned out. I've had the most fun programming this project than any other and felt the most struggle. Could my code be DRY-er, more elegant, and OOP? Absolutly. But this was quite the learning experience for me and is a mark of progress in my journey to becoming a developer.

Feel free to give me feedback on how I can improve, I'm very open and want to make progress.

Notes to myself for refactoring...

  • Beef up all validation methods!

  • Make it so answer is hidden @breaker.rb

  • DRY up sample methods in maker.rb (create it as it's own method)

  • Focus more on OOP concepts

  • Create a replay class or method

mastermind's People

Contributors

zacwilliamson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.