Welcome to Dream.In.Code
Getting Help is Easy!

Join 108,967 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,383 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Tic tac toe board

 
Reply to this topicStart new topic

Tic tac toe board

carpeltunnel
post 12 Dec, 2007 - 06:20 PM
Post #1


New D.I.C Head

*
Joined: 12 Dec, 2007
Posts: 2


My Contributions


Hey guys, I am working on coding a tic tac toe game. I am just learning ruby, so i was wondering if you guys could help me out. In my program, i assumed i should create a class just for the board. I am pretty much clueless as to what the board class should contain though... methods obviously, but how would that end up? I'm not asking for code, just mere ideas.
Thanks!
User is offlineProfile CardPM

Go to the top of the page


spullen
post 12 Dec, 2007 - 07:09 PM
Post #2


D.I.C Regular

Group Icon
Joined: 22 Mar, 2007
Posts: 330



Dream Kudos: 50
My Contributions


the board class should hold an array representing the board, and maybe another array to hold all of the states that happened during the game. Have methods in the class to places x's or o's on the board, along with anoter method that checks to see if the game is complete.
You might also want to add a database of moves and an "AI" player that could play against a human using brute force serches on the moves.
User is offlineProfile CardPM

Go to the top of the page

carpeltunnel
post 13 Dec, 2007 - 02:45 PM
Post #3


New D.I.C Head

*
Joined: 12 Dec, 2007
Posts: 2


My Contributions


"The board class should hold an array representing the board." Okay, I understand that it should have an array, but I'm not really sure what you mean by "representing the board". Is there some way that I have to specify an area for each slot on the board (such as top left, middle top... etc.)? As for the array to begin with, I would just put something like this:
CODE
  class Board
    board = []


This post has been edited by carpeltunnel: 13 Dec, 2007 - 02:46 PM
User is offlineProfile CardPM

Go to the top of the page

spullen
post 16 Dec, 2007 - 08:27 PM
Post #4


D.I.C Regular

Group Icon
Joined: 22 Mar, 2007
Posts: 330



Dream Kudos: 50
My Contributions


well a 2d array, so you can have columns and rows.
So if you have a 3 x 3 array for the 3 columns and 3 rows on the tic tac toe board.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/4/08 10:13PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month