Code Monkey home page Code Monkey logo

minesweeper_automated's Introduction

MineSweeper_Automated

Developed with IntelliJ.

A simple implementaion of the classic game MineSweeper. Intended to work as a starting point to experiment with different algorithms for solving the game.

Graphics resources used in the examples can be downloaded at icon8, if used in your implementation, be sure to add credits to the designers.

How to use

In the project you will find an example of how to build a RandomSweeperBot. To create your own SweeperBot, just implement the interface SweeperBot and its methods. Simplest possible bot would look like this:

package barefoot.sweepervariants;
import barefoot.minesweeper.Constants;
import java.util.Random;

public class SimplestPossibleBot implements SweeperBot {
    /**
     * Implement to set Difficulty for the game
     *
     * @return int[] as found in the difficulty constants in Constants.java
     * @see Constants
     */
    @Override
    public int[] getDifficulty() {
        return Constants.GAME_EASY;
    }

    /**
     * Implement to handle how many times the game should be played.
     * GameStatistics can be fetched from game.getGameStatistics.
     *
     * @param game an instance of the current gui
     * @return boolean that shows if an other round should be played
     */
    @Override
    public boolean playAgain(MyGUISweeper game) {
        //Just one game will be played
        return false;
    }

    /**
     * Implement to calculate the next action
     * Do not make multiple calls to game.takeAutomatedAction(), only one.
     *
     * @param playerRevealedBoard Double[][] illustrating the gameboard.
     * @param game                an instance of the GUI
     */
    @Override
    public void takeAutomatedAction(Double[][] playerRevealedBoard, MyGUISweeper game) {
        Random random = new Random();
        int row = random.nextInt(10);
        int col = random.nextInt(10);
        game.takeAutomatedAction(Constants.ACTION_SWEEP,row,col);
    }

    public static void main(String[] args) {
        MyGUISweeper.runAutomated(new SimplestPossibleBot());
    }
}

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.