Heres the validation checking method:
Code: Select all
* r is the value of the current grid position to check
* x & y are the current grid co-ordinates
*
private bool validgridposition(int r, int x, int y)
{
* check all x-axis values up till current position*
for (int xi = 0; xi < x; xi++)
{
if (grid_y__xi_.getValue() == r) return false;
}
*check all y-axis values up till current position*
for (int yi = 0; yi < y; yi++)
{
if (grid_yi__x_.getValue() == r) return false;
}
*creates a sub grid to search
* eg: if a 9x9 grid,
* should produce a 3x3 subgrid
* containing x and y
* where segments = sqrt(length of 1 side of the grid)
* as all elements exist im not getting nulls*
int xoffset = (x / segments) * segments;
int yoffset = (y / segments) * segments;
for (int ys = yoffset; ys < yoffset + segments; ys++)
{
for (int xs = xoffset; xs < xoffset + segments; xs++)
{
if (!((xs == x) && (ys == y)))
{
if (grid_ys__xs_.getValue() == r)
return false;
}
}
}
* if all checks pass*
return true;
}
please someone tell me what the ---- im doing wrong because im stymied!
so any and all comments will be accepted!