Giter Club home page Giter Club logo

go-websocket's Introduction

Go over WebSocket

Go is an ancient game that involves two players competing on a grid for space. The goal is to surround the largest amount of area. See the above Wikipedia article for more information.

I started this project for three reasons:

  1. I like the game of Go
  2. Playing it requires a board and a bunch of stones (web is better than real life)
  3. I wanted to learn the HTML5 Canvas and WebSocket APIs

I started thinking about reason 3 during a talk at Cascadia Ruby conference in Portland, the speakers were showing off a WebSocket-based chat app that the audience was participating in.

TODO:

  • Implement Pair, Set, Graph
  • hook up graph North,South,East,West edges on Board.putPiece
  • Switch the order of the board coordinates so x is first, y is second
  • Add Queue#contains
  • Vertex holds a Pair of coordinates
  • Adding makes an edge from the pairs of the adjacent vertices
  • Use new Pair, Set and Graph types
  • Add Set#remove
  • Find neighborhood of vertex
  • Implement BFS to find connected components
  • Define libertiesCount() function to count the liberties of a component
  • Handle components of size 1
  • Add scoring rules to program
  • Make grid size variable
  • Save state in localStorage
  • Add clear board button
  • Hook up a WebSocket (before this, learn how to WebSocket)

Data Structures

The board is represented using a 2D array of Vertex objects, each of which has a color property.

The color defaults to null, but can be switched to black or white.

Each vertex is represented as a Pair of coordinates, and has up to four neighbors, for each pair of adjacent vertices, we use a Set to represent an undirected edge in a Graph.

Using the graph, a ComponentMap object is used to find the connected components, then expose an iterator that visits each component once.

edges only to adjacent pieces of same color

Algorithms

go-websocket's People

Watchers

 avatar

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.