in reply to Re^2: Creating a unique variable type (an object) in thread Creating a unique variable type
I could do the idea of having the boolean in one element and having the int in the following. Frankly though, I find it easier to manage and think about if I could have them both the boolean and the int in the same element. Reasoning for this, is I will have to have the system calculate different locations in a later portion of the code, and to just find a single element via very simple arithmetic is trivial, compared to doing a similar calculation, but then having to worry considering the next element, which will in essence throw off my calculation.
What I mean by this is I have several subroutines that currently depend on a simple calculation, in this case, lets take an example of placing a queen on D6, well with my twodimensional array, I will completely block out the vertical and the horizontal columns, but what about the diagonals? well by doing a simple addition or subtraction of 1 to the factor being used in this case (in this case its actually two factors, the D which is equal to 4, and another that 6) With this, I could do a simple subtraction on one and addition on the other or two additions or two subtractions until I run out of possible squares. In our example, to resolve the upper left portion of the diagonal, we would do a double subtraction of 1 until one of the two arrays runs out of elements, and so on. This is why I want to have both of these values in the same element, since if they happen to be in the following element, I can no longer use the method described above to calculate all the squares being threatened by that queen that has been placed, in this case at D6, since as I go in one direction, I may be accessing either the boolean or the int, and I can't be sure without modifying the math used. It is just easier in this case to have them both in the same element if possible. The only other solution which could be used, is to create two twodimensional arrays, and while that would work, I feel it would be a waste of resources that could be easily avoided.
A rough diagram of the board setup with the Q being the queen and the x's being the squares under attack, has been created below.
1 2 3 4 5 6 7 8
A   x  x  
B    x x x
C     xxx 
D xxxxxQxx
E     xxx 
F    x x x
G   x  x  
H  x   x  
