Rewrite is_move_valid()
This commit is contained in:
parent
0ff026b4ca
commit
7e7502dcec
1 changed files with 10 additions and 21 deletions
31
src/model.c
31
src/model.c
|
@ -133,31 +133,20 @@ e_location get_next_outer_position(s_utictactoe *p_uttt) {
|
||||||
return FREE;
|
return FREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move){
|
e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) {
|
||||||
|
if ( p_uttt->outer_tictactoe->winner != NOBODY ) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
if ( get_next_player_to_play(p_uttt) != p_move->player ) {
|
if ( get_next_player_to_play(p_uttt) != p_move->player ) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if ( p_uttt->inception_level == 1 ) {
|
|
||||||
if ( p_uttt->outer_tictactoe->winner == NOBODY
|
if ( get_next_outer_position(p_uttt) != FREE
|
||||||
&& p_uttt->outer_tictactoe->content[p_move->outer_position] == NOBODY) {
|
&& get_next_outer_position(p_uttt) != p_move->outer_position) {
|
||||||
return YES;
|
return NO;
|
||||||
}
|
|
||||||
else {
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (p_uttt->outer_tictactoe->winner == NOBODY
|
|
||||||
&& p_uttt->inner_tictactoes[p_move->outer_position]->content[p_move->inner_position] == NOBODY
|
|
||||||
&& p_uttt->inner_tictactoes[p_move->outer_position]->winner == NOBODY )
|
|
||||||
{
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue