Skip to content

AlonVizniuk/book-scrabble-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book Scrabble (Java)

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 server
    • BookScrabbleHandler – handles QUERY / CHALLENGE requests
  • 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 MainTrain

Expected 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 ServerLauncher

The 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 = Q for QUERY or any other char for CHALLENGE
  • book1,book2,… = comma‑separated list of dictionary file names
  • word = the word to validate / challenge

Example (netcat):

echo -e 'Qtext1.txt,text2.txt,hello
' | nc localhost 5050

Server 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!

About

A Java-based Scrabble-like multiplayer word game with a custom board, dictionary caching (Bloom Filter, LRU, LFU), and a multithreaded client-server architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages