A complete Scrabble‑like word‑game engine written in pure Java.
The project demonstrates advanced data‑structure design, efficient
dictionary look‑ups with Bloom filters and two cache policies, and a
simple multi‑threaded client–server model.
## Project Highlights
- Board engine – 15 × 15 board, special tiles (DL, TL, DW, TW, ⭐), scoring & validation
- Tile bag – correct English letter distribution, scores, random draw / put‑back
- Dictionary stack
- Bloom filter (fast negative look‑up)
- LRU and LFU caches
- Fallback file scan (
IOSearcher)
- Caching framework – pluggable replacement policy (
CacheReplacementPolicy) - Server side
MyServer– multi‑threaded socket serverBookScrabbleHandler– handlesQUERY/CHALLENGErequests
- Full unit‑style test harness in
MainTrain.java
## Directory Layout
src/
├── MainTrain.java
├── board/
│ ├── Board.java
│ ├── Tile.java
│ └── Word.java
├── dictionary/
│ ├── BloomFilter.java
│ ├── CacheManager.java
│ ├── CacheReplacementPolicy.java
│ ├── Dictionary.java
│ ├── DictionaryManager.java
│ ├── IOSearcher.java
│ ├── LFU.java
│ └── LRU.java
├── server/
│ ├── BookScrabbleHandler.java
│ ├── ClientHandler.java
│ └── MyServer.java
├── text1.txt # sample dictionary data (auto‑generated by tests)
├── text2.txt
└── README.md # you are here
## Quick Start
### Prerequisites
- Java 8 or newer
- A terminal / shell (or an IDE such as IntelliJ IDEA / Eclipse)
### Build
# clone / copy the repo, then:
mkdir -p bin
javac -d bin $(find src -name "*.java")Windows CMD
mkdir bin
for /R src %f in (*.java) do javac -d bin %f### Run the built‑in tests
cd bin
java MainTrainExpected console tail:
done
(The MainTrain class prints detailed messages if anything fails.)
## Running the Server
The test suite does not start the socket server for you; the snippet below shows the minimal bootstrap:
import server.BookScrabbleHandler;
import server.MyServer;
public class ServerLauncher {
public static void main(String[] args) {
MyServer server = new MyServer(5050, new BookScrabbleHandler());
server.start();
System.out.println("Server running on port 5050");
}
}Compile & launch:
javac -d bin src/ServerLauncher.java
java -cp bin ServerLauncherThe server’s main loop accepts clients until server.stop() is called
from another thread.
## Client Protocol
BookScrabbleHandler expects a very simple one‑line request:
<OP><book1,book2,…,word>
OP=Qfor QUERY or any other char for CHALLENGEbook1,book2,…= comma‑separated list of dictionary file namesword= the word to validate / challenge
Example (netcat):
echo -e 'Qtext1.txt,text2.txt,hello
' | nc localhost 5050Server responds with:
true
or
false
followed by \n.
Tip: You can write a small Java or Python client, or test quickly with utilities such as
telnet/nc.
## Customization
| Area | Where to look | Ideas |
|---|---|---|
| Board layout | board/Board.java |
Change premium tile map |
| Letter distribution | board/Tile.java |
Adjust quantities / scores |
| Cache size & policy | Dictionary.java, CacheManager.java |
Plug different policies, tweak sizes |
| Server protocol | server/BookScrabbleHandler |
Add authentication, richer commands |
| GUI / Web front‑end | – | Build a Swing, JavaFX, or React client |
## License
This repository is released as‑is for educational use.
No warranty, express or implied.
Enjoy hacking on Book Scrabble!