Похожие чаты

Help please, why is the while loop still breaking when

legal_move is false?

7 ответов

4 просмотра

Are you sure it is false? Did you debug it (either with debugger or by printing something in your branches to the console)?

Chesire- Автор вопроса
Chesire
why will it be true?

You have a branch that sets it to true

Why don't just use while (true) and break? You only have single location to break it, no need to use bool variable like that.

I am sure you have just mistakenly walked through your program. In here, there are 2 conditions need to be fulfilled to break the loop: - check_legal_movement() returns true - check_eat() returns false Are you sure about that? Reconsider and simplify it if you can. I think you don't even need nested if for this. Also the legal_move = false; in else block is really useless.

Chesire- Автор вопроса

Похожие вопросы

Карта сайта