Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Nick Jordan
    @nickcjordan

    I have found a small example defiing objectives in ai.test.ts after coming across this thread: boardgameio/boardgame.io#7

    but I can't get the objective checkers to fire... the example in the thread shows defining a custom Bot derivative class that gets passed into the Client's "multiplayer: Local ( bot: CUSTOM_BOT ) " but I dont know how to define objectives for the "ai" section of the Game, and dont know how to pass in a custom Bot class implementing objectives for single player mode.

    any help would be appreciated!

    Nithiwat Sirirattanachaikul
    @nitsirs
    This message was deleted
    Nithiwat Sirirattanachaikul
    @nitsirs

    Hi all, I'm new to boardgame.io - I'm trying to run the game on a remote master by following the docs, but the Client just simply says: "Connecting..." without any error. (Same as this codesandbox)

    here's my server.js

    import next from "next";
    import { Server, Origins } from "boardgame.io/server";
    import { ThaiCrossword } from "./game/game";
    import Router from "@koa/router";
    
    const appPort = 3000;
    const apiPort = 8000;
    const dev = process.env.NODE_ENV !== "production";
    const app = next({ dev });
    const handle = app.getRequestHandler();
    
    app.prepare().then(() => {
      const server = Server({
        games: [ThaiCrossword],
      });
      const router = new Router();
    
      router.all("(.*)", async (ctx) => {
        await handle(ctx.req, ctx.res);
        ctx.respond = false;
      });
    
      server.app.use(async (ctx, next) => {
        ctx.res.statusCode = 200;
        await next();
      });
    
      server.app.use(router.routes());
      server.run({
        port: appPort,
        lobbyConfig: { apiPort },
      });
    
    });

    Client side:

    import { Client } from "boardgame.io/react";
    import { ThaiCrossword } from "../../game/game";
    import { SocketIO } from "boardgame.io/multiplayer";
    import ThaiBoard from "../../game/thaiBoard";
    import { useRouter } from "next/router";
    
    const ThaiBoardClient = Client({
      game: ThaiCrossword,
      board: ThaiBoard,
      multiplayer: SocketIO({ server: "http://localhost:8000" }),
      debug: false,
    });
    
    const App = () => {
      const router = useRouter();
      const { playerID } = router.query;
      return (
        <div>
    
          <ThaiBoardClient playerID={playerID}/>
        </div>
      );
    };
    
    export default App;

    Is there something wrong?

    5 replies
    Theo Salzmann
    @on3iro

    Hi,
    I am trying to add a middleware to the 'match/join' route, which also reads the playerName from the body.
    However if I also add the koaBody()-middleware I get a "stream is not readable"-error (after my middleware ran).
    I assume that this is because the join-route itself also includes the koaBody-middleware, but the body has already been parsed (and somehow koaBody seems to throw on that).
    If I don't use koaBody I can't access the playerName.

    Any idea what I could do here?

    Thanks in advance

    2 replies
    andrscyv
    @andrscyv
    Hey guys! I'm interested in using bots in multiplayer games with remote master server and would like to contribute for this feature. I made a high level description of my proposal here https://github.com/boardgameio/boardgame.io/issues/383#issuecomment-1107711313 . I would appreciate any feedback and guidance you could provide ! @delucis
    Kuta2kuma
    @Kuta2kuma

    Hi, it's me again, one quick question (though it's not directly in regards to bgio; I do apologize):

    I try to deploy the game app with the bgio lobby to a nginx web server but keep getting 404 errors when trying to create a game.
    Does someone have experience with setting up the lobby on nginx web servers and could provide some advice on how to get the game finally online.

    On localhost everything's working like it should though and so it seems the server configuration is not as needed by the lobby component.

    Nuno Balbona
    @NiciusB
    This engine seems perfect for my needs, but being unable to use classes is a non-starter
    Has anyone here had luck implementing serialization of the game state in some way?
    I'm wondering if I should bother working on that or if it's not gonna be worth it
    2 replies
    itsjesseyo
    @itsjesseyo
    Hello. I've been playing with BGIO for a couple of weekends now and love it. I've tried reading back as far as December but didn't see anything that might help me with my question, which is as follows: I am trying to allow a user to join a match via a 4 character code like with jackbox games. I was thinking I would add a custom route to save and retrieve a lookup from the 4-letter code to a matchid but cannot seem to find how to store additional data in the server storage. Is there a BGIO-centric way to do this or does anyone here know how to storage/retrieve key/values on the existing server storage? Also... how do i get a matchid from within the react components? Looks like I am going to have to use the API to create a game and store the matchid myself, but the tutorials do not go into this. Thanks and... where do i donate to the cause?
    12 replies
    iamevn
    @iamevn:matrix.org
    [m]
    would love for more of the types to be importable
    1 reply
    iamevn
    @iamevn:matrix.org
    [m]
    the two above are what I've hit so far but personally I think any type that one can get a reference to should be available to import
    maybe for cases like _ClientImpl that would mean defining and exporting an interface that it implements rather than simply exporting internal class
    happy to have a go at putting a PR together
    Chris Swithinbank
    @delucis
    I think if you do something like import type { _ClientImpl as ClientClass } from ...
    And then export that, we can even expose the full type.
    Sure we might expose a few internal methods but I don't think it's a huge deal.
    Bulat Kurbangaliev
    @ilov3

    Hey folks! I'm building react app based on boardgame.io, I'm trying undo my last move, but stuck with the following error on:

    ERROR: No moves to undo turn-order-0b7dce3d.js:451
        errorfn turn-order-0b7dce3d.js:451
        error turn-order-0b7dce3d.js:456
        CreateGameReducer reducer-07c7b307.js:1104
        dispatch Redux
        LogMiddleware client-fa36c03a.js:256
        TransportMiddleware client-fa36c03a.js:300
        SubscriptionMiddleware client-fa36c03a.js:311
        TransientHandlingMiddleware reducer-07c7b307.js:927
        undo client-fa36c03a.js:239
        onClick Board.jsx:106
        React 23
        js index.js:24
        factory react refresh:6
        Webpack 3

    Moves configured as undoable. Any thoughts how I could debug that?

    3 replies
    Andy Wang
    @andy1197
    This message was deleted
    2 replies
    Nick Jordan
    @nickcjordan
    Hi all, I have been working with a MCTS bot with Local multiplayer... I have it working where the bot will enumerate through the moves I provide, find one it likes, then make the move. However I noticed that as part of enumerating through to find the best moves, the move functions themselves are called by the bot a number of times until it finds the move it wants, then the state seems to reset to the start of the bot's turn, then the selected move is made and the bot's turn ends.... is there a way inside the move functions to determine if the current iteration of the function call is the bot enumerating through the moves looking for the best one versus the bot having already enumerated and is actually making the move rather than discovering?

    I have been making a board game with pieces that I would like to animate after each move is made, but I can't find any functionality that lets me look at the actual move being selected by the bot rather than seeing every move the bot considered, not knowing if its the one that will be selected... the bot is allowed to make multiple moves before the turn ends, but I want to animate the board after each move.... is there any way to do this?

    Thanks in advance! I am happy to explain more if my questions dont make sense

    Nick Jordan
    @nickcjordan
    I have found where if I implement the "play()" function in a custom implementation of MCTS bot I can see the move the bot is selecting... I thought maybe I could flag the move as "selected_by_bot" within this function so I will know within the move function that I should animate the move, but I can't edit the G state within the bot, so I don't think this approach would work. Please help!
    Nick Jordan
    @nickcjordan

    To summarize my main question:

    As a MCTS bot calls the various move methods while enumerating through the list of moves I provide it, is there any field on G or ctx or otherwise that I can check in the move function (or onMove(), onEnd(), etc) that tells me the move is the one that was selected by the bot?

    5 replies
    Theo Salzmann
    @on3iro

    Hey folks,

    What would be the correct way to import boardgame.ios server/utils? (if there currently is any)
    I currently need this, because I have a custom join-match route, which needs access to bgios createMatch-function.
    I can import utils via

    import {
      createMatch as bgioCreateMatch,
      getFirstAvailablePlayerID,
      getNumPlayers,
    } from 'boardgame.io/src/server/util'

    However this will make typescript typecheck these files and I get tons of errors. As soon as we us an import from 'src', an exclude inside the tsconfig will no longer work.
    Also I would prefer to import these from dist, but they currently don't seem to be part of the dist bundle.

    2 replies
    ryanms15
    @ryanms15

    Hey all, I'm having trouble with implementing remote multiplayer functionality. I've validated the game logic and behavior in local multiplayer and am trying to now port to remote. The issue I have is my client is having issues communicating with the server. When I run with a React LobbyClient component on my app, the game name and min/max players correctly populate in the boilerplate code, but when I try to create a new game, I get the response failed to create match for Azul (Error: HTTP status 404). When I use the plain JS LobbyClient implementation and call listGames(), the server returns undefined and a POST request to server:PORT/games/<game-name>/create also returns a 404 (Not Found) status code.

    Here is my client and server code. index.js is located in base directory/src. server.js is located in base directory.

    index.js (client)

    import React from 'react';
    import ReactDOM from 'react-dom/client';
    import './index.css';
    import { LobbyClient } from 'boardgame.io/client';
    import { Lobby } from 'boardgame.io/react';
    import Azul from './Game';
    import AzulBoard from './Board';
    
    async function lobbyStuff() {
        const lobbyClient = new LobbyClient({ server: 'http://localhost:3001' });
        const { matches } = await lobbyClient.listMatches('Azul');
        const { games } = await lobbyClient.listGames();
        console.log(matches);
        console.log(games);
        console.log(lobbyClient);
        const { matchID } = await lobbyClient.createMatch('Azul', {
            numPlayers: 4
        });
        console.log(matchID);
    }
    lobbyStuff();
    
    const root = ReactDOM.createRoot(document.getElementById('root'));
    root.render(
        <div>
            <Lobby
                gameServer={`http://${window.location.hostname}:3001`}
                lobbyServer={`http://${window.location.hostname}:3001`}
                gameComponents={[
                    { game: Azul, board: AzulBoard }
                ]}
            />
        </div>
    );
    const { Server, Origins } = require('boardgame.io/server');
    const Azul = require('./src/Game');
    
    const PORT = 3001;
    
    const server = Server({
        games: [Azul],
        origins: [Origins.LOCALHOST],
    });
    
    server.run(PORT);
    1 reply
    SamyGarib
    @SamyGarib

    Hi guys. I use flat-file to save the game's state. Sometimes things go sour, and I need a process to clean periodically zombie games. I'm trying to call directly the flat files methods but I can't figure it out. This code:

    const { FlatFile } = require('boardgame.io/server');
    
    const matchesDB = new FlatFile({
        dir: './db/matches/',
        logging: true
    });
    
    console.log("Attempting List Matches");
    matchesDB.listMatches().then(
        (result,error) => {
            console.log(result);
        }
        ).catch((error) => {
            console.log("List Marches Error");
            console.log(error);
        }
    );

    Will throw an error :

    TypeError: this.games.keys is not a function
        at FlatFile.listMatches (/AbakIO/abak-evolution/node_modules/boardgame.io/dist/cjs/server.js:2710:39)
        at Object.<anonymous> (/Abak/Development/AbakIO/abak-evolution/src/assets/js/server/utilities.js:9:11)`

    Can someone help me to understand what I'm doing wrong?

    1 reply
    Lucifer Morningstar
    @lmorningstar116
    Hi all. When performing any action, the board is not redrawn
    2 replies
    Darian Hickman
    @darianmavgo
    Can I hire somebody to migrate my 10 year old javascript board game to boardgame.io? If there's a better channel to post this request please reply with that. https://www.mavgo.com/portfolio/kenya
    4 replies
    Alex Jurkiewicz
    @alexjurkiewicz

    In the debug panel, I can select different player to change who a move is submitted by. I'm using this to test simultaneous stages. Is there any way to see which player is "active" in the context? playerId doesn't seem to get set, and currentPlayer is always set to the player whose turn it is.

    I'd like to know the currently selected debug player so I can update the UI to show their state

    10 replies
    Richard L
    @richardl62
    Hi. I am implementing a game with a time limit on certain stages. I was hoping to implement this in the server with a ‘time left’ flag as part of the game state. But I couldn’t see how to do this within the BGIO framework. Any advice would be welcome. Thanks.
    2 replies
    Izzy Lancaster✨
    @ILikePizza555

    Hello!
    I'm trying to implement a card game with a "pass" mechanic. If a player passes, they're removed from the turn order until all but one player passes. Once that happens, the board is cleared and the remaining player starts a new round, with all the players added back into the turn order of course.

    What tools do I have to manipulate the turn order in board game.io? It's not immediately obvious how I can do this, since I know I can't modify the ctx object.

    3 replies
    fladrif
    @fladrif
    I've been stuck on a problem wrt Stages for a while. I'm implementing an effect in a 2 player game where the opponent is made the active player for a move before being passed back to the current player. I go from { '1': 'some-stage' } and call setActivePlayers to set { currentPlayer: 'another-stage' } expecting ctx.activePlayers to be { '0': 'another-stage'}, then calling ctx.events.endStage() and going to {'0': 'last-stage'}, but instead after everything executes, I find myself in {'0': 'another-stage'}. Is there something fundamental I'm missing with how setActivePlayers and endStage works with regards to the current player not being an active player? Thanks!
    1 reply
    rateforx
    @rateforx
    Hi, how can I check on which stage the current (client) player is on?
    I cannot see anything of sort in the G or Ctx objects.
    1 reply
    Francisco Alamino
    @Franchax
    Hey! long time working with other parts of my game. Glad to see a lot of activity :D. Is there any correct way to use Unity with boardgame.io? I was wondering if I can just use the boargame backend and use unity as the client. This would be a great way to make my game multiplatform, but I don't know if its viable. If anyone already made something like this please be welcome to comment :D
    Nicolas Castejon
    @nicolasca
    Hey ! I have checked the deployment part with an example with Heroku for backend and client.
    Anyone has already done it with Vercel ? And how to setup such a deployment ? Thanks ! (I could not find an answer here and in the Github issues)