-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_checkpoint.js
More file actions
175 lines (148 loc) · 9.97 KB
/
validate_checkpoint.js
File metadata and controls
175 lines (148 loc) · 9.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
* Checkpoint 8 Validation Script
* Validates that core AI and gameplay mechanics are implemented correctly
*/
const fs = require('fs');
const path = require('path');
console.log('=== Checkpoint 8: Core AI and Gameplay Mechanics Validation ===\n');
let validationsPassed = 0;
let totalValidations = 0;
function validate(description, condition) {
totalValidations++;
if (condition) {
validationsPassed++;
console.log(`✓ ${description}`);
return true;
} else {
console.log(`✗ ${description}`);
return false;
}
}
function checkFileExists(filePath) {
return fs.existsSync(filePath);
}
function checkFileContains(filePath, searchTerms) {
if (!fs.existsSync(filePath)) return false;
const content = fs.readFileSync(filePath, 'utf8');
return searchTerms.every(term => content.includes(term));
}
function checkClassImplemented(filePath, className, requiredMethods = []) {
if (!fs.existsSync(filePath)) return false;
const content = fs.readFileSync(filePath, 'utf8');
// Check if class is defined
const classPattern = new RegExp(`class\\s+${className}\\s*{`, 'i');
if (!classPattern.test(content)) return false;
// Check if required methods exist
return requiredMethods.every(method => {
const methodPattern = new RegExp(`${method}\\s*\\(`, 'i');
return methodPattern.test(content);
});
}
// 1. File Structure Validation
console.log('1. File Structure Validation:');
validate('Main HTML file exists', checkFileExists('index.html'));
validate('Game engine file exists', checkFileExists('js/gameEngine.js'));
validate('Maze graph file exists', checkFileExists('js/mazeGraph.js'));
validate('PacMan entity file exists', checkFileExists('js/pacman.js'));
validate('Ghost entity file exists', checkFileExists('js/ghost.js'));
validate('Ghost AI system file exists', checkFileExists('js/ghostAI.js'));
validate('Input handler file exists', checkFileExists('js/inputHandler.js'));
validate('Renderer file exists', checkFileExists('js/renderer.js'));
validate('Main application file exists', checkFileExists('js/main.js'));
// 2. Core Classes Implementation
console.log('\n2. Core Classes Implementation:');
validate('GameEngine class implemented', checkClassImplemented('js/gameEngine.js', 'GameEngine', ['constructor', 'start', 'update', 'render']));
validate('MazeGraph class implemented', checkClassImplemented('js/mazeGraph.js', 'MazeGraph', ['constructor', 'findPathBFS', 'findPathAStar']));
validate('PacMan class implemented', checkClassImplemented('js/pacman.js', 'PacMan', ['constructor', 'update', 'setPosition']));
validate('Ghost class implemented', checkClassImplemented('js/ghost.js', 'Ghost', ['constructor', 'update', 'checkCollisionWithPacman']));
validate('GhostAI class implemented', checkClassImplemented('js/ghostAI.js', 'GhostAI', ['constructor', 'initializeGhosts', 'update', 'checkCollisions']));
validate('InputHandler class implemented', checkClassImplemented('js/inputHandler.js', 'InputHandler', ['constructor', 'getCurrentDirection']));
validate('Renderer class implemented', checkClassImplemented('js/renderer.js', 'Renderer', ['constructor', 'drawMaze', 'drawPacMan', 'drawGhost']));
// 3. Maze Graph System
console.log('\n3. Maze Graph System:');
validate('Maze graph has pathfinding algorithms', checkFileContains('js/mazeGraph.js', ['findPathBFS', 'findPathAStar']));
validate('Maze graph supports different tile types', checkFileContains('js/mazeGraph.js', ['TILE_TYPES', 'WALL', 'PELLET', 'POWER_PELLET']));
validate('Maze graph has demo maze creation', checkFileContains('js/mazeGraph.js', ['createDemoMaze']));
validate('Maze graph supports pellet consumption', checkFileContains('js/mazeGraph.js', ['consumePellet']));
// 4. PacMan Entity
console.log('\n4. PacMan Entity:');
validate('PacMan has movement system', checkFileContains('js/pacman.js', ['direction', 'updateMovement', 'isMoving']));
validate('PacMan has collision handling', checkFileContains('js/pacman.js', ['handleCollisions']));
validate('PacMan tracks movement history', checkFileContains('js/pacman.js', ['movementHistory', 'getMovementHistory']));
validate('PacMan supports predictive positioning', checkFileContains('js/pacman.js', ['getPredictedPosition']));
// 5. Ghost AI System
console.log('\n5. Ghost AI System:');
validate('Ghost AI has state machine', checkFileContains('js/ghost.js', ['currentState', 'stateConfig', 'transitionToState']));
validate('Ghost AI supports multiple personalities', checkFileContains('js/ghost.js', ['personality', 'aggressive', 'ambush', 'patrol', 'random']));
validate('Ghost AI has predictive targeting', checkFileContains('js/ghostAI.js', ['predictive', 'calculatePredictiveTarget']));
validate('Ghost AI supports coordination', checkFileContains('js/ghostAI.js', ['coordination', 'applyGhostCoordination']));
validate('Ghost AI has performance tracking', checkFileContains('js/ghostAI.js', ['getPerformanceMetrics', 'updatePerformanceMetrics']));
// 6. Collision Detection
console.log('\n6. Collision Detection:');
validate('Ghost-PacMan collision detection implemented', checkFileContains('js/ghost.js', ['checkCollisionWithPacman']));
validate('GhostAI collision system implemented', checkFileContains('js/ghostAI.js', ['checkCollisions']));
validate('Game engine handles collisions', checkFileContains('js/gameEngine.js', ['handleGhostCollisions']));
validate('Collision detection supports power mode', checkFileContains('js/gameEngine.js', ['powerPelletActive', 'handleGhostCollisions']));
// 7. Game Engine Integration
console.log('\n7. Game Engine Integration:');
validate('Game engine manages game state', checkFileContains('js/gameEngine.js', ['gameState', 'score', 'lives', 'level']));
validate('Game engine has entity management', checkFileContains('js/gameEngine.js', ['initializeEntities', 'getPacMan', 'getGhosts']));
validate('Game engine supports power pellets', checkFileContains('js/gameEngine.js', ['activatePowerPellet', 'powerPelletActive']));
validate('Game engine has performance monitoring', checkFileContains('js/gameEngine.js', ['performanceMetrics', 'updatePerformanceMetrics']));
// 8. Input Handling
console.log('\n8. Input Handling:');
validate('Input handler supports direction queuing', checkFileContains('js/inputHandler.js', ['directionQueue', 'queueDirection']));
validate('Input handler has arrow key mapping', checkFileContains('js/inputHandler.js', ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']));
validate('Input handler supports special keys', checkFileContains('js/inputHandler.js', ['Space', 'handlePauseToggle', 'handleRestart']));
// 9. Rendering System
console.log('\n9. Rendering System:');
validate('Renderer supports retro visual effects', checkFileContains('js/renderer.js', ['drawRetroMaze', 'drawNeonMaze', 'glow']));
validate('Renderer has entity drawing methods', checkFileContains('js/renderer.js', ['drawPacMan', 'drawGhost', 'drawPellet']));
validate('Renderer supports animation', checkFileContains('js/renderer.js', ['animationFrame', 'updateAnimation']));
validate('Renderer has debug capabilities', checkFileContains('js/renderer.js', ['drawDebugInfo', 'DEBUG_MODE']));
// 10. Test Files
console.log('\n10. Test Files:');
validate('Collision unit tests exist', checkFileExists('test_collision_unit.html'));
validate('Collision integration tests exist', checkFileExists('test_collision_integration.html'));
validate('Ghost AI tests exist', checkFileExists('test_ghost_ai.html'));
validate('Maze graph tests exist', checkFileExists('test_maze.html'));
validate('PacMan tests exist', checkFileExists('test_pacman.html'));
// 11. Advanced Features
console.log('\n11. Advanced Features:');
validate('Ghost AI has state transitions', checkFileContains('js/ghost.js', ['Chase', 'Scatter', 'Ambush', 'Retreat']));
validate('Pathfinding supports dynamic obstacles', checkFileContains('js/mazeGraph.js', ['dynamicObstacles']));
validate('Ghost AI supports multiple pathfinding algorithms', checkFileContains('js/mazeGraph.js', ['findPathBFS', 'findPathAStar', 'findOptimalPath']));
validate('Game engine supports level progression', checkFileContains('js/gameEngine.js', ['advanceLevel', 'resetGame']));
// 12. Integration Points
console.log('\n12. Integration Points:');
validate('Main application initializes all systems', checkFileContains('js/main.js', ['GameEngine', 'InputHandler', 'Renderer', 'MazeGraph']));
validate('HTML includes all required scripts', checkFileContains('index.html', ['gameEngine.js', 'ghostAI.js', 'pacman.js', 'ghost.js']));
validate('Game engine coordinates all systems', checkFileContains('js/gameEngine.js', ['initializeEntities', 'ghostAI', 'pacman', 'mazeGraph']));
// Summary
console.log('\n=== Validation Summary ===');
const passRate = ((validationsPassed / totalValidations) * 100).toFixed(1);
console.log(`Validations passed: ${validationsPassed}/${totalValidations} (${passRate}%)`);
if (passRate >= 90) {
console.log('\n✓ CHECKPOINT 8 PASSED');
console.log('Core AI and gameplay mechanics are properly implemented!');
console.log('All major systems are in place and integrated correctly.');
} else if (passRate >= 75) {
console.log('\n⚠ CHECKPOINT 8 PARTIAL');
console.log('Most core systems are implemented, but some components may need attention.');
console.log('Review the failed validations above for areas that need improvement.');
} else {
console.log('\n✗ CHECKPOINT 8 FAILED');
console.log('Significant implementation gaps detected.');
console.log('Core systems need to be completed before proceeding.');
}
console.log('\nNext steps:');
if (passRate >= 90) {
console.log('- All tests are passing - ready to proceed to next tasks');
console.log('- Consider implementing optional property-based tests');
console.log('- Ready to move on to Explainer AI system (Task 9)');
} else {
console.log('- Address the failed validations listed above');
console.log('- Run individual test files to debug specific issues');
console.log('- Ensure all core systems are properly integrated');
}
console.log('\nCheckpoint 8 validation complete.');