Coder Social home page Coder Social logo

unays7 / chess_pgn_parser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

A chess game parser and board position tracker in C++. Takes a filename as its single command-line argument. Files will contain a chess game in PGN notation (https://en.wikipedia.org/wiki/Portable_Game_Notation).

CMake 1.96% C++ 98.04%

chess_pgn_parser's Introduction

chess_pgn_parser

A chess game parser and board position tracker in C++. Takes a filename as its single command-line argument, files will contain a chess game in PGN notation (https://en.wikipedia.org/wiki/Portable_Game_Notation) and outputs the final board state accounting for all the moves in the game.

Sample Input:

[Event "F/S Return Match"]
[Site "Belgrade, Serbia JUG"]
[Date "1992.11.04"]
[Round "29"]
[White "Fischer, Robert J."]
[Black "Spassky, Boris V."]
[Result "1/2-1/2"]
1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.}
4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7
11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5
Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6
23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5
hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5
35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3

Sample Output:

Event : F/S Return Match
Site  : Belgrade, Serbia JUG
Date  : 1992.11.04
Round : 92
White : Fischer, Robert J.
Black : Spassky, Boris V.
Result: 1/2-1/2

  |  |  |  |  |  |  |  
  |  |  |  |  |  |  |  
wR|  |  |  |  |  |bP|  
  |  |bK|  |  |bB|bP|  
  |bP|  |  |  |  |  |  
  |wP|  |  |  |wP|wP|bN
  |  |  |  |  |  |  |  
  |  |  |  |wK|  |  |  

chess_pgn_parser's People

Contributors

unays7 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.