-
Notifications
You must be signed in to change notification settings - Fork 0
/
shiny_state_board.R
85 lines (78 loc) · 2.51 KB
/
shiny_state_board.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
library(shiny)
source('board_state.R')
s <- c("x", "_", "o")
ui <- pageWithSidebar(
headerPanel("Board encoding"),
sidebarPanel(
numericInput(inputId = "state",
label = "State code",
value = 0,
min = 0,
max = 19682,
step = 1),
tableOutput("stateboard")
),
mainPanel(
fluidRow(
column(3,
h4("Column 1"),
selectInput(inputId = "oneone",
label = "1-1",
choices = s,
selected = "x"),
selectInput(inputId = "twoone",
label = "2-1",
choices = s,
selected = "x"),
selectInput(inputId = "threeone",
label = "3-1",
choices = s,
selected = "x")
),
column(3,
h4("Column 1"),
selectInput(inputId = "oneone",
label = "1-1",
choices = s,
selected = "x"),
selectInput(inputId = "twoone",
label = "2-1",
choices = s,
selected = "x"),
selectInput(inputId = "threeone",
label = "3-1",
choices = s,
selected = "x")
),
column(3,
h4("Column 3"),
selectInput(inputId = "onethree",
label = "1-3",
choices = s,
selected = "x"),
selectInput(inputId = "twothree",
label = "2-3",
choices = s,
selected = "x"),
selectInput(inputId = "threethree",
label = "3-3",
choices = s,
selected = "x")
)
),
verbatimTextOutput("boardstate")
)
)
server <- function(input, output) {
output$stateboard <- renderTable({
stateToBoard(as.integer(input$state), "x")
})
output$boardstate <- renderPrint({
b <- matrix(data = c(input$oneone, input$onetwo, input$onethree,
input$twoone, input$twotwo, input$twothree,
input$threeone, input$threetwo, input$threethree),
nrow = 3, ncol = 3)
boardToState(b, "x")
})
}
shinyApp(ui = ui, server = server)