Coder Social home page Coder Social logo

game-of-go's Introduction

Board state string

There are now seven possible board states for a given coordinate: - no stone; - no stone, black’s territory; - no stone, white’s territory; - black stone; - black stone, white’s territory (dead black stone); - white stone; - white stone, black’s territory (dead white stone).

The GameBoard class in go.js needs to track this stuff. I plan to add an owner field that’s parallel to board, storing black, white, or none for each position. This implies another two states: - black stone, black’s territory; - white stone, white’s territory.

I’m not sure whether these two states should be used in someway, or just be considered invalid. I’m leaning towards invalid.

The state_string representing the board state needs to deal with the new states. These make sense to me:

.

no stone

B

no stone, black’s territory

W

no stone, white’s territory

b

black stone

c

black stone (dead)

w

white stone

x

white stone (dead)

c and x were chosen just because they follow b and c in the alphabet.

Scoring algorithms

Algorithm for counting territory, given: - komi, - the number of black stones captured during the game, - the number of white stones captured during the game, - the coordinates of live black stones, - the coordinates of live white stones, - the number of dead black stones on the board, and - the number of dead white stones on the board.

  1. Mark live black stones with b, live white stones with w, and all other coordinates with ?.

  2. For each coordinate ?:

    • Search in all directions, stopping at any b or w.

    • If both b and w coordinates are found, then mark all ? with ..

    • If only b coordinates are found, then mark all ? with B.

    • If only w coordinates are found, then mark all ? with W.

  3. Black’s territory is the sum of:

    • the number of coordinates marked B,

    • the number of white stones captured during the game, and

    • the number of dead white stones on the board.

  4. White’s territory is the sum of:

    • komi,

    • the number of coordinates marked W,

    • the number of black stones captured during the game, and

    • the number of dead black stones on the board.

Algorithm for finding other dead stones, given: - the coordinate of the new dead stone, - the coordinates of all stones of the same colour, and - the coordinates of the live stones of the other colour.

  1. Mark the stones of the same colour with ?, the live stones of the other colour with a (for alive), and all other coordinates with ..

  2. From the new dead stone, search in all directions, stopping at any a. Mark all ? encountered as d (for dead).

Planned flow for marking dead stones

  1. After two consecutive passes, the playing board is used for scoring.

    • The player that passed first gets an email announcement.

    • Both players are able to mark dead stones.

    • The link done appears, and is enabled.

    • Next to the done link, there is some opponent_done text; perhaps, (opponent has clicked done). This text is initially hidden.

  2. Clicking done sends the board state to the server.

    • A confirmation dialog is required. This helps with any race conditions: if an update has just been received from the opponent, this player will have a chance to notice.

    • The opponent gets an email.

    • The server stores the final board state for that user.

    • If the opponent has already clicked done and the final board states match, then the game is over.

    • If the opponent has already clicked done and the final board states do not match, then there has been a race condition (as should be evident after reading further)…​ hopefully, this situation is avoidable.

    • If the opponent has not already clicked done, then their opponent_done text is shown on their next update.

    • The done link is disabled.

  3. Clicking a stone on the board (either dead or alive) will send that stone to the server.

    • Send the coordinates of the stone that was clicked, as well as the supposed new owner.

    • The server saves the state of the stone, and sends back the new board state.

    • This is completed without link confirmation, since it can be undone…​ no need for the stupid-proof API used when playing the game.

    • If the opponent had previously clicked done, then the opponent’s final board state is cleared, the opponent receives an email, and this player’s opponent_done text is hidden again.

  4. Periodically, the UI polls the server for updates.

Details of client-side state transitions during scoring

