An AI for a game like connect 4 that uses a game matrix, would it be wise to check bounds using a nested if structure, or are there more efficient alternatives?
e.g:
or is it ok to index an array element that does not exist? (renderring the bounds check redundant) I think this will cause the program to crash:Code:if(x>1&&y>1) { //bounds check if(matrix[y-2][x-2]==1) { //first index. //... } }
Code:matrix[y-2][x-2]; //when x=1 and y=1