Untitled

 avatar
unknown
python
4 years ago
1.2 kB
1
Indexable
static bool Knight(int old_x, int old_y, int new_x, int new_y)
    {
        if (old_y - 2 >= 0 && old_x - 1 >= 0 && new_y == old_y - 2 && new_x == old_x - 1)
        {
            return true;
        }
        else if (old_y - 2 >= 0 && old_x + 1 <= 8 && new_y == old_y - 2 && new_x == old_x + 1)
        {
            return true;
        }
        else if (old_y - 1 >= 0 && old_x + 2 <= 8 && new_y == old_y - 1 && new_x == old_x + 2)
        {
            return true;
        }
        else if (old_y + 1 <= 8 && old_x + 2 <= 8 && new_y == old_y + 1 && new_x == old_x + 2)
        {
            return true;
        }
        else if (old_y + 2 <= 8 && old_x + 1 <= 8 && new_y == old_y + 2 && new_x == old_x + 1)
        {
            return true;
        }
        else if (old_y + 1 <= 8 && old_x - 1 >= 0 && new_y == old_y + 2 && new_x == old_x - 1)
        {
            return true;
        }
        else if (old_y + 1 <= 8 && old_x - 2 >= 0 && new_y == old_y + 1 && new_x == old_x - 2)
        {
            return true;
        }
        else if (old_y - 1 >= 0 && old_x - 2 >= 0 && new_y == old_y - 1 && new_x == old_x - 2)
        {
            return true;
        }
        else return false;
    }
Editor is loading...