I have that code:
List<Move> list = new List<Move>();
list.Add(GetBeatingForFieldOnSpecificDiagonal(i, enemyColor, Constant.TOP_LEFT));
list.Add(GetBeatingForFieldOnSpecificDiagonal(i, enemyColor, Constant.TOP_RIGHT));
list.Add(GetBeatingForFieldOnSpecificDiagonal(i, enemyColor, Constant.DOWN_LEFT));
list.Add(GetBeatingForFieldOnSpecificDiagonal(i, enemyColor, Constant.DOWN_RIGHT));
The question is:
Is this possible to somehow check if this element is not null before add it to the list?
I mean I don't want to call that method twice. One call for check it is not null and another for eventually add it, this is a bad way, because I am writing an AI algorithm for computer and any resources are important.
Aucun commentaire:
Enregistrer un commentaire