Changeset 306
 Timestamp:
 Jan 29, 2011, 2:23:56 AM (10 years ago)
 Location:
 trunk/monsterz
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/monsterz/board.cpp
r304 r306 347 347 } 348 348 349 /* Fill an array with the list of pieces that should disappear due to 350 * 3piece or more alignments. */ 349 351 int Board::ListMashes(int list[8][8]) 350 352 { … … 376 378 list[i][j + 2]++; 377 379 ret = 1; 380 } 381 } 382 383 return ret; 384 } 385 386 /* Fill an array with the list of pieces that can be moved. A value of 1 387 * indicates the piece can be moved right. A value of 2 means it can be 388 * moved up, and a value of 3 means both moves are possible. The number 389 * of possible moves is returned. */ 390 int Board::ListMoves(int moves[8][8]) 391 { 392 int ret = 0; 393 394 for (int j = 0; j < 8; j++) 395 for (int i = 0; i < 8; i++) 396 moves[i][j] = 0; 397 398 for (int j = 0; j < 8; j++) 399 for (int i = 0; i < 8; i++) 400 { 401 if (i + 1 < 8) 402 { 403 /* Try moving right */ 404 int i1 = data>pairs[i][j].id; 405 int i2 = data>pairs[i + 1][j].id; 406 407 if ((i + 3 < 8 && data>pairs[i + 2][j].id == i1 408 && data>pairs[i + 3][j].id == i1)  409 (j + 2 < 8 && data>pairs[i + 1][j + 2].id == i1 410 && data>pairs[i + 1][j + 1].id == i1)  411 (j + 1 < 8 && j  1 > 0 412 && data>pairs[i + 1][j + 1].id == i1 413 && data>pairs[i + 1][j  1].id == i1)  414 (j  2 > 0 && data>pairs[i + 1][j  1].id == i1 415 && data>pairs[i + 1][j  2].id == i1)  416 417 (i  2 > 0 && data>pairs[i  2][j].id == i2 418 && data>pairs[i  1][j].id == i2)  419 (j + 2 < 8 &&data>pairs[i][j + 2].id == i2 420 && data>pairs[i][j + 1].id == i2)  421 (j + 1 < 8 && j  1 > 0 422 && data>pairs[i][j + 1].id == i2 423 && data>pairs[i][j  1].id == i2)  424 (j  2 > 0 && data>pairs[i][j  1].id == i2 425 && data>pairs[i][j  2].id == i2)) 426 { 427 moves[i][j] = 1; 428 ret++; 429 } 430 } 431 432 if (j + 1 < 8) 433 { 434 /* Try moving up */ 435 int i1 = data>pairs[i][j].id; 436 int i2 = data>pairs[i][j + 1].id; 437 438 if ((j + 3 < 8 && data>pairs[i][j + 2].id == i1 439 && data>pairs[i][j + 3].id == i1)  440 (i + 2 < 8 && data>pairs[i + 2][j + 1].id == i1 441 && data>pairs[i + 1][j + 1].id == i1)  442 (i + 1 < 8 && i  1 > 0 443 && data>pairs[i + 1][j + 1].id == i1 444 && data>pairs[i  1][j + 1].id == i1)  445 (i  2 > 0 && data>pairs[i  1][j + 1].id == i1 446 && data>pairs[i  2][j + 1].id == i1)  447 448 (j  2 > 0 && data>pairs[i][j  2].id == i2 449 && data>pairs[i][j  1].id == i2)  450 (i + 2 < 8 &&data>pairs[i + 2][j].id == i2 451 && data>pairs[i + 1][j].id == i2)  452 (i + 1 < 8 && i  1 > 0 453 && data>pairs[i + 1][j].id == i2 454 && data>pairs[i  1][j].id == i2)  455 (i  2 > 0 && data>pairs[i  1][j].id == i2 456 && data>pairs[i  2][j].id == i2)) 457 { 458 moves[i][j] = 2; 459 ret++; 460 } 378 461 } 379 462 } 
trunk/monsterz/board.h
r294 r306 29 29 void Switch(int2 cell_a, int2 cell_b); 30 30 int ListMashes(int list[8][8]); 31 int ListMoves(int list[8][8]); 31 32 32 33 private:
Note: See TracChangeset
for help on using the changeset viewer.