Current state analysis Current setup: 6×6 grid = 36 states 4 actions (cardinal directions) Q-table size: 36 × 4 = 144 Q-values Optimal path: 10 steps (5 right + 5 down) With diagonals: 8 actions (4 cardinal + 4 diagonal) Q-table size: 36 × 8 = 288 Q-values Optimal path: ~7 steps (diagonal moves) Still manageable for tabular Q-Learning When to use Q-Learning vs DQN Q-Learning (Tabular) — current approach Good for: Small state spaces (current: 36 states) Discrete, finite states Fast learning on small problems Interpretable (you can inspect the Q-table) Low memory/compute Limitations: Doesn't scale well to large state spaces Can't generalize to unseen states Needs to visit every state-action pair Example scaling: 6×6 grid, 8 actions = 288 values (fine) 20×20 grid, 8 actions = 3,200 values (still fine) 100×100 grid, 8 actions = 800,000 values (starts to struggle) With obstacles/features per cell → state space explodes DQN (Deep Q-Network) Good for: Large state spaces (e.g., 50×50+ grids) Complex state representations (e.g., raw pixels, multiple features) Generalization to similar but unseen states Partial observability (e.g., limited vision range) Continuous or high-dimensional observations Trade-offs: More complex (neural network, hyperparameters) Needs more data/compute Less interpretable (harder to inspect) Requires experience replay, target networks, etc. Improvement possibilities
- Add diagonal movement (8 actions) Impact: Faster optimal paths (~7 steps vs 10) Slightly larger Q-table (288 vs 144) Q-Learning still works well When DQN helps: Not needed for this change alone.
- Larger grids (20×20, 50×50) Impact: 20×20: 400 states × 8 actions = 3,200 values (Q-Learning OK) 50×50: 2,500 states × 8 actions = 20,000 values (Q-Learning borderline) 100×100: 10,000 states × 8 actions = 80,000 values (DQN recommended) When DQN helps: Grids 50×50 and larger, or when state features grow.
- Multiple/moving traps Impact: Multiple traps: state space stays the same (still just agent position) Moving traps: state space grows (agent position + trap positions) 6×6 grid, 3 moving traps: 36 × 36 × 36 = 46,656 states (DQN recommended) When DQN helps: Dynamic environments with moving obstacles.
- Partial observability (limited vision) Impact: Agent sees only nearby cells (e.g., 3×3 window) State = local view (9 cells) instead of full grid Q-Learning struggles (many similar local views) DQN can learn to interpret local patterns When DQN helps: Partial observability, vision-based inputs.
- Rich state representation Current: Just (x, y) coordinates Enhanced: Include distance to goal, distance to trap, direction to goal, etc. Impact: Q-Learning: Can work if you discretize features DQN: Better at learning from continuous features When DQN helps: Continuous or high-dimensional features.
- Curriculum learning (start small, grow) Impact: Start 3×3, then 6×6, then 10×10, etc. Q-Learning can work at each stage DQN can transfer knowledge across sizes When DQN helps: Transfer learning across grid sizes.
- Sparse vs dense rewards Current: Sparse (only at goal/trap) Dense: Small reward for moving closer to goal Impact: Dense rewards help both Q-Learning and DQN learn faster DQN can benefit more from reward shaping Recommendation for your case For now (6×6 grid, adding diagonals): Stick with Q-Learning Add 8 actions (diagonals) Q-table: 288 values is manageable Fast to train and easy to understand Switch to DQN when: Grid size > 30×30 Multiple moving obstacles Partial observability (limited vision) Complex state features (e.g., terrain types, enemies) You want to learn from raw pixels/images Learning path suggestion Add diagonals to Q-Learning (8 actions) Scale to 10×10, then 20×20 (still Q-Learning) Add moving traps (consider DQN) Add partial observability (DQN recommended) Try DQN for comparison and learning DQN advantages for learning Experience replay: learns from past experiences Target networks: more stable learning Neural network: learns complex patterns Generalization: works on similar but unseen states