@@ -262,9 +262,10 @@ async function runTests() {
262262 }
263263
264264 // Verify some piece positions (e.g., white pawn at e2)
265- // Board is row-major: row 0 = rank 1, row 7 = rank 8
266- // e2 is row 1, col 4 (0-indexed)
267- const e2Index = 1 * 8 + 4 ; // row 1, col 4
265+ // Board uses 1-indexed coordinates: e2 = row 2, col 5
266+ // Board array is flattened row-major, but we need to account for 1-indexing
267+ // Array position for e2: (row-1) * 8 + (col-1) = (2-1)*8 + (5-1) = 1*8 + 4 = 12
268+ const e2Index = ( 2 - 1 ) * 8 + ( 5 - 1 ) ; // e2: row 2, col 5 in 1-indexed
268269 const e2Piece = board [ e2Index ] ;
269270 if ( e2Piece && e2Piece . type === 'Pawn' && e2Piece . color === 'White' ) {
270271 recordPass ( 'Initial Piece Positions' , 'White pawn at e2' ) ;
@@ -287,8 +288,9 @@ async function runTests() {
287288 log ( '\n=== C. Basic Legal Moves ===' , 'TEST' ) ;
288289
289290 // Move e2 to e4 (white pawn)
290- const e2 = { row : 1 , col : 4 } ;
291- const e4 = { row : 3 , col : 4 } ;
291+ // Using 1-indexed coordinates: e2 = row 2, col 5
292+ const e2 = { row : 2 , col : 5 } ;
293+ const e4 = { row : 4 , col : 5 } ;
292294 const move1Result = await apiCall ( '/move' , 'POST' , {
293295 source : e2 ,
294296 target : e4 ,
@@ -310,8 +312,9 @@ async function runTests() {
310312 }
311313
312314 // Move e7 to e5 (black pawn)
313- const e7 = { row : 6 , col : 4 } ;
314- const e5 = { row : 4 , col : 4 } ;
315+ // Using 1-indexed coordinates: e7 = row 7, col 5
316+ const e7 = { row : 7 , col : 5 } ;
317+ const e5 = { row : 5 , col : 5 } ;
315318 const move2Result = await apiCall ( '/move' , 'POST' , {
316319 source : e7 ,
317320 target : e5 ,
@@ -330,9 +333,9 @@ async function runTests() {
330333 log ( '\n=== D. Illegal Move Rejection ===' , 'TEST' ) ;
331334
332335 // Try to move a knight like a bishop (illegal)
333- // White knight is at b1 (row 0 , col 1)
334- const b1 = { row : 0 , col : 1 } ;
335- const d3 = { row : 2 , col : 3 } ;
336+ // White knight is at b1 (row 1 , col 2) in 1-indexed coordinates
337+ const b1 = { row : 1 , col : 2 } ;
338+ const d3 = { row : 3 , col : 4 } ;
336339 const illegalMoveResult = await apiCall ( '/move' , 'POST' , {
337340 source : b1 ,
338341 target : d3 ,
@@ -369,7 +372,8 @@ async function runTests() {
369372 recordWarning ( 'Pawn promotion full test requires complete game - testing API parameter only' ) ;
370373
371374 // Test valid moves API
372- const validMovesE2 = await apiCall ( '/getValidMoves' , 'POST' , { row : 1 , col : 4 } ) ;
375+ // Using 1-indexed coordinates: e2 = row 2, col 5
376+ const validMovesE2 = await apiCall ( '/getValidMoves' , 'POST' , { row : 2 , col : 5 } ) ;
373377 if ( validMovesE2 . ok && Array . isArray ( validMovesE2 . data ) && validMovesE2 . data . length > 0 ) {
374378 recordPass ( 'Get Valid Moves API' , `e2 pawn has ${ validMovesE2 . data . length } valid moves` ) ;
375379 } else {
@@ -392,11 +396,12 @@ async function runTests() {
392396 await apiCall ( '/startGame' ) ;
393397
394398 // Fool's Mate: 1. f3 e5 2. g4 Qh4#
399+ // Using 1-indexed coordinates
395400 const moves = [
396- { source : { row : 1 , col : 5 } , target : { row : 2 , col : 5 } } , // f2-f3
397- { source : { row : 6 , col : 4 } , target : { row : 4 , col : 4 } } , // e7-e5
398- { source : { row : 1 , col : 6 } , target : { row : 3 , col : 6 } } , // g2-g4
399- { source : { row : 7 , col : 3 } , target : { row : 3 , col : 7 } } // Qd8-Qh4 (checkmate )
401+ { source : { row : 2 , col : 6 } , target : { row : 3 , col : 6 } } , // f2-f3 (row 2, col 6 to row 3, col 6)
402+ { source : { row : 7 , col : 5 } , target : { row : 5 , col : 5 } } , // e7-e5 (row 7, col 5 to row 5, col 5)
403+ { source : { row : 2 , col : 7 } , target : { row : 4 , col : 7 } } , // g2-g4 (row 2, col 7 to row 4, col 7)
404+ { source : { row : 8 , col : 4 } , target : { row : 4 , col : 8 } } // Qd8-Qh4 (row 8, col 4 to row 4, col 8 )
400405 ] ;
401406
402407 for ( const move of moves ) {
@@ -414,8 +419,8 @@ async function runTests() {
414419
415420 // Verify no further moves allowed (attempt to move after checkmate)
416421 const moveAfterCheckmate = await apiCall ( '/move' , 'POST' , {
417- source : { row : 0 , col : 4 } ,
418- target : { row : 1 , col : 4 } ,
422+ source : { row : 1 , col : 5 } , // e1 king (1-indexed)
423+ target : { row : 2 , col : 5 } , // e2
419424 promotionType : 'Queen'
420425 } ) ;
421426
0 commit comments