There are lots of client-side bugs in the UI, so I’m going to get more specific. - has_opponent_moved request succeeds - you_have_passedscoring - Occurs when opponent clicks pass after you. - Hide the links about passing, etc., and show the done link. - Show initial territory calculations. - other possibilites not relevant. - you click pass - has_opponent_passedscoring - Occurs when you click pass after opponent. - Hide the links about passing, etc., and show the done link. - Show initial territory calculations. - other possibilites not relevant. - you mark_stone - scoringscoring - Occurs when you mark a group of stones. - May incorporate changes from opponent as well. - Update territory calculations. - opponent_is_donescoring - Occurs when you mark a group of stones. - Update the territory calculations. - you click done - scoringscoring - Occurs when you click done, but the server has a scoring_number higher than the one sent in. - Update the territory calculations. - Update scoring_number. - scoringyou_are_done - Occurs when you click done, and the server has the same scoring_number. - Disable the done link. - opponent_is_donegame_finished - Occurs when you click done. - Hide the done link. - Display game over text. - has_opponent_scored request succeeds - scoringscoring - Occurs when opponent mark_stone. - Update territory calculations. - Update scoring_number. - scoringopponent_is_done - Occurs when opponent clicks done. - Update territory calculations, since opponent may have used mark_stone. - Update scoring_number. - you_are_donescoring - Occurs when opponent mark_stone. - Enable the done link. - Update the territory calculations. - Update scoring_number. - you_are_doneopponent_is_done - Occurs when opponent mark_stone and then clicks done. - Enable the done link. - Update territory calculations. - Update scoring_number. - you_are_donegame_finished - Occurs when opponent clicks done. - Hide the done link. - Display game over text.

game-of-go's People

Contributors

awong-chromium avatar bjaress avatar davepeck avatar dexonsmith avatar sit avatar traveller42 avatar xcombelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

game-of-go's Issues

iOS can't "get going"

The "Create the game" link doesn't seem to work on iOS devices. I can fill out all the details but mashing create gets no effect. On both Safari and Opera.

Everything else works no problem :)

Duplicate chats

Sometimes I see the same chat message sent multiple times it seems like this happens when there is network latency..

Improve scoring images

The images added for scoring features in pull request #6 are really just placeholders, and are visually jarring. They should be replaced with images that are not nearly so ugly.

Feature: Add "rematch" button to end of scoring page

I'd love to re-challenge my mates after a game has ended, but currently it's hard work going to the root URL (yeah, I can't even find a 'home' button) and then re-inputting the same settings everytime.

It'd be great if there were a "rematch" button, which would just exchange colors and otherwise use same settings.

Update copyright dates and make licenses consistent

I figure this should only be done by Dave.

I don't know the requirements and what can/should be changed. However, you make the statement that this is released under the MIT license, but all the code still references the AGPL.

It is possible to make moves on stale boards.

It looks like this got broken recently, possibly with the Komi changes? Not sure yet.

As reported by Richard Jose:

I noticed that if you don't refresh the board (so it's still showing an old version of the game) and it is your turn (after having made turns elsewhere e.g. mobile phone) the board will still accept valid moves even though you aren't looking at the latest version of the board.

Fun.

Conversational links don't appear to work anymore?

Report from a user:

I am a Go beginner but big fan of your web go.davepeck.org.

Recently, after a long time, I started playing with a friend there again, and realised that an old function doesn´t seem to be working anymore?

If I recall correctly, it was possible to write in a comment a previous move (e.g. #12), click on this and it would be highlighted on the board. I am not sure if it was working exactly like this, but found it very useful to comment on previous moves and start the possible discussions about the alternatives to that.

If it was never a feature, please forgive me, last time I used the web was too long ago and my memory must be playing tricks on me.

Hopefully it is an easy fix and you have the spare time to help. In any case, thank you very much for this convenient and straight-to-the-point web to play go!!

(Right now, if I write a move, like #12, and click it, the web that attempts to open is:
http://go.davepeck.org/history/GAME ID/12/
And results in error 404 (tried in Chrome and Explorer))

Support "spectator" URLs

Games should include a shared "spectator" URL that allows anyone to view the game's current status. Optionally, it should allow spectators to participate in the chat.

SMS notifications

Twilio makes it cheap and easy. Possible pull request incoming if I have some spare cycles this month...

HTML5

I'm thinking updating to HTML5 will go a long way toward proper support of mobile devices.

Add ability to manage games associated with an email address

Sort of four related-ish features:

  • Introduce ability to create an account/establish a password
  • Introduce page with list of games and proper next-move links
  • Introduce ability to delete selected games
  • Introduce ability to delete account entirely

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.