Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input moves via shiny? #11

Open
McCartneyAC opened this issue Jul 2, 2018 · 2 comments
Open

Input moves via shiny? #11

McCartneyAC opened this issue Jul 2, 2018 · 2 comments

Comments

@McCartneyAC
Copy link

Hi! I love that you've made and kept up this package. I'm trying to build a shiny app and I'm having a hell of a time getting user-input moves to register via your example code, e.g. chss$move("f4") .
The typical error I'm getting is : Error:attempt to apply non-function because it's treating the chss environment as, well, an environment and so calling chss$mov() isn't a function that can be embedded within a reactive wrapper. Does that make sense?

I'm trying to implement this code:

ui = shinyUI(
  fluidPage(
      # chessboardjsOutput('board', width = 300), 
      textInput("mv", "Input Your Move", placeholder = "Move"),
      actionButton("make_move", label = "Move", icon = icon("chess")),
      tags$p("Available Moves"),
      textOutput(outputId = "avail"), 
      tags$p("Move History"),
      tableOutput(outputId = "hist"),
      tags$p("Turn:", textOutput(outputId = "turn_is"))
      )
    )
  

server = function(input, output, session) {
  
  chss <- Chess$new()
  chss<-observeEvent(input$make_move, {
    chss$move(quote(mv)) 
  }, 
  ignoreNULL = T)
  # output$board <- renderChessboardjs({
  #   chessboardjs()
  # })
  output$avail<-reactive({
    chss$moves()
  })
  output$turn_is<-reactive({
    chss$turn()
  })
  output$hist<-reactive({
    chss$history(verbose=T)
  })
   

  
}

shinyApp(ui = ui, server = server)
@R-icntay
Copy link

R-icntay commented Jun 7, 2022

Hello @McCartneyAC, were you able to figure this out? Thank you.

@McCartneyAC
Copy link
Author

No, I gave up on the project and forgot I ever posted this error. I think the issue is that the rchess package stores information about the game as an object and I'm not great at OOP (which is why I like R and Shiny in the first place!)

if you make progress on it, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants