Skip to content

Instantly share code, notes, and snippets.

@engleek
Created March 22, 2010 09:04
Show Gist options
  • Save engleek/339898 to your computer and use it in GitHub Desktop.
Save engleek/339898 to your computer and use it in GitHub Desktop.
int evaluate_position(int color){
int result = 0;
if ((get_horizontal_lines(4, color * (-1)) || (get_vertical_lines(4, color * (-1)) || get_diagonal_lines(4, color * (-1))))) {
return (-1) * VALUE_QUAD;
}
if ((get_horizontal_lines(4, color) || (get_vertical_lines(4, color) || get_diagonal_lines(4, color)))) {
return VALUE_QUAD;
}
result += (VALUE_TRIPPLE) * (get_horizontal_lines(3, color) + get_vertical_lines(3, color) + get_diagonal_lines(3, color));
result += VALUE_PAIR * (get_horizontal_lines(2, color) + get_vertical_lines(2, color) + get_diagonal_lines(2, color));
result -= VALUE_TRIPPLE * (get_horizontal_lines(3, color * (-1)) + get_vertical_lines(3, color * (-1)) + get_diagonal_lines(3,color * (-1)));
result -= VALUE_PAIR * (get_horizontal_lines(2,color * (-1)) + get_vertical_lines(2,color * (-1)) + get_diagonal_lines(2,color * (-1)));
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment