Giter Site home page Giter Site logo

govariantsteam / govariants Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 2.39 MB

A place to play Go variants

Home Page: https://www.govariants.com

License: GNU Affero General Public License v3.0

HTML 0.15% CSS 2.19% TypeScript 71.62% Procfile 0.03% JavaScript 0.75% Vue 25.27%
baduk game igo weiqi

govariants's People

Contributors

benjaminpjones avatar dependabot[bot] avatar evizam avatar jonko314 avatar merowin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

govariants's Issues

Game moves: error handling

  1. server should pass back current board state along with error message
  2. client should adjust accordingly
  3. client should display error message

[CI] run tsc on PRs and pushes to main

The launch command runs tsc on server, so we want to make sure it passes. Also it's good to check the types anyway.

Somewhat related - maybe we don't want heroku checking types? I believe transpilers such as babel can convert to JS faster and they won't die because of missing types..

Logo

We should have one!

State via the API

In hidden information games, the clients should not have access to the whole moves list. My thought is that the following endpoints can be created:

  • /games/%id%/state
  • /games/%id%/state/%seat% (partial state)

It would return the output of exportState().

config entry broken

Probably caused by #70

To reproduce:

  1. pick a variant on the homepage
  2. modify the config
  3. click "Create game"
  4. observe that the default config was used, not the modified one.

Read-only prop for boards

Two scenarios where you might want not want the board to register hover and drag events:

  • The game page (noticeable with parallel board because hovering makes a square pink)
  • Not my turn (noticeable with chess board)

[FR] Clock

I'm not really sure how this should work, but time settings are a pretty big part of the game.

Remove multi-procfile

When I first set up the Heroku stuff, I thought we would need two servers - one to serve the client (React/Vue) and one for the REST server (Express). Turns out we can build the client code and serve it directly from the Express server, so multiple Procfiles are not necessary.

  • packages/server/Procfile
    • this is the one we still need
    • We might want to move it to the root though
  • packages/client/Procfile
    • We don't need this one anymore
    • Note: this will be removed anyway when I remove the React app
  • The multiprocfile buildpack should be removed (i think this is done in the Heroku interface)

Variant Abstraction

As demonstrated in commit 01c399f variants can share some parts of code. Abstractions like this reduce code redundancy and should make it easier to add similar variants.

The commit introduced an examplary class AbstractAlternatingBlackWhiteOnGridVariant, which was used as superclass for the Baduk and TicTacToe variants. Other variants call for more considerations on how to achieve a better form of abstraction:

A couple of high level design thoughts:

  • Is this method of creating an intermediate subclass composable?
    • Example: HexGo might be described as an AlternatingBlackWhite variant, and Go Battle Royale might be described as a Grid variant. If we had two subclasses AlternatingBlackWhiteVariant and AbstractGridVariant, is it possible to compose the two into AbstractAlternatingBlackWhiteGridVariant?
  • As far as minimizing redudancy between Go and TicTacToe, it's definitely a useful exercise, but I don't think we want to go too deep into TicTacToe specifically as it was just a demonstration for how a game can be added.
  • Looking at the list of games we wanted to focus on in the forum thread, only Pyramid Go fits the AbstractAlternatingBlackWhiteGridVariant

Originally posted by @benjaminpjones in #27 (comment)

Also worth mentioning are thoughts on abstraction expressed in the OGS forum.

Persist games in a database

I removed this as a requirement for the MVP. For now, data is stored in memory and lost when the server restarts.

Still, a DB will be crucial. Some discussion to be had on which one.

Postgres seems like the straightforward choice, but Mongo seems like it might shine here since game data doesn't have a consistent schema.

Implement server

Basic MVP requirements:

  • persist games in a database
    • See issue #6
  • log in w username and password
    • Not necessary at first, see issue #5
  • play a game (via socket.io)

Change the metadata/title

Currently it's just whatever Create React App put in there. We can change this to Go Variants and whatever logo comes out of #11 .

Screen Shot 2022-07-10 at 10 59 39 AM

Screen Shot 2022-07-10 at 11 02 05 AM

Return JSON on error (game/%%/move)

For some reason, html is being returned and it confuses JSON.stringify(), so the error shown isn't very useful. I think this has something to do with the fact that we are calling next() on error (a fix I had to do to deal with express not knowing how to handle unhandled promise exceptions!)

Screenshot (should say something like "you can't place a stone on an existing stone"):

Screenshot_20220829-064639_Firefox

Implement basic UI

MVP requirements =

  • Log in? (I think this is important, but maybe not)
    • For the MVP, just going to let anyone play a move as any player.
  • Create a game
  • Play a game

default configs

We should have default configs for each game, since right now it defaults to a config that works for baduk.

Anchor the Nav Bar

The nav bar seems to change position, depending on what page you're on. We should try to keep it fixed. The easiest way to do this will be to lock it to the top and have it take up the whole width. But with some more css, we could do something fancy like locking it to the bottom or sides.

Screenshots

Mobile

Screen Shot 2023-05-20 at 22 22 57 Screenshot 2023-05-20 at 10 22 26 PM

Desktop

Screenshot 2023-05-20 at 10 20 44 PM Screenshot 2023-05-20 at 10 19 29 PM Screenshot 2023-05-20 at 10 18 58 PM

[FR] Analysis

AKA these buttons:

Screen Shot 2022-07-09 at 10 08 00 PM

Game tree exploration (i.e. exploring unplayed moves) not necessary.

Seats

Like seats at a poker table. You sit down to play and it associates you with a Player number. This depends on users being in place (#5)

  • endpoints
    • [new] PUT games/:game_id/sit/:seat_num
    • [new] PUT games/:game_id/leave/:seat_num
    • [modify] GET games/:game_id: add players field, an array of seats with length game.numPlayers()
  • UI: SeatComponent and integration into GameView

Example from VGS:

Screen Shot 2022-08-17 at 8 25 10 AM

What I've got on seats branch so far:

Screen Shot 2022-08-17 at 8 14 55 AM

Responsive board

Currently the board gets cropped on mobile:

This was previously implemented in the React app by setting <svg width="100%" height="100%">

Implement ko for baduk

Question: should this be implemented at the individual level? I was hoping that games would not need to keep track of history. And it would be relatively simple to implement the (super)ko rule at an abstract level. Something like:

const gamestate = deepCopy(game.exportState());
// Note: Array.prototype.includes won't work since we are comparing JS objects. We'll
// either need to make history a special type of Array or just use a different function.
if (history.includes(gamestate)) {
    throw Error("illegal ko");
}
history.push(gamestate);

Handle errors and crashes more gracefully

It recently came to my attention that server-side errors aren't handled well (try sending a move from the wrong player! fixed that, but there are others). If an async function throws, the server will crash and needs to be manually restarted. A couple things we can do:

  • Use a process manager to restart whenever there is a failure.
  • catch the unhandled promises
  • Set the right error instead of throwing: (#29)

Add a lint check

I noticed there's about 11 lint errors in the Vue app, but nothing enforcing it. Here's a list of things that we need in order to get the whole repo linted:

  • Add eslintrc file for the packages that don't have it (shared & server?)
    • To start, I think we want to extend "eslint:recommended"
  • Add a lint script to the root package.json
  • Fix any lint errors that show up
  • Call the lint script in the GitHub workflow

There are also a variety of IDE integrations available for ESLint that folks can use for faster feedback: https://eslint.org/docs/latest/user-guide/integrations

Config entry

Variants have options such as board size, komi, etc. Currently this configuration can be specified via JSON:

Screen Shot 2022-07-09 at 7 01 58 PM

However, it is easy to pass invalid data this way. It would be better if we had an options pane with validation, similar to OGS's ChallengeModal:

Screen Shot 2022-07-09 at 7 03 54 PM

Respect "gameover" phase

If the game is over, we should show the result and prevent new moves from being submitted to the server.

[baduk] validate config

One example of an invalid config:

{
height: 100,
width: 19,
komi: 5.5
}

height is too large for SGF format- game creation should fail!

Implement resignation

Requires end-to-end support (Resign button in the UI, resignation on the backend)

Some design questions:

  • Will there also be a concept of leaving? Some way you can leave an empty seat that someone else could potentially join...
  • If so, will these conflict? How does resignation work in a >2 player environment?

Use socket.io for gameplay

If player A and player B are both on the game page, and player A plays a move, player B's board will not update. We can use socket.io to send moves to clients as they are played.

Server errors: use the right error codes, and bubble up to the UI

Just throwing in Express sends out a 500 error code, which usually indicates a bug on the server. Many errors are thrown on purpose when the client makes a mistake (game not found, invalid move). We should use the proper error codes for these:

  • 400: Bad Request
  • 404: Not found

In addition, the UI should surface these errors to the user where appropriate.

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.