✅ Trying to add tic tac toe board snapshot to variable for display of full match later
Code: https://paste.ofcode.org/n4KiPrNa8pyHiyWGuks93e
I'm trying to check some weird nonsense with ttt, specifically automating games to check some data. Part of that was seeing how the game behaves when you can overwrite symbols but your moves are random.
For that, I'm trying to keep a snapshot of every move. I have tried it with just outputting which cell it had overwritten, but because of my implementation that doesn't show the cell number if there was already a mark placed.
I can't seem to find a way to add the Board() output into a variable for later calling
7 Replies
That's because
Board
currently prints the board to the console, only
What you would do, is first create a string variable with the board, then add it to a list for snapshotting, and then print it out
Something like
Ah cool, thanks!
Actually testing it, I get an System.Collections.Generic.List`1[System.String] error. A quick search doesn't tell me much (too much of a beginner to understand how to fix the problem)
Instead of a string I'd recommend saving the moves only and not the whole game render
A collection cannot be printed as a string. It must be iterated
What error?
Ah, printing
Not an error, just calling the default
.ToString()
method of object
I did that before, but I'd have to rework the placing logic to do that. Currently, if it would land on a field that already has a symbol, it would not tell me which of the fields it has overridden, just the symbol that field had before
Angius
REPL Result: Success
Console Output
Compile: 475.646ms | Execution: 46.854ms | React with ❌ to remove this embed.
Nice, that works now!