public static BitGridType operator ^(BitGridType a, BitGridType b)
    {
        int w, h;

        if (a.Width() <= b.Width())
        {
            w = a.Width();
        }
        else
        {
            w = b.Width();
        }

        if (a.Height() <= b.Height())
        {
            h = a.Height();
        }
        else
        {
            h = b.Height();
        }

        BitGridType to_return = new BitGridType(w, h);

        for (int j = 0; j < h; j++)
        {
            for (int i = 0; i < w; i++)
            {
                to_return[i, j] = a[i, j] ^ b[i, j];
            }
        }

        return(to_return);
    }
 public GoL_logic(int width, int height, int[] stability_range, int[] growth_range, bool only_test_neighbors)
 {
     game_board        = new BitGridType(width, height);
     next_board        = new BitGridType(width, height);
     population_stable = stability_range;
     population_grow   = growth_range;
     should_cull       = only_test_neighbors;
 }
Exemple #3
0
    public BitGridType UnionSteps(int iter)
    {
        BitGridType region = new BitGridType(game.GetBoard().Width(), game.GetBoard().Height());

        for (int i = 0; i < iter; i++)
        {
            game.NextBoardState();
            region |= game.GetBoard();
        }

        return(region);
    }
    //Mutate game_board to store the next state for all game board cells.
    public void NextBoardState()
    {
        int w = game_board.Width();
        int h = game_board.Height();

        for (int j = 0; j < h; j++)
        {
            for (int i = 0; i < w; i++)
            {
                next_board[i, j] = NextCellState(i, j);
            }
        }

        game_board = next_board;
        next_board = new BitGridType(next_board.Width(), next_board.Height());
    }