Coder Social home page Coder Social logo

mastermind-net's Introduction

Introduction

Please note: This project was discontinued.

The class was written with the intention of hiding as much game logic from the developer as possible, to allow him/her creating the GUI/CLI, instead of focusing on game details.

Also, for developers who want to create a Mastermind game from scratch, but don't want to worry using dozen of classes. All the public classes were reduced to the following:

  • Mastermind: it's a factory and allows you to create the needed objects to interact with the system
  • MastermindGame: where the action happens! This class represents a game, and allows you to simulate a board. All the moves are done internally, and the final result is returned after that
  • ScoreCard: allows you to save score from all games you wish to save. Later, the scores can be retrieved as a global score from all games, or search for a individual game, and get the score

Enumerators were designed to be informative as well. Descriptive names and rich documentation descriptions makes easier to developer to know what each option does. Example code

// Creates a new custom game, with human and computer as players
// Board has 6 rows, allowing 2 pegs per row
MastermindGame mm = Mastermind.createCustomGame("human", "computer", 6, 2);

// Creates the secret combination to be guessed by human player
PegColor[] colors = new PegColor[] { PegColor.Blue, PegColor.Cyan };
ColoredPegRow combination = Mastermind.createCombination(colors);
mm.setup(combination);

// The setup is done, we can start the game
mm.startGame();

while (mm.Status == GameStatus.Running)
{
      // Note that getUserGuess must be implemented by the developer
      // It must return the user guess for the current move
      ColoredPegRow userGuess = getUserGuess();
    
      // MoveResult can give you information like how many pegs had the right color or were in the correct position
      MoveResult mr = mm.doMove(e.Current);
}

// Outside the loop, means the game already ended
if (mm.Status == GameStatus.Ended)
  MsgBox("game ended!");

When the game ends, it's not possible to do more moves, but there is a lot of information that MastermindGame? classe can still provide, such as:

  • Time statistics
  • The winner of this match
  • Save the players victory in the ScoreCard?

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.