Comments (6)
Also think it should be
gamemove <- 2 *(move-1) + (player != "white")
from rchess.
How about this?
# function to get fens from a pgn game.
library("purrr")
get_fens <- function(pgn) {
chss <- Chess$new()
chss$load_pgn(pgn)
moves <- chss$history()
chss$reset()
fens <- map_chr(moves, function(x) chss$move(x)$fen())
fens
}
data("chesswc")
game <- head(chesswc,1)
pgn <- game$pgn
fens <- get_fens(pgn)
player <- "white"
move <- 11
gamemove <- 2 * move + (player != "white")
fens[gamemove]
[1] "r2qkb1r/p4ppp/b1n1pn2/8/PpNP4/1P6/5PPP/RNBQKB1R w KQkq - 1 12"
ggchessboard(fens[gamemove])
Now we can iterate for every fen and try to create the gif as requested in #9
from rchess.
Wonderful.
Only quibble is could dispense with axis titles and label the x as a:h
Also possibly replicate left axis on right and bottom axis at top
from rchess.
I'll fix the axis :B, but not sure how to add the opposites axis. Im not sure if ggplot have this options.
from rchess.
Just found this. looks promising re double axes
library(ggplot2)
library(cowplot)
p <- ggplot(mtcars, aes(mpg, disp)) + geom_line(colour = "blue")
ggdraw(switch_axis_position(p , axis = 'xy', keep = 'xy')).
from rchess.
Nice, I'll check it.
from rchess.
Related Issues (14)
- Get captured material
- get_header funcionality HOT 1
- Bug in history_detail HOT 2
- simultaneous castling and check HOT 1
- Can't load pgn! HOT 3
- Implement a chess engine HOT 2
- Adding chessboard themes
- Enhancement Request: Animation for Individual game HOT 6
- Unclear why this is an invalid move HOT 2
- Input moves via shiny? HOT 2
- Build Fail HOT 1
- wrong pgn in the chessopenings dataset
- plot problem on google colab
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 rchess.