Boardgame.io: any bots support customized defined?

Created on 12 Nov 2020  Â·  5Comments  Â·  Source: boardgameio/boardgame.io

does any bots support AI customized define by python aliked script?

question

Most helpful comment

There’s no out-of-the-box support, but a minimal bot is a class that extends Bot and implements a play method, so you can theoretically integrate with any external service:

import { Bot } from 'boardgame.io/ai';

class CustomBot extends Bot {
  async play({ G, ctx }, playerID) {
    const nextMove = await fetchActionFromService({ G, ctx }, playerID);
    return { action: nextMove };
  }
}

So if you can find a way to dispatch the request to the service — for example a request to a Python server — and parse its response into a boardgame.io action, that could work.

boardgame.io expects play to return an object like:

{
  action: {
    type: 'MAKE_MOVE' || 'GAME_EVENT',
    payload: {
      type: string,
      args: any,
      playerID: string,
    },
  },
}

All 5 comments

@yangboz Could you provide more detail about what you’re looking for? The framework provides a bot that implements Monte Carlo tree search, but it is Javascript like the rest of the codebase. The Bots section of the tutorial shows how to get it up and running.

I am trying using MuZero as AI bots's engine ,but the codebase is written with Python, so if possible the boardgame.io's bot compatible with external service?

There’s no out-of-the-box support, but a minimal bot is a class that extends Bot and implements a play method, so you can theoretically integrate with any external service:

import { Bot } from 'boardgame.io/ai';

class CustomBot extends Bot {
  async play({ G, ctx }, playerID) {
    const nextMove = await fetchActionFromService({ G, ctx }, playerID);
    return { action: nextMove };
  }
}

So if you can find a way to dispatch the request to the service — for example a request to a Python server — and parse its response into a boardgame.io action, that could work.

boardgame.io expects play to return an object like:

{
  action: {
    type: 'MAKE_MOVE' || 'GAME_EVENT',
    payload: {
      type: string,
      args: any,
      playerID: string,
    },
  },
}

If you can deploy a bot separately as a client, please try this.
https://github.com/boardgameio/boardgame.io/tree/master/python

I’m going to close this for now as I think it has been answered, but please feel free to re-open it if you have any further questions @yangboz.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haoyangnz picture haoyangnz  Â·  5Comments

jchadwick picture jchadwick  Â·  4Comments

julienroulle picture julienroulle  Â·  9Comments

amerine picture amerine  Â·  5Comments

iCrashed picture iCrashed  Â·  4Comments