答案 0 :(得分:1)
您需要将const _makeMove = async (activePlayer) => {
try {
//Step 1 - take input
const proposedMove = await activePlayer.proposeMove();
//Step 2 - check if legal
if (!gameBoard.checkLegal(proposedMove)) {
throw new Error("bad entry");
}
//Step 3 - etc
//Step 4 - etc
//Step 5 - etc
} catch (e) {
console.log('oops bad entry!')
console.log("how it works: type 2 numbers ONLY, each between 1 and 3 (no spaces), to signify your move")
console.log("eg to place a mark into bottom left corner type 33. First cell = 11. Bang in the center = 22. You get it.")
console.log('lets try again...')
return _makeMove(activePlayer);
}
};
添加到PATH环境变量中。
library(shiny)
library(DT)
library(base64enc)
ui <- fluidPage(
tags$head(
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js")
),
br(),
DTOutput("dtable")
)
server <- function(input, output, session){
output[["dtable"]] <- renderDT({
datatable(
iris[1:5,],
extensions = "Buttons",
options = list(
dom = "Bfrtip",
buttons = list(
list(
extend = "pdfHtml5",
customize = JS(
"function(doc) {",
" doc.content.splice( 1, 0, {",
" margin: [ 0, 0, 0, 12 ],",
" alignment: 'center',",
sprintf(
" image: '%s',",
dataURI(
file = "https://www.r-project.org/logo/Rlogo.png",
mime = "image/png"
)
),
" width: 50",
" })",
"}"
)
)
)
)
)
})
}
shinyApp(ui, server)
。