GithubHelp home page GithubHelp logo

Comments (6)

pssguy avatar pssguy commented on June 11, 2024 1

Also think it should be

gamemove <- 2 *(move-1) + (player != "white")

from rchess.

jbkunst avatar jbkunst commented on June 11, 2024

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])

image

Now we can iterate for every fen and try to create the gif as requested in #9

from rchess.

pssguy avatar pssguy commented on June 11, 2024

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.

jbkunst avatar jbkunst commented on June 11, 2024

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.

pssguy avatar pssguy commented on June 11, 2024

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.

jbkunst avatar jbkunst commented on June 11, 2024

Nice, I'll check it.

from rchess.

Related Issues (14)

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.