Lines in tic-tac-toe

Started by
10 comments, last by pimple 19 years, 6 months ago
About how many lines of code do you think a tic-tac-toe game should have if it's written in the C language.
Advertisement
Assuming in console mode, probably a few hundred. Why does it matter?
yea in console mode. I want to make sure I don't have any "lazy code" and how much is a few hundred, 300?
I'd guess about 300 or 400, yeah. What do you mean "lazy code"?
The number of lines of code in an application really doesn't matter. You could probably write tic-tac-toe in about 50 lines, but it would be horrible. Or you could write it in 1000 lines, with loads of flashy (console mode) graphics.
by lazy code I mean not having good solid algorithms.
Well, the number of lines of code won't really help you judge that. If you write down an algorithm first, and try to stick to it when coding, that'll help. E.g.
Draw board   Draw lines   Draw X's   Draw O'sGet Input   Ask player for board position (1-9)   Get position   Check position is valid
Etc etc.
mine is kinda more flashy than that. It actually uses windows!!! console windows using the ncurses library that is.

BTW before starting a project like tic-tac-toe would you first plan and then start coding?
Quote:Original post by subflood
BTW before starting a project like tic-tac-toe would you first plan and then start coding?


The most important thing is ofcourse to figure out the maximum lines of code that you allow!!!!

/MindWipe
"To some its a six-pack, to me it's a support group."
I wrote mine in 155, including comments. So 300 should be plenty.

The difference with a game like tic-tac-toe is that it is very easy to plan. Infact, Evil already planned it for you. But writing out how you want your program to run is very crucial for large scale projects. Its good to get the practice with small ones, and normally leads to more legible, more constructed, and faster programs.
It takes as many lines as it takes, really. The way to tell if you wrote too much is to look for duplication. And if you find some, fix it!

This topic is closed to new replies.

Advertisement