let board =[0;0;0;0;0;0;0;0;0];;
I am trying to change the value of board
using the returned vals of some of the functions that I wrote.
This is going to be my game loop:
let rec f gamestate = match gamestate with
9 -> ()
| _ ->
let _ = print_board board in
let _ = print_string "\n" in
let _ = print_string "row: " in
let row = read_int () in
let _ = print_string "col: " in
let col = read_int () in
board = (player_move board row col);
(*trying to change the value of board to (player_move board row col)*)
f (gamestate + 1);;
f 0;;
I have ensured that all the functions perform as intended. I was able to do so by:
let _ = print_board (player_move board row col) in
This gives me the output as I expect it to be but I have no way of "saving" the newly modified board
Do I have to use an Object
instead?
The essential trick is to make board
a parameter of f. Then you can call f
recursively with the new board.