This sample shows how to implement Goita AI based on goita-core
.
npm install goita-ai-sample
- To use the
RandomAI
class in a TypeScript file -
import * as Goita from "goita-core";
import { RandomAI } from "goita-ai-sample";
const history = "12345678,12345679,11112345,11112345,s1,113,2p,3p,431,1p,2p,315";
const board = Goita.Board.createFromString(history);
const ai = new RandomAI();
const chosenMove = ai.chooseMove(board.toThinkingInfo());
board.playMove(chosenMove);
- To use the
RandomAI
class in a JavaScript file -
const Goita = require('goita-core');
const RandomAI = require('goita-ai-sample').RandomAI;
const history = "12345678,12345679,11112345,11112345,s1,113,2p,3p,431,1p,2p,315";
const board = Goita.Board.createFromString(history);
const ai = new RandomAI();
const chosenMove = ai.chooseMove(history);
board.playMove(chosenMove);