Code:
enum Direction bends[NUMBENDS][2][2][2] = { /* [type][before/after][y][x]*/
{{{ NONE, DOWN},{ NONE, END}},{{ DOWN, LEFT},{RIGHT, END}}},
{{{ NONE, NONE},{ END, LEFT}},{{ DOWN, LEFT},{ END, UP}}},
{{{ END, NONE},{ UP, NONE}},{{ END, LEFT},{RIGHT, UP}}},
{{{RIGHT, END},{ NONE, NONE}},{{ DOWN, END},{RIGHT, UP}}},
{{{ NONE, END},{ NONE, UP}},{{RIGHT, END},{ UP, LEFT}}},
{{{ NONE, NONE},{RIGHT, END}},{{RIGHT, DOWN},{ UP, END}}},
{{{ DOWN, NONE},{ END, NONE}},{{RIGHT, DOWN},{ END, LEFT}}},
{{{ END, LEFT},{ NONE, NONE}},{{ END, DOWN},{ UP, LEFT}}}
};
...skipping to the problem bit ...
index = 0;
for (xy = 0; xy < (MAX * MAX) - MAX; xy++)
{
if ((xy + 1) % MAX == 0) continue;
for (c = 0; c < NUMBENDS; c++)
{
if ((bends[c][0][0][0] != END) && (bends[c][0][0][0] != board[xy])) continue;
if ((bends[c][0][0][1] != END) && (bends[c][0][0][1] != board[xy + 1])) continue;
if ((bends[c][0][1][0] != END) && (bends[c][0][1][0] != board[xy + MAX])) continue;
if ((bends[c][0][1][1] != END) && (bends[c][0][1][1] != board[xy + MAX + 1])) continue;
mods[index][0] = xy; mods[index][1] = c; index++;
for (d = 0; d < index; d++) mvprintw(debug++,40,"InBends%d:%d,%d",d,mods[d][0],mods[d][1]);refresh(); /*debug output*/
}
}
I added a debugging loop there to output the array as it find it, and I'm getting some odd output. I'd expect it to show me a building array, but instead I get something like: