Giter Site home page Giter Site logo

onitama-ai's Introduction

onitama-ai

An implementation of the board game Onitama, featuring an AI based on the Minimax algorithm.

How to Play

Onitama is a perfect-information game which is fairly simple. 5 movement cards are chosen at random, with 2 being given to each player (face-up so both players can see), and the final card being left on the table. Each card will have a depiction of the various moves that can be made by any piece on the board. Landing on an opponents piece will capture it, and you cannot move onto tiles already occupied by friendly squares.

Upon moving, the card used to play the move is placed in the center of the table, and the player picks up the card which was already in the center (replacing the card that was just used).

Each player takes it in turns to make a move, until a player wins.

Win conditions

In Onitama, there are two win conditions which can be used:

  • Reach your opponent's temple with your master.
  • Capture your opponent's master.

While the first win condition is supported, it is currently disabled while working on a nicer scoring mechanism (see below). Optimising for the temple-capture win condition led to boring games otherwise.

Playing against the AI

To play against the AI, choose the AI difficulty when prompted on first loading the page (or, choose vs player to play against someone locally). The AI will always be the red pieces, meaning the player always goes first.

Scoring

The Minimax algorithm will only be as good as the scoring mechanism used to evaluate a game-state. For this project, a very rudamentry scoring system was used. Points are allocated for:

  • Capturing pieces.
  • Controlling the center of the board.
  • Capturing your opponent's master.

This does not do justice to the complexity that this game can have; for example, there is nothing in the scoring about advantagous positions which can threaten multiple units, or adjustments based on the cards in-play. However, it is sufficient to demonstrate a working AI (and to lose to it often).

Known issues

There is currently a potential issue wherein a player cannot move based on the cards they have available. This is very rare though as it relies on a very particular hand to be drawn.

Tech

This project is built almost-completely in TypeScript, using React (via Vite) for the UI. The game engine itself is written in TypeScript too, however currently only runs in tandem with the UI (i.e. there is no CLI version which uses the game engine).

onitama-ai's People

Contributors

jdysiewicz avatar

Watchers

 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.