Git Product home page Git Product logo

theatre.minimax's Introduction

Theatre.minimax

Minimax is a decision rule used in decision theory, game theory, statistics and philosophy for minimizing the possible loss for a worst case (maximum loss) scenario.

Overview

This Minimax module implements the Negamax simplification with alpha–beta pruning.

Installation

Copy the content of sources/ folder into your project.

Usage

To use this Minimax module, you'll need to instanciate it with your presets (heuristic and childhood functions). Then, each time you'll need to get the best move node to play, you'll have to call the right decision rule (maximize or minimize) to apply to current move node.

Quick start

We first start an instance of this Minimax module :

// starts a Minimax instance with your presets
const minimax = new Minimax(heuristic, childhood);

Then, we could use this instance to maximize the next move node to play :

// calls maximize decision rule for current move node limited by given depth
const maximize = minimax.maximize(start, depth);

// gets the best next move node to play
console.log(maximize);

Or we could minimize the next move node to play :

// calls minimize decision rule for current move node limited by given depth
const minimize = minimax.minimize(start, depth);

// gets the worst next move node to play
console.log(minimize);

API

constructor()

maximize()

minimize()


constructor()

Creates an instance of this Minimax module.

Usage :
// starts a Minimax instance with your presets
const minimax = new Minimax(heuristic, childhood);
Properties :
property name type description
parameter heuristic function scores a move node
parameter childhood function retrieves next move nodes from a move node
Details :

heuristic() :

The heuristic function purpose is to score a move node to tell Minimax how to compare them with each other. Since it is related to your application, you must define your own heuristic function to pass through the constructor following the documentation below.

property name type description
parameter move object move node
return score number score of the move node

childhood() :

The childhood function purpose is to retrieve the next move nodes from a move node to tell Minimax how to go through the move tree. Since it is related to your application, you must define your own childhood function to pass through the constructor following the documentation below.

property name type description
parameter move object move node
return moves array array of move nodes

maximize()

Maximizes the chances of current move winning (minimum loss).

Usage :
// calls maximize decision rule for current move node limited by given depth
const maximize = minimax.maximize(start, depth);
Properties :
property name type description
parameter start object move node
parameter depth number max depth to reach browsing the move nodes tree

minimize()

Minimizes the chances of current move winning (maximum loss).

Usage :
// calls minimize decision rule for current move node limited by given depth
const minimize = minimax.minimize(start, depth);
Properties :
property name type description
parameter start object move node
parameter depth number max depth to reach browsing the move nodes tree

theatre.minimax's People

Contributors

deformhead avatar

Watchers

 avatar  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.