@Alberth & @Kercyn
Still this stuff in C++ confuses me a bit. Like, I know that when you need to pass a value to read it only, you need to put const keyword in front of the parameter, and pass it by reference (or pointer). However, I'm not sure when to use pass by reference or pass by pointer. As I've understood:
- pass by value means copying the object in the function's scope
- pass by reference means passing that specific object into the function
- pass by pointer means passing only the address of the object
Surprisingly, it allowed me to initialize the array without a constant expression. Not sure why and also not sure why you'd need a constant when you allocate the array on the stack.
As for the different syntax of the array, correct me if I'm wrong:
- Player players[numOfPlayers] would allocate the memory on the stack (or in the context where the array is declared - in this case the stack, because it is declared in function).
- Player * players = new Player[numOfPlayers] would allocate memory on the heap while keeping a reference on the stack.
- delete  players would free the heap memory allocated for the array, but the players reference would still remain. Therefore, a players = nullptr would be good practice after the delete. Am I correct?
Thanks for the tips, guys. This game is a way for me to learn to program in C++ and to do games development. I skipped the basic checks and the flow of the game lacks stuff because I wanted to concentrate on things that I found confusing. Things like making the game use a bot when there's only one player, doing some artificial intelligence, although my bot is reaaaaaaaly dumb now. I am still not really sure how should I go about making it smarter.
I am thinking of making my bot look for situations where the other player could win. For example, when the bot finds two X's in row, he should put his mark on the cell that's empty on that row. Some tips on AI would be appreciated (everything I find on the web now is too confusing... minimax algorithm? It seems to complex for me, for now).
Also, one other thing that I'd like to do is provide a GUI for the game. I kind of learn by doing. :)