Sign in to follow this  

Lines in tic-tac-toe

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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's
Get Input
Ask player for board position (1-9)
Get position
Check position is valid
Etc etc.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I say write the entire thing out using as many lines as you need. Then when it's finished and working how you want, start looking for ways to accomplish the same thing with less code. Once you have a working version it'll be much easier.

Share this post


Link to post
Share on other sites
my first ttt was about 300 lines (always including comments and blank spaces), but i just had to make it more effective just to have soemthing to talk/brag about... heh... anyhoo, i got it down to just over a hundred (can't remember actual figure, but i don't think it was more than 120)... they can be found at http://www.geocities.com/antigatez/pimplesttt.html

Share this post


Link to post
Share on other sites

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this