Skip to content

jessiets/ScrabbleGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

ScrabbleGame

About:
A two-part class project on creating the game of Scrabble.

This project is completed in the language of C++ and focuses on the implementation of

  • object orientated design
  • STL classes
  • graphs: tries
  • backtracking search
  • exception error
  • Project Description

    Scrabble (and its clones like “Words with Friends”) is a game for typically 2-4 players, in which the players take turns placing tiles on a board, forming correct words, and gaining points for their words. However, to add more variety to the game, we expanded the program to include 1-8 human players. Of course, computer players can also be included under the condition that there must be at least one human player.

    Game Rules

    There are 3 kinds of moves a player can make: place a word, exchange tiles, or pass .
    Below are a few rules to keep in mind of when playing the game:

    If you choose to place a word,

    • Your tiles, together with tiles that are on the board, must form a single contiguous horizontal or vertical line - no gaps allowed.
    • You cannot place a tile on top of another previously placed tile.
    • Except for the first move of the game, at least one of the placed tiles must be adjacent (horizontally or vertically) to a previously placed tile.
    • For the first move of the game, one of your tiles must be on the start square.
    • Each maximal sequence (meaning that on both ends, it is bordered by an empty square or the end of the board) of two or more letters that is formed by your placement of tiles (notice that there could be multiple) must be a legal word according to the dictionary (see below). Sequences are read left to right, and top to bottom. Single letters are not considered words.
    • The moment you place a word including one or more blank tiles, those blank tiles are assigned letters (by you), which they keep for the rest of the game.

    Instead of placing a word, you may exchange anywhere from 1 to hand_size of your tiles with the bag. When you do this, you first return the tiles, and then you draw the same number of tiles from the bag to replace them (possibly getting some of the same tiles back). This ends your move.

    Lastly, you may pass your turn and not do anything.

    Start, Process, and End of Game

    • First, the program should ask you about who’s playing.

      After supplying the player name (e.g. Tommie), the program should ask if that player is a computer (y/n). “y” indicates computer. “n” indicates human. If users do not specify, the default player should be a human player.

    • Play proceeds in turn by player order.
    • The game ends in one of two ways:
      • Play finishes once a player runs out of letters when all tiles have already been taken from the bag.
      • Play can also finish if every single player passes their turn without any other moves occurring in that span.
    • When the game ends, each other player subtracts from their scores the sum of points of all tiles that they have in their hands. If the game ended because a player ran out of tiles, that player gets to add the sum of all other players’ tiles to his/her score.

    Syntax Rules for Input

  • The player can enter one of the three following moves (commands could be in upper or lower case, shown in uppercase):
    • PASS: the player simply passes his/her turn.
    • EXCHANGE <string of tiles>: the player wishes to discard these tiles back into the bag, drawing the same number of new tiles to replace them.
    • PLACE <dir> <row> <column> <string of tiles>: the player wishes to place a word on the board. The first tile will be placed in the given row and column (where counting starts at 1, not 0). Row 1 is the top row of the board, and column 1 is the leftmost column of the board. - indicates that tiles will be placed horizontally, and | indicates that tiles will be placed vertically. The string of tiles should be tiles from the player’s hand (no spaces), in the order in which they are to be placed. If the player wishes to use a blank tile, he/she uses ?, immediately followed by the character to be used for the blank. Note that if the player wants to start a word using an already placed letter or letters, then the user chooses <row> and <column> according to the first letter they place, not the first letter of the word.
  • Once a player makes a legal move, the word is permanently placed on the board.
  • Press return to continue.
  • Examples of Input Commands

    • PASS: pass the turn.
    • EXCHANGE aa?: put two tiles of the letter a and a blank tile back into the bag and draw three new tiles.
    • PLACE | 3 3 CAKE: put the tiles C, A, K, E down in order, starting at row 3, column 3, going down.
    • PLACE - 5 1 POE?MON: imagining that the previous move (CAKE) has been executed, and no other relevant tiles are around: place a horizontal word starting in row 5, column 1 (left border of the board), placing the tile P there, O in row 5, column 2, E in row 5, column 4, placing a blank tile that is interpreted as an M in row 5, column 5, and so on. This forms the word POKEMON with the K that was already there at row 5, column 3.

    Notice that when placing tiles, you do not specify the tiles that your word will also be using which are already on the board, only the ones you are adding (in order).

    Running the Game

    Since this program requires some text files and configuration, there is a folder called config that has all the required data to start the program. Simply type the following to start the program!

    First type make
    Then
     ./scrabble <configuration-file-name> 
    



    That's it for the instructions, hope you enjoy the game~

    About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published