static void auditBaseCellNeighbors()

in src/apps/miscapps/generateBaseCellNeighbors.c [39:79]


static void auditBaseCellNeighbors(int baseCellNeighbors[NUM_BASE_CELLS][7],
                                   int baseCellRotations[NUM_BASE_CELLS][7]) {
    for (int i = 0; i < NUM_BASE_CELLS; i++) {
        for (int j = 0; j <= NUM_DIRS; j++) {
            if (baseCellNeighbors[i][j] == INVALID_BASE_CELL) continue;

            CoordIJK ourDir = {0, 0, 0};
            _neighbor(&ourDir, j);

            int k = 0;
            for (; k <= NUM_DIRS; k++) {
                if (baseCellNeighbors[baseCellNeighbors[i][j]][k] == i) {
                    break;
                }
            }
            if (k == NUM_DIRS + 1) {
                printf("MISMATCH between %d and %d\n", i,
                       baseCellNeighbors[i][j]);
            }
            CoordIJK theirDir = {0, 0, 0};
            _neighbor(&theirDir, k);

            for (int reverse = 0; reverse < 3; reverse++) {
                _ijkRotate60ccw(&ourDir);
            }
            for (int rotate = 0; rotate < baseCellRotations[i][j]; rotate++) {
                _ijkRotate60ccw(&ourDir);
            }

            // This is wrong for moving into pentagons. One neighbor for most
            // pentagons, and four neighbors for the polar pentagons 4 and 117.
            if (!_isBaseCellPentagon(baseCellNeighbors[i][j])) {
                if (ourDir.i != theirDir.i || ourDir.j != theirDir.j ||
                    ourDir.k != theirDir.k) {
                    printf("WRONG DIRECTION between %d and %d\n", i,
                           baseCellNeighbors[i][j]);
                }
            }
        }
    }
}