backend extended
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { BoardGenerationService } from '../src/Application/Game/BoardGenerationService';
|
||||
|
||||
// Test the fixed board generation
|
||||
async function testFixedBoardGeneration() {
|
||||
console.log('Testing fixed board generation (max 1 minute, no -1 values)...');
|
||||
|
||||
const service = new BoardGenerationService();
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
const result = await service.generateBoard(16, 4, 2); // Similar to your test case
|
||||
const endTime = Date.now();
|
||||
|
||||
console.log(`\n=== GENERATION RESULTS ===`);
|
||||
console.log(`Generation time: ${((endTime - startTime) / 1000).toFixed(2)} seconds`);
|
||||
console.log(`Error rate: ${result.totalErrorRate}%`);
|
||||
|
||||
// Count field types
|
||||
const positiveFields = result.fields.filter(f => f.type === 'positive');
|
||||
const negativeFields = result.fields.filter(f => f.type === 'negative');
|
||||
const luckFields = result.fields.filter(f => f.type === 'luck');
|
||||
|
||||
console.log(`\n=== FIELD COUNTS ===`);
|
||||
console.log(`Positive fields: ${positiveFields.length}`);
|
||||
console.log(`Negative fields: ${negativeFields.length}`);
|
||||
console.log(`Luck fields: ${luckFields.length}`);
|
||||
|
||||
// Check for -1 values in validation results
|
||||
let totalValidations = 0;
|
||||
let invalidValidations = 0;
|
||||
|
||||
Object.values(result.validationResults).forEach(outcomes => {
|
||||
outcomes.forEach(outcome => {
|
||||
totalValidations++;
|
||||
if (outcome === -1) {
|
||||
invalidValidations++;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`\n=== VALIDATION CHECK ===`);
|
||||
console.log(`Total validations: ${totalValidations}`);
|
||||
console.log(`Invalid validations (-1): ${invalidValidations}`);
|
||||
console.log(`SUCCESS: ${invalidValidations === 0 ? 'NO -1 VALUES FOUND! ✅' : 'STILL HAS -1 VALUES ❌'}`);
|
||||
|
||||
// Show step value variety
|
||||
const stepValues = positiveFields.map(f => f.stepValue).filter(v => v !== undefined);
|
||||
const uniqueStepValues = [...new Set(stepValues)];
|
||||
console.log(`\n=== STEP VALUE VARIETY ===`);
|
||||
console.log(`Unique positive step values: [${uniqueStepValues.sort((a, b) => a - b).join(', ')}]`);
|
||||
|
||||
// Show sample validation results
|
||||
console.log(`\n=== SAMPLE VALIDATION RESULTS ===`);
|
||||
Object.entries(result.validationResults).slice(0, 5).forEach(([position, outcomes]) => {
|
||||
const field = result.fields.find(f => f.position === parseInt(position));
|
||||
console.log(`Position ${position} (${field?.type}, step: ${field?.stepValue || 'N/A'}): [${outcomes.join(', ')}]`);
|
||||
});
|
||||
|
||||
console.log(`\n✅ Board generation test completed successfully!`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error during board generation:', error);
|
||||
}
|
||||
}
|
||||
|
||||
testFixedBoardGeneration();
|
||||
Reference in New Issue
Block a user