Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Chess Game program

Introduction

Meet mchess

This is the home of mchess. Mchess provides a chess board, chess pieces, chess rules and an environment to support live games.

A chess game occurs between two players who use the pieces on the board with the assistance of the rules of the game to effect their strategies and eventually lose or win at endgame.

A chessboard is made of 64 squares that are arranged in an 8 x 8 grid.

A player performs actions by moving the chess pieces on the board.

There are 6 types of pieces in chess:

  1. King
  2. Queen
  3. Knight
  4. Bishop
  5. Rook
  6. Pawn

Each type of piece has its specific rules that govern its movements on the chess board. These rules specify the legal moves from location to location on the board.

Installation

  1. go get -u github.com/mesb/mchess
  2. cd /path/to/mchess –> This will be in your go workspace
  3. go build
  4. ./mchess

Analogy

For a 2D or 3D perspective, a chessboard is seen as a square. But who says we have to represent the board this way in the computer? The computer may have its own view that best suits its tasks and enjoyment of the board.

Chess is both a language and the game. The language is used to communicate actions during games. The may look something like:

  1. e4 e5
  2. Nf3 Nc6
  3. Bb5 a6

Move number 1 specifies that the piece(pawn) at location (e4) should be moved to (e5). That is, it should be moved forward, one step.

The chess language is like assembly for the chess machine. Hence, we can build chess as an interpreter.

A running chess game has the following essential pieces:

  1. chess board
  2. 2 players(black and white)
  3. chess pieces
  4. chess rules

The chess game is like an activity between 3 parties who have access to some pieces that they can move around a number of rooms. The rooms are built into a rather funny 64-storey building. The funny thing about the storey building is that each floor has only 1 room large enough support the activities of the game. The floors with their 1-room spaces are numbered from 0 to 63. There are some elevators in the real world that skip some floor numbers, but the elevator to this building has all the floors from 0 to 63.

Amongst the 3 parties, 2 of them, say Mola and Ni are the real players of the game. The 3rd person, say Xmac, is an executor of commands or a robot that performs the tasks it’s instructed to do. Xmac can fly to any of the floors of the 64-storey building and get or deposit a piece. Mola and Ni play the game taking turns and voicing their commands to Xmac.

The game starts with Mola and Ni having access to a demarcated portion of resources. That is, Mola and Ni own game pieces in the 64 rooms that are in the storey building. Let’s call the story building mondoni.

At the start, Mola’s pieces or task forces are arranged in the first 16 rooms. Ni’s pieces are arranged in the last 16 rooms. The remaining 32 rooms between them are empty and are the initial battle ground for the game.

The main game is for Mola or Ni to first capture his oponent’s King who will be housed in 1 of the rooms. Mola and Ni all have, at every given time, full understanding of the state of the game by virtue of the location of each other’s pieces.

It’s with information about where a player is, and where the oponent is, that players acquire their reason to make a certain move. In our case, it is the state of the game that is the reason behind any command given by Mola and Ni.

Xmac knows the rules of the game well, or perhaps it knows what to do in order to look rules up. When Xmac receives a command, it checks if the move is correct with the assistance of the rules of the game. For example, a pawn can’t move like a knight. Sometimes, one may give a wrong command; Xmac needs to know which commands are wrongs and/or illegal.

If a command is correct or legal, Xmac executes the command by going to the location of the piece in question and moving or displacing it to the commanded location. All the attacks and background activities that happen in the art of war that underlies this game are covered by the actions of Xmac.

Hence, Mola and Ni only need to trust Xmac with perfect execution. Xmac justly and efficiently executes their commands, moving their pieces around as they battle each other.

Other Notes

See Wiki @ Mchess Wiki

About

A chess playground

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages