/** * Advances the state of the board (cellular automaton) by a single step. */ void step(board_t* board, const board_t* old_board) { assert(NULL != board); assert(NULL != old_board); assert(is_valid_board(board)); // create a copy of the old state // the board pointed to by _board_ will //board_t old_board = *board; // iterate over the living cells // TODO decide whether a linked list is worth the added complexity for (pos_t pos = {0, 0}; pos.y < ROWS; pos.y++) { for (pos.x = 0; pos.x < COLUMNS; pos.x++) { const cell_t old_state = get_cell(old_board, pos); // determine the number of living cells bordering this one const int black_neighbors = n_neighbors(old_board, pos, BLACK); const int white_neighbors = n_neighbors(old_board, pos, WHITE); const cell_t new_state = successor_cell_state(old_state, white_neighbors, black_neighbors); //if (new_state != old_state) set_cell_state(board, pos, new_state); /* if (new_state != EMPTY) */ /* printf("(%d,%d) b: %d, w: %d\n", */ /* pos.x, pos.y, black_neighbors, white_neighbors); */ } } }
unsigned int Tri3Subdivision::get_ordered_valence(unsigned int node_id) const { libmesh_assert_less(node_id, n_neighbors()); libmesh_assert(_subdivision_updated); return get_ordered_node(node_id)->valence(); }