I would like to store an Array (Tic Tac Toe Game (initialized) position 3 X 3 array of string(A = fill(“”,3,3)) in a list array. The game A gets filled with moves of X and O, so my list of game positions would have a list [ A1… first board position,moves filling X and O, A2 second move (this would have all the previous moves and then A3 etc.] [[“X” “” “” ; “” “” “”; “” “” “O”], [ "X “X” “”; “” “” “O”; “” “O” “O”]] …]
How would I fill an list or array with the A1,A2 ,A3,…game positions? My code updates the previous positions which is not what I want. I tried to paste the screen snippet for the output. but I do not see it.
type or paste code
C = []
A = fill("",3,3)
for i in 1:2
listgamestate = []
listpossmove= [1,2,3,4,5,6,7,8,9]
selectedmove = rand(listpossmove)
println("selected move",selectedmove)
A[selectedmove] = "X"
#println(A)
push!(C, A)
println(C)
println()
listpossmove = filter(x ->x!= selectedmove, listpossmove)
selectedmove = rand(listpossmove)
#println("selected move",selectedmove)
A[selectedmove] = "O"
#println("O selected",A)
C = push!(C,A)
println(C)
listpossmove = filter(x ->x!= selectedmove, listpossmove)
end