Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 1v1 games #9

Closed
aurbano opened this issue May 22, 2018 · 1 comment
Closed

Support 1v1 games #9

aurbano opened this issue May 22, 2018 · 1 comment

Comments

@aurbano
Copy link
Member

aurbano commented May 22, 2018

In order to provide a better testing experience, players should be able to play 1v1 against their algorithms, or have one algorithm against another.

In essence we should support:

  • player (manual) vs player (manual)
  • player (manual) vs algorithm
  • algorithm vs algorithm

1v1 Matches will be created from the web UI by sending the appropriate message to the server, who will respond with a token. To make it easier to share, the token should be 3 words (for example) i.e. "kitten sky lamp".

Idea for implementation:

The server could handle each match as a "room" in socket.io, so players connect to that room in order to participate in a match?

The workflow would be:

  1. User goes to the UTTT website and clicks on "Create Match".
    • The website sends the request to the server, and receives a token.
    • The website goes into a "Match Created" mode, where it's waiting for players.
  2. User runs uabc with the token from the server, connecting to the match.
    • The website now shows an algorithm connected to the list of available players for this match
    • The user now has the option to start the match, by playing itself against the algorithm.
    • Before starting the match, if another algorithm connects to this match, then both algorithms show up in the list of available players, removing the option of human vs algorithm.
  3. Once there are 2 players connected (either the user & an algorithm, 2 users, or 2 algorithms), the user can click on "Start Match", which will display a UI similar to the Replay one available when uploading logs.
  4. If playing user vs algorithm, the server will initiate a game, request a move from the user socket, which will make it wait for the user to click on a valid cell, then send it to the server, send it to the algorithm... etc.
  5. Whenever a game is done, the web should give the option to "Start a new game", or "Finish"
@aurbano
Copy link
Member Author

aurbano commented Jul 19, 2018

JSON format for Lobby + Tournament

type Stats = {
    started: boolean;
    finished: boolean;
    options: {
      maxGames: number,
    },
    matches: Array<MatchStats>;
    ranking: {
        players: string[],
    },
};

type MatchStats = {
    id: string,
    state: 'finished' | 'playing' | 'upcoming',
    winner: string | -1 | null, // token | tie | unfinished
    players: [
        {
            token: string,
            gamesWon: number,
        }
    ],
    games: [
        {
            id: number,
            finished: boolean,
            winner: string | -1 | null,
            moves: string[],
            timing: number, // ms to complete game
        }
    ];
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants