Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        numHoles       = fp.numHoles;
        blocksPlacedUI = GetComponent <Text>();
    }
Exemplo n.º 2
0
        /// <summary>
        /// Predictive covariance at a given pair of points
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public double Covariance(Vector x, Vector y)
        {
            double kxy = FixedParameters.Prior.Covariance(x, y);
            Vector kxB = FixedParameters.KernelOf_X_B(x);
            Vector kyB = FixedParameters.KernelOf_X_B(y);

            return(kxy - kxB.Inner(Beta * kyB));
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        timeDeduction       = fp.timeDeduction;
        timeInvincible      = fp.timeInvincible;
        rb2d                = GetComponent <Rigidbody2D>();
        rb2d.freezeRotation = true;
        sr = GetComponent <SpriteRenderer>();
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();
        float           x  = fp.numCols * fp.WALL_DISTANCE / 2.0F;
        float           y  = -fp.numRows * fp.WALL_DISTANCE / 2.0F;

        mazeCentre   = new Vector3(x, y, -10);
        nextSize     = Mathf.Max(x * 0.5625F, -y * 1.125F);
        offset       = transform.position - player.transform.position;
        playerCamera = GetComponent <Camera>();
    }
Exemplo n.º 5
0
 /// <summary>
 /// Mean at a given point
 /// </summary>
 /// <param name="X"></param>
 /// <returns></returns>
 public double Mean(Vector X)
 {
     if (IsUniform())
     {
         return(Gaussian.Uniform().GetMean());
     }
     else
     {
         Vector kxB = FixedParameters.KernelOf_X_B(X);
         return(kxB.Inner(Alpha) + FixedParameters.Prior.Mean(X));
     }
 }
 public override FunctionOverload BuildInternal()
 {
     return(new FunctionWildcardOverload(
                Name,
                Description,
                WildcardRegex,
                ReturnTypeBuilder,
                ReturnType,
                FixedParameters.ToImmutable(),
                VariableParameter,
                Evaluator,
                Flags));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Predictive Variance at a given point
 /// </summary>
 /// <param name="X">Input</param>
 /// <returns>Predictive variance</returns>
 public double Variance(Vector X)
 {
     if (IsUniform())
     {
         Gaussian temp = new Gaussian();
         temp.SetToUniform();
         return(temp.GetVariance());
     }
     else
     {
         Vector kxB = FixedParameters.KernelOf_X_B(X);
         return(FixedParameters.Prior.Variance(X) - Beta.QuadraticForm(kxB));
     }
 }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            if (IsPointMass)
            {
                return(Point.GetHashCode());
            }
            int hash = Hash.Start;

            hash = Hash.Combine(hash, FixedParameters.GetHashCode());
            hash = Hash.Combine(hash, IncludePrior.GetHashCode());
            hash = Hash.Combine(hash, pointFunc == null ? Hash.Start : pointFunc.GetHashCode());
            hash = Hash.Combine(hash, InducingDist.GetHashCode());
            return(hash);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Predictive distribution at a given point
 /// </summary>
 /// <param name="X">Input</param>
 /// <returns>Predictive distribution</returns>
 public Gaussian Marginal(Vector X)
 {
     if (IsUniform())
     {
         return(Gaussian.Uniform());
     }
     else
     {
         double   kxx    = FixedParameters.Prior.Variance(X);
         Vector   kxb    = FixedParameters.KernelOf_X_B(X);
         Gaussian result = new Gaussian(
             kxb.Inner(Alpha) + FixedParameters.Prior.Mean(X), kxx - Beta.QuadraticForm(kxb));
         return(result);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Predictive distribution at a given list of points
 /// </summary>
 /// <param name="XList">List of inputs</param>
 /// <returns>Predictive distribution</returns>
 public VectorGaussian Joint(IList <Vector> XList)
 {
     if (IsUniform())
     {
         return(VectorGaussian.Uniform(XList.Count));
     }
     else
     {
         PositiveDefiniteMatrix kXX = FixedParameters.Prior.Covariance(XList);
         Matrix kXB = FixedParameters.KernelOf_X_B(XList);
         kXX.SetToDifference(kXX, kXB * Beta * kXB.Transpose());
         VectorGaussian result = new VectorGaussian(kXB * Alpha + FixedParameters.Prior.Mean(XList), kXX);
         return(result);
     }
 }
Exemplo n.º 11
0
        public FunctionOverload(string name, string description, ReturnTypeBuilderDelegate returnTypeBuilder, TypeSymbol signatureType, IEnumerable <FixedFunctionParameter> fixedParameters, VariableFunctionParameter?variableParameter, EvaluatorDelegate?evaluator, FunctionFlags flags = FunctionFlags.Default)
        {
            Name              = name;
            Description       = description;
            ReturnTypeBuilder = returnTypeBuilder;
            Evaluator         = evaluator;
            FixedParameters   = fixedParameters.ToImmutableArray();
            VariableParameter = variableParameter;
            Flags             = flags;

            MinimumArgumentCount = FixedParameters.Count(fp => fp.Required) + (VariableParameter?.MinimumCount ?? 0);
            MaximumArgumentCount = VariableParameter == null ? FixedParameters.Length : (int?)null;

            TypeSignature       = $"({string.Join(", ", ParameterTypeSignatures)}): {signatureType}";
            TypeSignatureSymbol = signatureType;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Predictive coariance at a given list of points
 /// </summary>
 /// <param name="XList">List of inputs</param>
 /// <returns>Predictive covariance</returns>
 public PositiveDefiniteMatrix Covariance(IList <Vector> XList)
 {
     if (IsUniform())
     {
         VectorGaussian temp = new VectorGaussian(XList.Count);
         temp.SetToUniform();
         return(temp.GetVariance());
     }
     else
     {
         PositiveDefiniteMatrix kXX = FixedParameters.Prior.Covariance(XList);
         Matrix kXB = FixedParameters.KernelOf_X_B(XList);
         kXX.SetToDifference(kXX, kXB * Beta * kXB.Transpose());
         return(kXX);
     }
 }
Exemplo n.º 13
0
    // Use this for initialization
    void Awake()
    {
        FixedParameters.generateParameters(wallDistance, numRows, numCols, trapCount, numHoles,
                                           Mathf.CeilToInt(timeout * 60), numGuards, Mathf.CeilToInt(timeDeduction * 60), Mathf.CeilToInt(timeInvincible * 60),
                                           requireInitialInstructions);
        SharedValues sharedValues = SharedValues.GetInstance();

        sharedValues.timeLeft = Mathf.CeilToInt(gameTime * 60);
        sharedValues.level    = level;

        // other stuff
        sharedValues.holesSpawned         = 0;
        sharedValues.wallFrames           = 0;
        sharedValues.areWallsShown        = true;
        sharedValues.trapDisplayState     = 1;
        sharedValues.trapDisplayStateTime = 120;
        sharedValues.isStunned            = false;
        sharedValues.stunnedTime          = 0;
        sharedValues.hasGameStarted       = false;
        sharedValues.isGameOver           = false;
        sharedValues.win = false;
    }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        HALF_WALL_DISTANCE    = fp.HALF_WALL_DISTANCE;
        QUARTER_WALL_DISTANCE = fp.QUARTER_WALL_DISTANCE;

        numRows  = fp.numRows;
        numCols  = fp.numCols;
        numHoles = fp.numHoles;

        holes  = new int[numHoles, 2];
        blocks = new int[numHoles, 2];

        for (int i = 0; i < numHoles; i++)
        {
            holes[i, 0]  = Random.Range(0, numRows);
            holes[i, 1]  = Random.Range(0, numCols * 2);
            blocks[i, 0] = Random.Range(numRows, numRows * 2);
            blocks[i, 1] = Random.Range(0, numCols * 2);
        }
        SpawnNewBlockHolePair();
    }
Exemplo n.º 15
0
    public static void generateParameters(float wall_dist, int rows, int cols, int traps, int holes,
                                          int timeout, int numGuards, int timeDeduction, int timeInvincible, int requireInitialInstructions)
    {
        inst = new FixedParameters();

        inst.WALL_DISTANCE         = wall_dist;
        inst.HALF_WALL_DISTANCE    = 0.5F * wall_dist;
        inst.QUARTER_WALL_DISTANCE = 0.25F * wall_dist;

        inst.numRows   = rows;
        inst.numCols   = cols;
        inst.trapCount = traps;

        inst.numHoles = holes;

        inst.timeout = timeout;

        inst.numGuards = numGuards;

        inst.timeDeduction  = timeDeduction;
        inst.timeInvincible = timeInvincible;

        inst.requireInitialInstructions = requireInitialInstructions;
    }
Exemplo n.º 16
0
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        timeout = fp.timeout;
    }
Exemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        WALL_DISTANCE         = fp.WALL_DISTANCE;
        HALF_WALL_DISTANCE    = fp.HALF_WALL_DISTANCE;
        QUARTER_WALL_DISTANCE = fp.QUARTER_WALL_DISTANCE;

        numRows   = fp.numRows;
        numCols   = fp.numCols;
        trapCount = fp.trapCount;
        numGuards = fp.numGuards;


        horizontalWalls = new int[numRows + 1, numCols];

        verticalWalls = new int[numRows, numCols + 1];

        visited = new int[numRows, numCols];

        traps = new int[trapCount, 2];

        guards = new int[numGuards, 2];

        borderList = new List <Border>();



        for (int i = 0; i < horizontalWalls.GetLength(0); i++)
        {
            for (int j = 0; j < horizontalWalls.GetLength(1); j++)
            {
                horizontalWalls[i, j] = 1;
            }
        }

        for (int i = 0; i < verticalWalls.GetLength(0); i++)
        {
            for (int j = 0; j < verticalWalls.GetLength(1); j++)
            {
                verticalWalls[i, j] = 1;
            }
        }

        for (int i = 0; i < visited.GetLength(0); i++)
        {
            for (int j = 0; j < visited.GetLength(1); j++)
            {
                visited[i, j] = 0;
            }
        }

        //horizontalWalls[numRows, numCols - 1] = 0;
        //verticalWalls[0, 0] = 0;

        for (int i = 0; i < traps.GetLength(0); i++)
        {
            traps[i, 0] = Random.Range(0, numRows * 2);
            traps[i, 1] = Random.Range(0, numCols * 2);
            while (traps[i, 0] == 0 && traps[i, 1] == 0)
            {
                traps[i, 0] = Random.Range(0, numRows * 2);
                traps[i, 1] = Random.Range(0, numCols * 2);
            }
        }

        for (int i = 0; i < guards.GetLength(0); i++)
        {
            guards[i, 0] = Random.Range(0, numRows * 2);
            guards[i, 1] = Random.Range(0, numCols * 2);
        }



        ProcessCell(numRows - 1, numCols - 1);
        while (borderList.Count > 0)
        {
            int    index           = Random.Range(0, borderList.Count);
            Border borderToProcess = borderList[index];
            Border nextBorder      = borderList[borderList.Count - 1];
            borderList[index] = nextBorder;
            borderList.RemoveAt(borderList.Count - 1);
            ProcessWall(borderToProcess.orientation, borderToProcess.arrRow, borderToProcess.arrCol);
        }

        // walls
        for (int i = 0; i < horizontalWalls.GetLength(0); i++)
        {
            for (int j = 0; j < horizontalWalls.GetLength(1); j++)
            {
                if (horizontalWalls[i, j] == 1)
                {
                    Instantiate(wall, new Vector2((j * WALL_DISTANCE) + HALF_WALL_DISTANCE, -(i * WALL_DISTANCE)), Quaternion.identity);
                }
            }
        }
        for (int i = 0; i < verticalWalls.GetLength(0); i++)
        {
            for (int j = 0; j < verticalWalls.GetLength(1); j++)
            {
                if (verticalWalls[i, j] == 1)
                {
                    Instantiate(wall, new Vector2(j * WALL_DISTANCE, -((i * WALL_DISTANCE) + HALF_WALL_DISTANCE)), Quaternion.Euler(0, 0, 90));
                }
            }
        }

        // traps
        for (int i = 0; i < traps.GetLength(0); i++)
        {
            int        trapRow = traps[i, 0];
            int        trapCol = traps[i, 1];
            GameObject newWall = (GameObject)Instantiate(trap, new Vector2(trapCol * HALF_WALL_DISTANCE + QUARTER_WALL_DISTANCE,
                                                                           -(trapRow * HALF_WALL_DISTANCE) - QUARTER_WALL_DISTANCE), Quaternion.identity);
            newWall.GetComponent <TrapGPS>().trapStateOn = ((trapRow + trapCol) % 3) + 1;
        }

        // guards
        for (int i = 0; i < guards.GetLength(0); i++)
        {
            int guardRow = traps[i, 0];
            int guardCol = traps[i, 1];
            Instantiate(guard, new Vector2(guardCol * HALF_WALL_DISTANCE + QUARTER_WALL_DISTANCE,
                                           -(guardRow * HALF_WALL_DISTANCE) - QUARTER_WALL_DISTANCE), Quaternion.identity);
        }
    }
Exemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        FixedParameters fp = FixedParameters.GetInstance();

        requireInitialInstructions = fp.requireInitialInstructions;
    }