I made tictactoe program for practice, however i wonder is there a way to get program output(text on screen) 1 at the time. heres example, this is how the program runs on eclipse
XO game by IronMan!
Player (X), Computer (O)!
____________
1 | 2 | 3
-----------
4 | 5 | 6
-----------
7 | 8 | 9
____________
Player X:1
Computer O:2
____________
X | O | 3
-----------
4 | 5 | 6
-----------
7 | 8 | 9
____________
Player X:9
Computer O:5
____________
X | O | 3
-----------
4 | O | 6
-----------
7 | 8 | X
____________
Player X:8
Computer O:7
____________
X | O | 3
-----------
4 | O | 6
-----------
O | X | X
____________
Player X:
is it possible to make it display only one grid and refresh it each turn.
XO game by IronMan!
Player (X), Computer (O)!
____________
X | O | 3
-----------
4 | O | 6
-----------
O | X | X
____________
Player X:
is it possible to make it display only one grid and refresh it each turn.
Not exactly sure what your asking but by grid if you mean the 3x3 board, I would get player input, calculate computer move, clear screen and redraw the board.
If you mean you only want to redraw the # and replace it with a X or O, I think it's possible, meaning I think I have seen it done with some ASCI games but not sure how you would do that.
Also, windows specific functions (Sleep) shouldn't be suggested without knowing the OP is on Windows. I have a feeling that this is going to turn into a sticky like the "Why does my console keep closing?" one.
As firedraco said, and the above articles, the console just isn't meant to do that. However, if you insist, there is several possibilities. I suggest doing research and deciding for yourself what is needed/absolutely necessary.
Since you haven't mentioned your platform (run on eclipse doesn't make any sense in terms of platform).
As per my perspective, every console has been built focusing on different goals. Using newlines won't be a good solution when you think of portability. One of the basic issue would be "line wrapping" in consoles.
So thinking about a having a good design of 'tictactoe' program which separates display information from game logic by providing a generic interface and having concrete displaying solutions for each relevant console would be a good idea.
As per my perspective, every console has been built focusing on different goals. Using newlines won't be a good solution when you think of portability. One of the basic issue would be "line wrapping" in consoles.
I believe you have the wrong concept of newlines. That's about as portable of a clearscreen as you can get. Output 100 new lines, there is now nothing on the screen. I fail to see how line wrapping has anything to do with this. Even if you meant word wrapping, that doesn't affect newlines. If you meant line wrapping in the sense that the console stores everything in essentially a large array and wraps back to the top, I don't know of any consoles that do this (it's possible that characters might still be left on the display) but that is going to be an issue overall with that specific console. Any console that I know of that might do that would clear the buffer before wrapping it around, to prevent garbage from being displayed. If you could show me an example, that'd be great.