Code Monkey home page Code Monkey logo

simplego.js's Introduction

simpleGo.js

A simple implementation of Go game in plain HTML, CSS and JavaScript. The project is still under development.

Introduction

Go is an abstract strategy board game for two players in which the aim is to surround more territory than the opponent. The game was invented in China more than 2,500 years ago and is believed to be the oldest board game continuously played to the present day.

References:


Pseudocode

I have created a pseudocode using an AI assistant (Google Bard) with some modifications made by me to be as the following:

Initialize game board (table using pre-defined size)
Fill the table with empty intersections

Set firstPlayerTurn to true
Set the game state as onGoing

While game onGoing:
	1. Display current game state
	2. Ask current player for input (move or pass)
	3. If input is move (x, y):
		a. If move is valid (not occupied and no self-capture):
			i. Place stone at (x, y)
			ii. Check if any opponent's stones are captured:
				- For each neighbouring intersection (up, down, left, right):
					- If neighbouring intersection has opponent's stone and no liberties:
						- Remove the stone and add a captured count to the player's score
			iii. Set firstPlayerTurn to false
		b. Else:
			i. Display error message and prompt the player to make another choice
			ii. Return
	4. Else if input is pass:
		a. Set firstPlayerTurn to false
	5. End the game by setting onGoing to false when:
		a. All intersections are occupied by stones OR
		b. Both players resign by passing his turn consecutively

Calculate and display the final score:
	Count the number of stones each player has on the board
	Add their captured stones to the total score

Determine and announce the winner:
	The player with the higher score wins
	If the scores are tied, the game is a draw

License

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.

simplego.js's People

Contributors

almadhoob avatar

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.