Skip to content

shezdev/tictactoe_ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe - Practice tech test

Brief description of what the project is, what it does

Getting started

git clone path-to-your-repo command_to_install_dependencies (e.g. bundle)

Usage

[(1) How to install it (what to clone, what to run to get all dependencies)]

command_to_start (e.g. rackup or rails s) Navigate to http://localhost:4567/

[(2) How to run it (is it a command line tool? Do you have to load it into IRB? Is is a web application? What port needs to be used?)]

Running tests

test_command (e.g. rspec)

Later on, you can add screenshots and additional information to your heart's content, but make sure you have this with all your repos as you proceed through the course. You will thank yourself later. https://github.com/matiassingers/awesome-readme

Image Title

Rules

  • 2 players in game
  • Players can take turns until the game is over
  • A player can claim a field if not already taken
  • Turn ends when a player claims a field
  • A player wins if they claim all the fields in a row, column or diagonal
  • A game is over if the player wins
  • A game is over when all the fields are taken

Domain Model

Object (Nouns) Messages (verbs)
PLAYER has a MARKER, takes a turn, claims a FIELD, wins, loses or draws a GAME
MARKER is "X" or "Y", can be placed on a FIELD
GAME is played by 2 PLAYERS, has a BOARD
FIELD is on a BOARD, has MARKERS
BOARD has 9 FIELDS

User Stories

As a PLAYER
When I start a GAME of Tic Tac Toe
Myself and my opponent will be allocated a MARKER ("O" or "X") randomly.

As a PLAYER
When I am prompted to take my turn
I will place my MARKER on an empty FIELD on the BOARD.

As a PLAYER
When my turn is over
A second PLAYER will take their turn.

As a PLAYER
If my turn results in 3 MARKERS in a row, column or diagonal on the BOARD.
I win, and the GAME is over.

As a PLAYER
If the second player's turn results in 3 MARKERS in a row, column or diagonal on the BOARD
I lose, and the GAME is over.

As a PLAYER
If it is my turn, and I use the last empty space on the BOARD without resulting in a winning combination
It is a draw, and the GAME is over.

PLaying

feature test 1

# require "./lib/game.rb"
#  => true
# >game = Game.new
#  => #<Game:0x007fa2a40a3018 @player1=#<Player:0x007fa2a40a2ff0 @marker="">, @player2=#<Player:0x007fa2a40a2f50 @marker="">>
# > game.play
#  => "O"
# > game.player1
#  => #<Player:0x007fa2a40a2ff0 @marker="X">
# > game.player2
#  => #<Player:0x007fa2a40a2f50 @marker="O">
# > game.player1.marker
#  => "X"
# > game.player2.marker
#  => "O"

feature test 2


About

Practice tech test | Tic Tac Toe game | Fully TDD | Written in Ruby

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages