This is a Haskell implementation of Scrabble.
Todo: GUI, Network game server, AI engine.
First things first, install stack: http://docs.haskellstack.org/en/stable/README.html#how-to-install
And then jump up on the repl:
$ stack ghci
*Scrabble> let hell = ("HELL", Vertical, (7,7))
let has = ("HAS", Horizontal, (5,6))
let as = ("AS", Horizontal, (5,7))
let (b,s) = quickPut [hell, has, as]
*Scrabble> printBoard True b
______________________________________________
|3W| | |2L| | | |3W| | | |2L| | |3W|
| |2W| | | |3L| | | |3L| | | |2W| |
| | |2W| | | |2L| |2L| | | |2W| | |
|2L| | |2W| | | |2L| | | |2W| | |2L|
| | | | |2W| | | | | |2W| | | | |
| |3L| | | |3L| | | |3L| | | |3L| |
| | |2L| | | H| A| S|2L| | | |2L| | |
|3W| | |2L| | A| S| H| | | |2L| | |3W|
| | |2L| | | |2L| E|2L| | | |2L| | |
| |3L| | | |3L| | L| |3L| | | |3L| |
| | | | |2W| | | L| | |2W| | | | |
|2L| | |2W| | | |2L| | | |2W| | |2L|
| | |2W| | | |2L| |2L| | | |2W| | |
| |2W| | | |3L| | | |3L| | | |2W| |
|3W| | |2L| | | |3W| | | |2L| | |3W|
----------------------------------------------
*Scrabble> s
[14,14,13]
Start a new game:
*Scrabble> start [human "Josh", human "Stephen", human "Andrew"]
Place the word 'rest' vertically at position (7,7). You can only place things in your rack.
(place REST V (7 7))
*Scrabble> cheat (matchAll [containsAny "z", containsLetterAtPos 'w' 4])
["buzzwig","buzzwigs","buzzword","buzzwords","unbowdlerized","zugzwang","zugzwanged","zugzwanging","zugzwangs"]
*Scrabble> cheat (matchAll [containsAny "x", containsLetterAtPos 'b' 4, endsWith 'g'])
["exhibiting","exorbitating","extubating","kickboxing","soapboxing"]
$ tree src
.
├── Scrabble
│ ├── Bag.hs -- Tile and Bag representation
│ ├── Board -- Scrabble board related code
│ │ ├── Board.hs -- Board representation and functions
│ │ ├── Orientation.hs -- Horizontal and Vertical functions and data
│ │ ├── Point.hs -- Simple code to work with (x,y) coordinates
│ │ └── Square.hs -- Squares on the board
│ ├── Commands -- Code for inputting game commands
│ │ ├── AST.hs -- AST for player input (and parsing)
│ │ ├── Interpreter.hs -- Interpreter for player input
│ │ └── SExpr.hs -- Generic sexpr parser
│ ├── Dictionary.hs -- Letter and Dictionary representation
│ ├── Game.hs -- Player and Game state representation
│ ├── Move -- Making a move, validation, scoring, etc
│ │ ├── Move.hs -- Move representation and functions to make moves
│ │ ├── Scoring.hs -- Calculates score for a move
│ │ ├── Validation.hs -- Checks to see if a move is valid
│ │ └── WordPut.hs -- Representation of tiles put on the board in a turn
│ ├── NonEmpty.hs -- Helper functions for NEL
│ ├── ReplHelpers.hs -- Some quick testing helper functions for use on the REPL
│ └── Search.hs -- Code for searching the dictionary
│ └── Tile.hs -- Tile representation
└── Scrabble.hs