MatrixLogic is a terminal-based logic puzzle game (widely known as Takuzu or Binary Puzzle). This project was developed as a practical assignment for the Programming Fundamentals course (First quarter, 1st Year of Computer Engineering).
The game challenges the player to fill a dynamic grid using only 'X' and 'O' tokens, adhering to a strict set of logical constraints. It features multiple randomized boards parsed from a local text database and a robust Undo system.
To successfully solve a board, the following conditions must be met:
- Immutable Seed: Initial uppercase tokens (
XandO) cannot be modified. - Equilibrium: Each row and each column must contain the exact same number of
Xs andOs. - No Triples: No more than two identical elements can be placed consecutively in any row or column.
- Uniqueness: No two rows can be identical. No two columns can be identical.
- Language: Java 8+
- Interface: Command-Line Interface (CLI)
- Stack-Based History (Undo System): Leverages
java.util.Stack(LIFO) to store deep copies of board states, allowing the user to seamlessly revert their moves dynamically step-by-step to the very beginning. - File Parsing & I/O Optimization: Uses
BufferedReaderwrapped in atry-with-resourcesblock to safely and efficiently read level layouts dynamically from a.txtdatabase. - Matrix Validation Algorithms: Implements 2D array traversal algorithms to validate the grid against complex geometric rules (row/column equivalence and contiguous character counting).
- Defensive Input Parsing: Robust console input validation with dynamic coordinate boundaries parsing (e.g., handling boundaries for inputs like
1Aor12D).
Note: The game requires the tableros.txt file to be located in the root directory alongside the executable to load the levels properly.
1. Clone the repository:
git clone [https://github.com/Ivanlaguna511/MatrixLogic.git](https://github.com/Ivanlaguna511/MatrixLogic.git)
cd MatrixLogic2. Compile the Java file:
javac MatrixLogic.java3. Run the application:
java MatrixLogic-Iván Moro Cienfuegos and Diego Martín García