I am trying to make some code so that a single element a matrix can reference elements adjacent to it. Sort of like how you can only move game pieces to spaces adjacent. For example, I want to be able to say something like:
if x matrix element is adjacent to y element:
y_element_adjacent = True
I want to know how to accomplish the 'is adjacent' portion of this.
EDIT: I have tried making a list and assigning each element a number. So in a 100 element list (or a 10x10 game board), space 1x1 would be the 0th element and space 1x3 would be the 2nd element... Like this:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
11, 12, 13, 14, 15, 16, 17, 18, 19, 20
However, the problem with this is that if the x element was 10, my code would take + 1 to find an adjacent space, and 11 is NOT adjacent. I then realized that lists are not the correct way to do this and matrices would be a the way to go. I'm just a little confused on how I can use them differently than lists.
Any help is appreciated! Thanks.