04Educational Tool

Formal Language Typing Game

An interactive Python/Tkinter game visualizing formal language theory in real-time — regular expressions, palindromes, and balanced parentheses validation using stack-based logic.

PythonTkinterStack LogicRegexAutomata Theory
View on GitHub
3
Formal Languages
Real-time
Validation
GUI
Interface
Drag to rotate scene
type
Educational Tool
status
Completed
year
2024
role
Solo Developer
01

System Architecture · 3D View

02

Architecture Diagram

Tkinter GUI
User Interface
User Input
Keyboard Events
Regex Engine
Pattern Matching
Stack Automaton
Palindrome / Parens
Scoring System
Points · Timer
Visual Feedback
Correct / Wrong
03

Screenshots & Output

terminal
$ python3 main.py
Formal Language Typing Game v1.0
Level 1: Regular Expressions
Pattern: ^(a|b)*abb$
Input "aabb" → ✓ VALID +10 pts
Input "ababb" → ✓ VALID +10 pts
Input "abba" → ✗ INVALID -5 pts
Level 2: Balanced Parentheses (PDA)
Input "((()))" → ✓ Stack empty — VALID +15 pts
Score: 135 / 200 Time: 00:45 Accuracy: 87%
$
Game Session
Live typing validation output
Accuracy Scores
Regex (Level 1)87%
Palindrome82%
Balanced Parens91%
User Accuracy85%
Realtime Val.96%
Accuracy Scores
Per-language accuracy rates
Data Output
{
"language_type": "regular",
"pattern": "^(a|b)*abb$",
"automaton": "DFA",
"states": 4,
"input": "aabb",
"accepted": true,
"stack_trace": ["q0→q1→q2→q3"]
}
State Machine
Automata configuration
Project Structure
📁 formal-language-game/
├─ main.py Game loop
├─ regex_engine.py RE validator
├─ automata.py DFA / PDA logic
├─ scoring.py Points + timer
├─ levels/
│ ├─ level1_regex.py
│ └─ level2_pda.py
└─ tkinter_ui.py GUI
Source Structure
Python module layout
04

What I Built

Designed a Python-based interactive game using Tkinter for real-time formal language concept visualization.

Implemented algorithms for regular expressions, palindromes, and balanced parentheses validation.

Developed data processing functions to enhance user interaction and improve learning outcomes.

Applied stack-based logic and automated error detection to refine gameplay mechanics.

05

Project Insights

Personal Notes & Learnings
Markdown Editor
Live Preview

Learning Goal

Make formal language theory tangible and interactive for CS students.

Implementation Choices

  • Tkinter chosen for zero-dependency desktop GUI
  • Stack-based DFA for balanced parentheses was elegant to implement
  • Regex compilation cached at startup for real-time feedback

What I Would Change

  • Port to a web app (Flask + JS) for broader accessibility
  • Add difficulty progression and leaderboard
✓ Insights saved locally