Giter Club home page Giter Club logo

chessboard's People

Contributors

jupiter24 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

wesavetheworld

chessboard's Issues

Read PGN

To read a PGN file, we need a function which converts move like "Nf3" in array("g1", "f3").
In this example it has to check for every knight on the board if it can reach f3. It should throw an exception if the move isn't clear (if there are to knights, which could move on f3). And of course it also has to understand moves like "Ngf3" or "N1f3" and "0-0", "0-0-0". It should remove + (check) at the end of a move.

We also need a function, which splits the PGN up into single moves and loads the meta data.

pawn move two squares forward

In its first move a pawn is able to move two squares forward. This has to be implemented in the isPossibleMove function.

createPgn function

There should be a function, which creates a PGN from the $moves list.

doMove function

At the moment the doMove function does absolutely nothing.
We need it for version 1.0.

createFEN function

Version 1.0 should have a function, which returns the FEN from the current position saved in $board.

Support variations

In PGN files there can be variations in parantheses. Of course they need to be parsed seomhow, but they also need to be stored in $moves.

Support en passant and castling in isValidMove

En passant and castling aren't supported yet by the isValidMove function.
(The isValidMove function does not have to be changed, we only need to change the isPossibleMove function).

Update doMove

The doMove function should also add the move to the $moves array.

Restructure isPossibleMove

isPossibleMove should do the check if there's a piece of the same color on the target square for all pieces together. Then it could also do the check for pieces of different colors together.

Save moves

For managing PGNs, the class needs a variable, in which the complete game (all moves) is saved.
This could be an array like this:

array(
   array("e2", "e4"),
   array("c7", "c5"),
   array("g1", "f3")
)

or like this:

array(
    "e4",
    "c5",
    "Nf3"
)

I think the first one is much better, because the moves like "Nf3" must be converted only once, when loading the PGN file and not every time they shall be used.

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.