int isCornerMove(move) returns whether move is placed in a corner or not
This commit is contained in:
		
							parent
							
								
									76981af571
								
							
						
					
					
						commit
						661e57519e
					
				
					 3 changed files with 15 additions and 2 deletions
				
			
		|  | @ -21,7 +21,6 @@ send_move(int row, int col) | |||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int main(void) | ||||
| { | ||||
| 	int done = 0; | ||||
|  | @ -62,7 +61,7 @@ int main(void) | |||
| 		movesList *moves = new movesList(); | ||||
| 
 | ||||
| 		findMoves(field, moves); | ||||
| 		if(!moves->movesNumber) | ||||
| 		if(!(moves->movesNumber)) | ||||
| 		{ | ||||
| 			turn_row=0; | ||||
| 			turn_col=0; | ||||
|  | @ -75,6 +74,8 @@ int main(void) | |||
| 
 | ||||
| #ifdef debugprint | ||||
| 		printf("numX: %d, numO: %d\n", numX, numO); | ||||
| 		printf("%d  %d\n", sizeof(field), sizeof(cell[fieldSize][fieldSize])); | ||||
| 		printf("IsCorner? %d\n", isCornerField(moves->list[0])); | ||||
| #endif | ||||
| 
 | ||||
| 		// 3. Return result
 | ||||
|  |  | |||
|  | @ -314,3 +314,12 @@ findMoves(cell (*field)[fieldSize], movesList *moves) { | |||
| 		findDiagonalBottomLeftMoves(field, moves) + | ||||
| 		findDiagonalTopRightMoves(field, moves); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| isCornerField(move m) { | ||||
| 	if( (m.turnRow == 1 || m.turnRow == fieldSize) && (m.turnCol == 1 || m.turnCol == fieldSize) ) | ||||
| 		return 1; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,4 +26,7 @@ extern int readStateBuffer(char*, cell (*)[fieldSize], unsigned int *, unsigned | |||
| 
 | ||||
| //iterates through field in all directions, stores moves into movesList
 | ||||
| int findMoves(cell (*)[fieldSize], movesList *); | ||||
| 
 | ||||
| //returns 1 if move on corner field
 | ||||
| int isCornerField(move); | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue