macao
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Macao Logo

Build Status Coverage Status npm version PRs welcome

Macao is a simple framework that allows the addition of powerful game AI to your JavaScript game with minimal configuration and coding.

Why use Macao

Perhaps:

  1. You are programming a simple game like Tic-Tac-Toe, Connect Four, Nim or the likes and would like to make the game playable against "the computer" without having to code a bunch of if statements, state machines and decision trees.
  2. You're programming a more complicated game like chess, Checkers or Go. Unfortunately, programming an AI player that is able to challenge good human players usually requires imparting the AI with the knowledge of expert players, and you are not. You may know the rules of the game, but you are no Grand Master.
  3. You are developing an entirely original game. Obviously, you know the rules of the game since you are the one who invented it, but do you know the best strategies to employ during play? How can you? Unlike with chess, your game hasn't been played by millions of people over centuries so there are no doubt various ways to play your game that even YOU haven't thought about.
  4. You are building a prototype of a game and, eventually you plan to give it a very complicated AI with detailed expert domain knowledge, gained through weeks of machine learning and written in thousands of lines of code. But for now, you'd really just like to figure out if and how the game works and if it's fun to play.

What Is Macao

Macao is a simple framework that allows the addition of powerful game AI to your JavaScript game with minimal configuration and coding. It is based on the powerful, yet simple, Monte Carlo Tree Search algorithm. Macao makes it possible for you to add AI to your game, even if you are a bad player and don't understand the strategy. All you need to know are the rules of the game, that's it, and that's all Macao needs to know in order to work it's magic.

Although we plan to quickly expand the types of games it supports, at the moment Macao is compatible with two player, turn-based, perfect information, deterministic games. Well, that was a mouthful. Basically this means that it should work with any game similar to Chess, Checkers, Tic-Tac-Toe, Nine Men's Morris etc.

How to use Macao

import { Macao } from "macao";
 
// Functions that implement the game's rules.
// These functions are provided by you.
const funcs = {
  generateActions,
  applyAction,
  stateIsTerminal,
  calculateReward
};
 
const config = {
  duration: 30
  // ...
};
 
const macao = new Macao(funcs, config);
 
// Somewhere inside your game loop
const action = macao.getAction(state);

For more indepth information on how to use Macao, please see the general documentation.

Installation

npm install macao --save

General Documentation

You can read the general documenation here.

API

You can read the API documentation here.

Contributing

Please take a look at our contributing guidelines if you're interested in helping!

Changelog

See CHANGELOG.md

License

Macao is provided under the MIT License.

Package Sidebar

Install

npm i macao

Weekly Downloads

367

Version

2.0.1

License

MIT

Unpacked Size

128 kB

Total Files

39

Last publish

Collaborators

  • neoflash