|
@@ -288,7 +288,7 @@ void Cell::updateUnMovealeCells_(std::queue<Cell*> & Q) {
|
|
}
|
|
}
|
|
|
|
|
|
void Cell::print() {
|
|
void Cell::print() {
|
|
- std::cout << col_ << " " << row_ << std::endl;
|
|
|
|
|
|
+ std::cout << "(" << col_ << ", " << row_ << ")";
|
|
}
|
|
}
|
|
|
|
|
|
Cell* Cell::getRealShootTarget(Cell* next){
|
|
Cell* Cell::getRealShootTarget(Cell* next){
|
|
@@ -297,35 +297,46 @@ Cell* Cell::getRealShootTarget(Cell* next){
|
|
}
|
|
}
|
|
int next_col = next->col_;
|
|
int next_col = next->col_;
|
|
int next_row = next->row_;
|
|
int next_row = next->row_;
|
|
- if(next_col - col_ == next_row - row_){
|
|
|
|
|
|
+ if(next_col - col_ == next_row - row_){//GoMainDiagonal
|
|
if(next_col > col_){
|
|
if(next_col > col_){
|
|
return getrightDown()->getright();
|
|
return getrightDown()->getright();
|
|
}
|
|
}
|
|
if(next_col < col_){
|
|
if(next_col < col_){
|
|
return getleftUp()->getleft();
|
|
return getleftUp()->getleft();
|
|
}
|
|
}
|
|
- throw new std::string("Don`t recalculated");
|
|
|
|
|
|
+ throw std::string("Don`t recalculated");
|
|
}
|
|
}
|
|
- if(-2 * (next_col - col_) == (next_row - row_)){
|
|
|
|
|
|
+ if(-2 * (next_col - col_) == (next_row - row_)){//GoSecondaryDiagonal
|
|
if(next_col < col_){
|
|
if(next_col < col_){
|
|
return getrightUp()->getright();
|
|
return getrightUp()->getright();
|
|
}
|
|
}
|
|
if(next_col > col_){
|
|
if(next_col > col_){
|
|
return getleftDown()->getleft();
|
|
return getleftDown()->getleft();
|
|
}
|
|
}
|
|
- throw new std::string("Don`t recalculated");
|
|
|
|
|
|
+ throw std::string("Don`t recalculated");
|
|
}
|
|
}
|
|
- if(next_col - col_ == -2 * (next_row - row_)){
|
|
|
|
|
|
+ if(next_col - col_ == -2 * (next_row - row_)){//GoUp
|
|
if(next_col < col_){
|
|
if(next_col < col_){
|
|
return (getleftUp() != nullptr ? getleftUp()->getrightUp() : getrightUp()->getleftUp());
|
|
return (getleftUp() != nullptr ? getleftUp()->getrightUp() : getrightUp()->getleftUp());
|
|
}
|
|
}
|
|
if(next_col > col_){
|
|
if(next_col > col_){
|
|
return (getleftDown() != nullptr ? getleftDown()->getrightDown() : getrightDown()->getleftDown());
|
|
return (getleftDown() != nullptr ? getleftDown()->getrightDown() : getrightDown()->getleftDown());
|
|
}
|
|
}
|
|
- throw new std::string("Don`t recalculated");
|
|
|
|
|
|
+ throw std::string("Don`t recalculated");
|
|
|
|
+ }
|
|
|
|
+ int row_secondary_diag = row_ - 2 * (next_col - col_);
|
|
|
|
+ int row_main_diag = row_ + next_col - col_;
|
|
|
|
+ int twice_row_up_line = 2 * row_ + col_ - next_col;
|
|
|
|
+ if(next_col > col_){
|
|
|
|
+ if(next_row < row_main_diag)return getleft();
|
|
|
|
+ if(2 * next_row < twice_row_up_line)return getleftUp();
|
|
|
|
+ if(next_row < row_secondary_diag)return getrightUp();
|
|
|
|
+ return getright();
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ if(next_row < row_secondary_diag)return getleft();
|
|
|
|
+ if(2 * next_row < twice_row_up_line)return getleftDown();
|
|
|
|
+ if(next_row < row_main_diag)return getrightDown();
|
|
|
|
+ return getright();
|
|
}
|
|
}
|
|
- return this;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|