Welcome to Dream.In.Code
Become an Expert!

Join 136,936 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,847 people online right now. Registration is fast and FREE... Join Now!




Tic tac toe board

 
Reply to this topicStart new topic

Tic tac toe board

carpeltunnel
12 Dec, 2007 - 05: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
+Quote Post

spullen
RE: Tic Tac Toe Board
12 Dec, 2007 - 06:09 PM
Post #2

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 330



Thanked: 1 times
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
+Quote Post

carpeltunnel
RE: Tic Tac Toe Board
13 Dec, 2007 - 01: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 - 01:46 PM
User is offlineProfile CardPM
+Quote Post

spullen
RE: Tic Tac Toe Board
16 Dec, 2007 - 07:27 PM
Post #4

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 330



Thanked: 1 times
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
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:46PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month