Comments (1)
This looks like a valid classical PGN movetext.
It is recommended to validate it with Chess\Movetext before processing as described in the docs.
use Chess\Variant\Classical\PGN\Move;
use Chess\Movetext;
$move = new Move();
$text = '1.d4 Nf6 2.Nf3 e6 3.c4 Bb4+ 4.Nbd2 O-O 5.a3 Be7 6.e4 d6 7.Bd3 c5';
$movetext = (new Movetext($move, $text))->validate();
print_r($movetext);
Thus, you may want to do something similar as in BoardToMp4.php.
use Chess\Variant\Classical\Board;
use Chess\Variant\Classical\PGN\Move;
use Chess\Movetext;
$board = new Board();
$move = new Move();
$text = '1.d4 Nf6 2.Nf3 e6 3.c4 Bb4+ 4.Nbd2 O-O 5.a3 Be7 6.e4 d6 7.Bd3 c5';
$movetext = new Movetext($move, $text);
if ($movetext->validate()) {
foreach ($movetext->getMovetext()->moves as $key => $val) {
$board->play($board->getTurn(), $val);
}
}
Also Chess\Player\PgnPlayer allows to play a PGN movetext.
use Chess\Player\PgnPlayer;
$movetext = '1.e4 c5 2.Nf3 d6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3';
$player = new PgnPlayer($movetext);
$board = $player->play()->getBoard();
I hope this will be helpful.
from php-chess.
Related Issues (20)
- Explain the implications of making a move
- Implement the partial pin evaluation
- Fix the protection evaluation
- En Passant Capture Square Incorrectly Identified HOT 2
- TDD the Chess\Eval\ThreatEval class
- TDD the Chess\Eval\AbsoluteSkewerEval class
- TDD the Chess\Eval\DeflectionEval class
- TDD the Chess\Eval\DiscoveredCheckEval class
- TDD the Chess\Eval\AdvancedPawnEval class
- TDD the Chess\Eval\DiagonalOppositionEval class
- TDD the Chess\Eval\FarAdvancedPawnEval class
- PHP 8.3 support
- TDD the Chess\Eval\BackRankEval class
- TDD the Chess\Eval\OverloadingEval class
- Castling is there while king has check HOT 1
- Fix the defense evaluation
- Fix the defense evaluation
- Fix the defense evaluation
- Improve the response time of the chessboard image recognizer HOT 1
- Write tests for Stockfish to play against itself
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-chess.