Ejemplo n.º 1
0
        public Boggle(ScoringMode score_mode = ScoringMode.SCRABBLE, BoardSize board_size = BoardSize.BIGBOGGLE, BoundaryMode bound_mode = BoundaryMode.STANDARD, int time_limit = 180000, int min_length = 3)
        {
            status = GameStatus.PRE_GAME;

            score = 0;
            mode = score_mode;
            size = board_size;
            minLength = min_length;
            gameLength = time_limit;
            bound = bound_mode;

            dice = new string[(int)size, 6]; //Create the array to hold dice values
            position = new int[(int)size]; //Array of positions on board
            board = new string[(int)size]; //Array containing the layout of the board

            gameTimer.Enabled = false;
            gameTimer.Interval = (double)gameLength;
            gameTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

            current_word_list = "../../enable2k.txt";

            if (size == BoardSize.STANDARD)
            {
                current_dice_set = "../../BoggleDice.txt";
            }
            else
            {
                current_dice_set = "../../BigBoggleDice.txt";
            }

            LoadDice();
            LoadWordList();
            ShuffleBoard();
        }
Ejemplo n.º 2
0
 public ContainsResult(Field tip, bool contain, Vector2 layerPoint,
                       BoundaryMode boundary = BoundaryMode.Unknown)
 {
     this.tip        = tip;
     this.boundary   = boundary;
     this.contain    = contain;
     this.layerPoint = layerPoint;
 }
Ejemplo n.º 3
0
        public bool IsCrossOver(float threshold, BoundaryMode boundaryMode = BoundaryMode.High)
        {
            switch (boundaryMode)
            {
            case BoundaryMode.Low:
                return((Previous < threshold && threshold <= Current) || (Current < threshold && threshold <= Previous));

            case BoundaryMode.High:
                return((Previous <= threshold && threshold < Current) || (Current <= threshold && threshold < Previous));
            }

            throw new Exception("BoundaryMode must be High or Low.");
        }
Ejemplo n.º 4
0
    void SetBoundaries(float [,] grid, BoundaryMode mode)
    {
        for (int x = 1; x < FluidDataBank.GRID_WIDTH - 1; ++x)
        {
            grid[x, 0] = grid[x, 1] * ((mode == BoundaryMode.MirrorVertical) ? -1 : 1);
            grid[x, FluidDataBank.GRID_HEIGHT - 1] = grid[x, FluidDataBank.GRID_HEIGHT - 2] * ((mode == BoundaryMode.MirrorVertical) ? -1 : 1);
        }

        for (int y = 1; y < FluidDataBank.GRID_HEIGHT - 1; ++y)
        {
            grid[0, y] = grid[1, y] * ((mode == BoundaryMode.MirrorHorizontal) ? -1 : 1);
            grid[FluidDataBank.GRID_WIDTH - 1, y] = grid[FluidDataBank.GRID_WIDTH - 2, y] * ((mode == BoundaryMode.MirrorHorizontal) ? -1 : 1);
        }

        grid[0, 0] = 0.5f * (grid[0, 1] + grid[1, 0]);
        grid[FluidDataBank.GRID_WIDTH - 1, 0]  = 0.5f * (grid[FluidDataBank.GRID_WIDTH - 2, 0] + grid[FluidDataBank.GRID_WIDTH - 1, 1]);
        grid[0, FluidDataBank.GRID_HEIGHT - 1] = 0.5f * (grid[0, FluidDataBank.GRID_HEIGHT - 2] + grid[1, FluidDataBank.GRID_HEIGHT - 1]);
        grid[FluidDataBank.GRID_WIDTH - 1, FluidDataBank.GRID_HEIGHT - 1] = 0.5f * (grid[FluidDataBank.GRID_WIDTH - 2, FluidDataBank.GRID_HEIGHT - 1] + grid[FluidDataBank.GRID_WIDTH - 1, FluidDataBank.GRID_HEIGHT - 2]);
    }
Ejemplo n.º 5
0
        public TimelineSearchResult <T> Search(float rate, BoundaryMode boundaryMode = BoundaryMode.High)
        {
            if (dataArray.Count == 0)
            {
                throw new Exception("timeline is not initialized");
            }

            var   searchResult = weightArray.FloatBinarySearch(rate * TotalWeight, boundaryMode);
            float baseWeight;

            if (searchResult == 0)
            {
                baseWeight = 0;
            }
            else
            {
                baseWeight = weightArray[searchResult - 1] / TotalWeight;
            }

            float nextWeight;

            if (searchResult == dataArray.Count - 1)
            {
                nextWeight = 1;
            }
            else
            {
                nextWeight = weightArray[searchResult] / TotalWeight;
            }

            return(new TimelineSearchResult <T>(
                       dataArray[searchResult],
                       searchResult,
                       baseWeight,
                       nextWeight
                       ));
        }
Ejemplo n.º 6
0
 private void radBoundStandard_CheckedChanged(object sender, EventArgs e)
 {
     if (radBoundStandard.Checked)
     {
         boundMode = BoundaryMode.STANDARD;
     }
 }
Ejemplo n.º 7
0
 private void radBoundPeriod_CheckedChanged(object sender, EventArgs e)
 {
     if (radBoundPeriod.Checked)
     {
         boundMode = BoundaryMode.PERIODIC;
     }
 }
Ejemplo n.º 8
0
    void Advect(float[,] destination, float[,] source, float[,] velocityX, float[,] velocityY, BoundaryMode boundaryMode, float deltaTime)
    {
        // Instead of taking an explicit "integrate forward" approach, we do this implicit-style by tracing backwards from each cell center;\
        // since this requires us to compute a source value between cell centers, we simply linearly interpolate between the four neighbouring cells
        for (int x = 1; x < FluidDataBank.GRID_WIDTH - 1; ++x)
        {
            for (int y = 1; y < FluidDataBank.GRID_HEIGHT - 1; ++y)
            {
                float sampleX = x - deltaTime * velocityX[x, y];
                float sampleY = y - deltaTime * velocityY[x, y];

                int   leftX;
                int   rightX;
                int   bottomY;
                int   topY;
                float alphaX;
                float alphaY;

                GridCoordinatesToInterpolationParameters(sampleX, sampleY, out leftX, out rightX, out bottomY, out topY, out alphaX, out alphaY);
                destination[x, y] = SampleGrid(source, leftX, rightX, bottomY, topY, alphaX, alphaY);
            }
        }

        SetBoundaries(destination, boundaryMode);
    }
Ejemplo n.º 9
0
    void Relax(float[,] destination, float[,] source, int numIterations, float alpha, BoundaryMode boundaryMode, float deltaTime)
    {
        CopyGrid(destination, source);

        var k = alpha * deltaTime;

        // Gauss-Siedel relaxation of the target density matrix
        for (int iteration = 0; iteration < numIterations; ++iteration)
        {
            for (int x = 1; x < FluidDataBank.GRID_WIDTH - 1; ++x)
            {
                for (int y = 1; y < FluidDataBank.GRID_HEIGHT - 1; ++y)
                {
                    destination[x, y] = (source[x, y] + k * (destination[x - 1, y] + destination[x + 1, y] + destination[x, y - 1] + destination[x, y + 1])) / (1 + 4 * k);
                }
            }
        }

        SetBoundaries(destination, boundaryMode);
    }
Ejemplo n.º 10
0
        public BoggleGUI(Options c, Color valid_move, Color selected_move, ScoringMode score_mode = ScoringMode.SCRABBLE, BoardSize board_size = BoardSize.BIGBOGGLE,
            BoundaryMode bound_mode = BoundaryMode.STANDARD, int t_limit = 180000, int min_length = 3)
        {
            InitializeComponent();

            caller = (Options)c;
            colorValid = valid_move;
            colorSelected = selected_move;
            scoreMode = score_mode;
            boardSize = board_size;
            boundMode = bound_mode;
            timeLimit = t_limit;
            wordMin = min_length;
            string dice = caller.customDice;
            string word = caller.customWords;

            //Create psuedo control array
            btnArray = new Button[(int)boardSize];

            btnArray[0] = button1;
            btnArray[1] = button2;
            btnArray[2] = button3;
            btnArray[3] = button4;
            btnArray[4] = button5;
            btnArray[5] = button6;
            btnArray[6] = button7;
            btnArray[7] = button8;
            btnArray[8] = button9;
            btnArray[9] = button10;
            btnArray[10] = button11;
            btnArray[11] = button12;
            btnArray[12] = button13;
            btnArray[13] = button14;
            btnArray[14] = button15;
            btnArray[15] = button16;
            if (boardSize == BoardSize.BIGBOGGLE) // If Big Boggle need all the buttons
            {

                btnArray[16] = button17;
                btnArray[17] = button18;
                btnArray[18] = button19;
                btnArray[19] = button20;
                btnArray[20] = button21;
                btnArray[21] = button22;
                btnArray[22] = button23;
                btnArray[23] = button24;
                btnArray[24] = button25;

            }
            else // Else if Standard hide the extra buttons
            {
                button17.Visible = false;
                button18.Visible = false;
                button19.Visible = false;
                button20.Visible = false;
                button21.Visible = false;
                button22.Visible = false;
                button23.Visible = false;
                button24.Visible = false;
                button25.Visible = false;
                int btnNumber = 0;
                for (int row = 0; row < 4; row++) //Rearrange the buttons into a 4x4 grid
                {
                    for (int col = 0; col < 4; col++)
                    {
                        Point myPoint = new Point(41 * (col % 4), (41 * row));
                        btnArray[btnNumber].Location = myPoint;
                        btnNumber++;
                    }

                }
            }
        }
Ejemplo n.º 11
0
        // =================================================
        // Float Array
        // =================================================

        ///<summary>
        ///<returns>0 to sortedValues.Count integer</returns>
        ///</summary>
        public static int FloatBinarySearch(this IList <float> sortedValues, float value, BoundaryMode boundaryMode = BoundaryMode.Low)
        {
            var min = 0;
            var max = sortedValues.Count;

            if (boundaryMode == BoundaryMode.Low)
            {
                while (true)
                {
                    var next = (max - min) / 2 + min;
                    var dv   = sortedValues[next];
                    if (dv <= value)
                    {
                        min = next + 1;
                    }
                    else
                    {
                        max = next;
                    }
                    if (min == max)
                    {
                        break;
                    }
                }
            }
            else
            {
                while (true)
                {
                    var next = (max - min) / 2 + min;
                    var dv   = sortedValues[next];
                    if (dv < value)
                    {
                        min = next + 1;
                    }
                    else
                    {
                        max = next;
                    }
                    if (min == max)
                    {
                        break;
                    }
                }
            }
            return(min);
        }
Ejemplo n.º 12
0
 private void ValidateBoundary(BoundaryMode comparisonMode, int comparisonResult, object parameterValue, string parameterName)
 {
     if (comparisonResult < 0 || (comparisonResult == 0 && comparisonMode == BoundaryMode.Exclusive))
     {
         ValidationFailed(null, parameterValue, parameterName);
     }
 }