Ejemplo n.º 1
0
        public double calcActionErrorMetric()
        {
            ObjectSystem newState = this.getCurrentObjectSystem();
            int          numActionsToReachGoal = newState.findGeneralShortestPathAStar(this.end);

            return((double)numActionsToReachGoal);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            if (!args.Any()) { ShowHelp(); }
            var settings = GetMasterWorkerSlaveSettings(args);
            Debug.WriteLine(
                        $"Starting computation [{settings.ComputationLowerLimit}, {settings.ComputationUpperLimit}]" +
                        $" with  + {(settings.AsyncBus ? "async" : "sync")} bus" +
                        $" and {settings.SlaveObjectsCount} slave worker(s)"
                );
            //Create system
            var os = new ObjectSystem("/testSystem", new InMemoryBus(async: settings.AsyncBus));
            //Create master
            os.Create(() => new MasterWorkerObject(settings.SlaveObjectsCount));

            //Create subscriber to catch results sent from master
            var sub = os.Create(() => new ActionSubscriberObject<LogMessage>(msg =>
                   Console.WriteLine(
                       $"{settings.ComputationLowerLimit},"+
                       $"{settings.ComputationUpperLimit}," +
                       $"{settings.AsyncBus}," +
                       $"{settings.SlaveObjectsCount}," +
                       $"{msg.Message},"
                       )
               ));

            //Create generic obj and send some work parameters to the master
            var genericPub = os.Create(() => new GenericPublisherObject());
            var work = Enumerable.Range((int)settings.ComputationLowerLimit, (int)settings.ComputationUpperLimit).ToArray();
            genericPub.Publish(new PrimeOnPositionsToSumRequest(work));
            
            Console.ReadLine();
        }
Ejemplo n.º 3
0
    public int LayerOnExit;  // BallOnTable

    void OnTriggerEnter(Collider other)
    {
        if (ObjectSystem.IsObjectHittable(other.gameObject.tag) != -1)
        {
            other.gameObject.layer = LayerOnEnter;
        }
    }
Ejemplo n.º 4
0
    // This function computes different reward function based on chosen value.
    public float calcRewardManager(ObjectSystem current, ObjectSystem newState, int actionTaken,
                                   MessageHeader header, bool stopAction, int numActions)
    {
        switch (this.rewardFunctionType)
        {
        case 0:                 // Cosine distance
            return(this.calcCosineDistanceReward(current, newState, header, stopAction));

        case 1:                 // Sparse signal
            return(this.calcSparseSignalReward(current, newState, header, stopAction, numActions));

        case 2:                 // Sparse signal with distance potential
            return(this.calcPotentialBasedRewardReduceDistance(current, newState, header, stopAction, numActions));

        case 3:                 // Sparse signal with oracle potential
            return(this.calcPotentialBasedRewardFollowOracle(current, newState, actionTaken, header, stopAction, numActions));

        case 4:                 // Sparse signal with oracle potential
            return(this.calcPotentialBasedRewardFollowOracleReduceDistance(current, newState,
                                                                           actionTaken, header, stopAction, numActions));

        case 5:                 // Sparse signal with oracle addition
            return(this.calcPotentialBasedRewardFollowOracleReduceDistanceV2(current, newState,
                                                                             actionTaken, header, stopAction, numActions));

        case 6:                 // Sparse signal with oracle addition
            return(this.calcPotentialBasedRewardReduceDistanceV2(current, newState, header, stopAction, numActions));

        case 7:                 // Reward is negative of distance to the goal
            return(this.calcNegDistanceReward(current, newState, header, stopAction, numActions));

        default:
            throw new ApplicationException("Unknown reward type");
        }
    }
Ejemplo n.º 5
0
    // Calculate difference between two block states by squared
    public double calcUnnormalizedSumOfEuclidean(ObjectSystem state1, ObjectSystem state2)
    {
        List <Point3D> objLoc1 = state1.getObjectLocations();
        List <Point3D> objLoc2 = state2.getObjectLocations();

        if (objLoc1.Count != objLoc2.Count)
        {
            throw new ApplicationException("MDP Manager expects same number of objects." +
                                           " Either environments are different" +
                                           " or an object fell off the board and was removed. Found " + objLoc1.Count + " and " + objLoc2.Count);
        }

        double blockSize1 = state1.getSizeOfBlock();
        double blockSize2 = state2.getSizeOfBlock();

        if (Math.Abs(blockSize1 - blockSize2) > 0.001)
        {
            throw new ApplicationException("Block size differ. Found " + blockSize1 + " and " + blockSize2);
        }

        double sumOfEuclidean = 0;

        for (int i = 0; i < objLoc1.Count; i++)
        {
            Point3D p1 = objLoc1 [i];
            Point3D p2 = objLoc2 [i];

            double dist = p1.calc2DL2Distance(p2);
            sumOfEuclidean = sumOfEuclidean + dist;
        }

        return(sumOfEuclidean);
    }
Ejemplo n.º 6
0
        // Use this for initialization
        public void init(List <GameObject> cubes, float blockSize, float stepSize, int horizon)
        {
            //Add translation action controller
            GameObject robot = GameObject.Find("Robot");

            if (robot == null)
            {
                Debug.LogError("There must be a robotic agent called 'Robot'");
            }

            this.queue = new Queue <Job> ();
            this.numberOfJobsFinished = new SynchronizedInt();

            // Add actions that the robot can perform e.g., translation, picking etc.
            this.translation = robot.AddComponent <LinearTranslation> ();
            this.translation.init(10.00f);

            // Snapshot ID
            this.snapshotID = 1;

            // Maximum number of epsiodes
            this.maxNumActions = horizon;
            this.numActions    = 0;
            this.blockSize     = blockSize;

            this.minimumApproachDistance = Mathf.Infinity;

            this.cubes     = cubes;
            this.stepSize  = stepSize;
            this.current   = this.getCurrentObjectSystem();
            this.rewardStr = "$NONE$";
        }
Ejemplo n.º 7
0
 public CountryManager(ushort teamNum, ushort countryId)
 {
     this.countryTeamNum = teamNum;
     this.countryID      = countryId;
     mObjectSystem       = new ObjectSystem(countryID);
     mBuildSystem        = new BuildSystem(countryID);
 }
Ejemplo n.º 8
0
        public void updateClosestApproachMetric()
        {
            ObjectSystem newState   = this.getCurrentObjectSystem();
            double       biskMetric = this.mdpManager.calcBiskMetric(newState);

            this.minimumApproachDistance = (double)Mathf.Min((float)this.minimumApproachDistance, (float)biskMetric);
        }
Ejemplo n.º 9
0
        public double calcBiskMetric()
        {
            ObjectSystem newState   = this.getCurrentObjectSystem();
            double       biskMetric = this.mdpManager.calcBiskMetric(newState);

            return(biskMetric);
        }
Ejemplo n.º 10
0
 public void changeEpisode(List <GameObject> cubes, ObjectSystem start, ObjectSystem end,
                           List <int> trajectory, List <Point3D> trajectoryPoints, int numObjects, float blockSize)
 {
     this.cubes = cubes;
     this.mdpManager.changeScenario(start, end, trajectory, trajectoryPoints);
     this.blockSize = blockSize;
     this.end       = end;
     this.minimumApproachDistance = this.mdpManager.calcBiskMetric(start);
 }
Ejemplo n.º 11
0
    private List <GameObject> createDigitCubes(ObjectSystem system, GameObject sampleCube, GameObject sampleDigits)
    {
        this.colors    = this.getUniqueColors();
        this.digitText = new List <GameObject> ();
        List <GameObject> cubes = new List <GameObject> ();

        // Make the cube inactive
        sampleCube.SetActive(false);

        int   ix        = 0;
        float blockSize = (float)system.getSizeOfBlock();

        Material[] newMaterial = new Material[1];
        newMaterial [0] = sampleCube.GetComponent <Renderer> ().materials [0];
        sampleCube.GetComponent <Renderer> ().materials = newMaterial;

        foreach (string brand in brandsList)
        {
            Debug.Log("Creating cube for digit: " + (ix + 1));
            // Create the game object
            GameObject newObj = (GameObject)Object
                                .Instantiate(sampleCube, sampleCube.transform.position, Quaternion.identity);

            if (!this.simplifiedProblem)
            {
                // Create digit and write the letter
                GameObject newDigits = (GameObject)Object
                                       .Instantiate(sampleDigits, sampleDigits.transform.position, sampleDigits.transform.rotation);
                newDigits.name = "Digits_" + ix;
                Vector3 oldScale = newDigits.transform.localScale;
                newDigits.GetComponent <TextMesh> ().text = (ix + 1).ToString();
                newDigits.SetActive(false);
                this.digitText.Add(newDigits);
                newDigits.transform.parent = newObj.transform;
            }

            newObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f) * (float)blockSize;
            newObj.name = "Cube_Digit_" + ix;

            // Simplified problem adds a unique color to every block
            if (this.simplifiedProblem)
            {
                Material[] materials = newObj.GetComponent <Renderer> ().materials;
                materials [0].EnableKeyword("_EMISSION");
                materials [0].SetColor("_EmissionColor", this.colors [ix]);
            }

            ix++;

            newObj.SetActive(false);
            cubes.Add(newObj);
        }

        sampleDigits.SetActive(false);

        return(cubes);
    }
Ejemplo n.º 12
0
    private float calcPotentialBasedRewardFollowOracleReduceDistance(ObjectSystem current, ObjectSystem newState, int action,
                                                                     MessageHeader header, bool stopAction, int numActions)
    {
        if (header == MessageHeader.FailureACK || header == MessageHeader.FailureAndResetACK)
        {
            return(-1.0f);
        }

        ObjectSystem toReach = this.end;

        // The system went from current to newState and it has to reach toReach
        List <Point3D> objLoc1 = current.getObjectLocations();

        // Compute distance d13 is pre-transition distance and d23 is post transition action.
        double d13 = this.calcUnnormalizedSumOfEuclidean(current, toReach);
        double d23 = this.calcUnnormalizedSumOfEuclidean(newState, toReach);

        double blockSize = newState.getSizeOfBlock();

        double rawReward = -0.02f;

        if (stopAction)          // || numActions == this.horizon) {
        {
            if (d23 < blockSize) //1.0 if within 1 block distance
            {
                rawReward = 1.0f;
            }
            else
            {
                rawReward = this.stopActionReward;
            }
        }
        else
        {
            rawReward = -0.02f;             //verbosity penalty
        }

        double potentialOld = -d13 / blockSize;
        double potentialNew = -d23 / blockSize;

        //when stopping the new and old potential will be same.
        double  reshapedReward     = rawReward + potentialNew - potentialOld;
        Point3D preTransitionState = objLoc1 [this.indexObjMoved];

        double oraclePotential = this.potentialFromTrajectory(preTransitionState,
                                                              action, this.trajectoryPoints, this.trajectory);

        reshapedReward = reshapedReward + oraclePotential - this.potentialOld;

        if (this.overridePotential)
        {
            // Hack that override potential. Hack was added to return rewards for all CB
            this.potentialOld = oraclePotential;
        }

        return((float)reshapedReward);
    }
Ejemplo n.º 13
0
        private SystemMediator()
        {
            #region 系统实例化

            DelegateSystem = new DelegateSystem(this);
            ObjectSystem   = new ObjectSystem(this);

            #endregion
        }
Ejemplo n.º 14
0
    public void changeScenario(ObjectSystem start, ObjectSystem end, List <int> trajectory, List <Point3D> trajectoryPoints)
    {
        this.start            = start;
        this.end              = end;
        this.potentialOld     = -0.02f;    //0.0;
        this.trajectory       = trajectory;
        this.trajectoryPoints = trajectoryPoints;

        // Compute the objected moved
        List <Point3D> objLoc1 = this.start.getObjectLocations();
        List <Point3D> objLoc2 = this.end.getObjectLocations();

        double blockSize1 = this.start.getSizeOfBlock();
        double blockSize2 = this.end.getSizeOfBlock();

        if (objLoc1.Count != objLoc2.Count)
        {
            throw new ApplicationException("MDP Manager expects same number of objects." +
                                           " Either environments are different" +
                                           " or an object fell off the board and was removed");
        }

        if (Math.Abs(blockSize1 - blockSize2) > 0.001)
        {
            throw new ApplicationException("Block size differ. Found " + blockSize1 + " and " + blockSize2);
        }

        int mainBlock    = -1;
        int changedBlock = 0;

        for (int i = 0; i < objLoc1.Count; i++)
        {
            Point3D p1 = objLoc1 [i];
            Point3D p2 = objLoc2 [i];

            if (p1.calc2DL2Distance(p2) > 0.001)
            {
                mainBlock = i;
                changedBlock++;

                if (changedBlock > 1)
                {
                    mainBlock = -1;
                    break;
                }
            }
        }

        if (mainBlock == -1)
        {
            Debug.LogError("Needed exactly one block to move. Found "
                           + changedBlock + " many blocks moved.");
        }

        this.indexObjMoved = mainBlock;
    }
Ejemplo n.º 15
0
 public SystemView(ObjectSystem sys)
 {
     this.sys = sys;
     order    = new List <int>();
     for (int i = 0; i < sys.Count; i++)
     {
         order.Add(i);
     }
     Redraw();
 }
Ejemplo n.º 16
0
    // This reward is negative of distance from the new state to the goal state
    private float calcNegDistanceReward(ObjectSystem current, ObjectSystem newState,
                                        MessageHeader header, bool stopAction, int numActions)
    {
        // Compute distance d13 is pre-transition distance and d23 is post transition action.
        double distance  = this.calcUnnormalizedSumOfEuclidean(newState, this.end);
        double blockSize = newState.getSizeOfBlock();
        double reward    = -distance / blockSize;

        return((float)reward);
    }
Ejemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        _system  = new ObjectSystem();
        CurTime  = DelayTime;
        setTimer = DelayTime / 4;

        if (gameObject.GetComponent <GizmoSelection>())
        {
            ActiveLayer = gameObject.GetComponent <GizmoSelection>().DynamicLayer;
        }
    }
Ejemplo n.º 18
0
 public SystemWindow(String s, ObjectSystem sys) : base(s)
 {
     sys_view = new SystemView(sys);
     this.Add(sys_view);
     this.Events            |= EventMask.PointerMotionMask | EventMask.ScrollMask;
     this.DeleteEvent       += delegate { Application.Quit(); };
     this.KeyPressEvent     += Program.Input.KeyPress;
     this.MotionNotifyEvent += Program.Input.MouseMovement;
     this.ScrollEvent       += Program.Input.Scroll;
     this.ShowAll();
 }
Ejemplo n.º 19
0
        public string reset()
        {
            InitScript init        = GameObject.Find("Ground").GetComponent <InitScript> ();
            string     instruction = init.reset();

            string fileName = "deprecated";

            this.snapshotID++;

            this.current = this.getCurrentObjectSystem();
            return(fileName + "#" + instruction);
        }
Ejemplo n.º 20
0
    public void resetEnd()
    {
        DataPoint    current         = this.dataset [this.datapointIndex];
        int          start           = current.getStartFrame();
        int          end             = current.getEndFrame();
        Episode      episode         = current.getEpisode();
        ObjectSystem system          = episode.getEnvironmentByIndex(start);
        ObjectSystem toReach         = episode.getEnvironmentByIndex(end);
        Decoration   pointDecoration = current.getDecoration();

        this.render(toReach, pointDecoration);
        this.highlightMainBlockAndGoal(system, toReach);
    }
Ejemplo n.º 21
0
        public static void PITest()
        {
            ObjectSystem sys = new ObjectSystem(new List <SimObject>()
            {
                new Block()
                {
                    position    = new Vector3(0, 0, 0),
                    velocity    = new Vector3(0, 0, 0),
                    mass        = 1e300,
                    dimensions  = new Vector3(2, 8, 8),
                    color       = new Vector3(1, 0, 0),
                    orientation = new Vector3(0, 0, 0),
                },
                new Ball()
                {
                    position = new Vector3(2.5, 0, 0),
                    velocity = new Vector3(0, 0, 0),
                    mass     = 1,
                    color    = new Vector3(0, 1, 0),
                },
                new Ball()
                {
                    position = new Vector3(5, 0, 0),
                    velocity = new Vector3(-1, 0, 0),
                    mass     = Math.Pow(100, DIGITS),
                    color    = new Vector3(0, 0, 1),
                },
            });
            int j    = 0;
            int last = -1;

            Application.Init();
            var sysWindow = new Graphics.SystemWindow("Mechanics Simulation", sys);

            sysWindow.PlayAsync(interval: 0);
            active_syswindow = sysWindow;
            Console.WriteLine("hi");
            Task.Run(() => {
                while (true)
                {
                    sys.TimeStep(Math.Pow(10, PRECISION));
                    // Don't output every frame, and only if the number of collisions has changed
                    if (j++ % 1e4 == 0 && last != collision_counter)
                    {
                        Console.WriteLine($"{collision_counter} collisions");
                        last = collision_counter;
                    }
                }
            });
            Application.Run();
        }
Ejemplo n.º 22
0
    void OnTriggerStay(Collider col)
    {
        int tmp = ObjectSystem.IsObjectHittable(col.gameObject.tag);

        if (tmp == 5)
        {
            for (int i = 0; i < ashCount; i++)
            {
                Vector3 pos = col.transform.position + new Vector3(1, 1, 1) * Random.Range(0.5f, 0.9f);
                Instantiate(ashParent, pos, col.transform.rotation, col.transform.parent);
            }
            Destroy(col.gameObject);
        }
    }
Ejemplo n.º 23
0
    private float calcPotentialBasedRewardFollowOracleReduceDistanceV2(ObjectSystem current,
                                                                       ObjectSystem newState, int action, MessageHeader header, bool stopAction, int numActions)
    {
        ObjectSystem toReach = this.end;

        // The system went from current to newState and it has to reach toReach
        List <Point3D> objLoc1 = current.getObjectLocations();
        List <Point3D> objLoc2 = newState.getObjectLocations();
        List <Point3D> objLoc3 = toReach.getObjectLocations();

        // Compute distance d13 is pre-transition distance and d23 is post transition action.
        double d13       = objLoc1 [this.indexObjMoved].calc2DL2Distance(objLoc3 [this.indexObjMoved]);
        double d23       = objLoc2 [this.indexObjMoved].calc2DL2Distance(objLoc3 [this.indexObjMoved]);
        double blockSize = newState.getSizeOfBlock();

        double rawReward = -0.02f;

        if (stopAction /*|| numActions == this.horizon*/)
        {
            if (d23 < blockSize)               //1.0 if within 1 block distance
            {
                rawReward = 1.0f;
            }
            else
            {
                rawReward = this.stopActionReward;
            }
        }
        else
        {
            rawReward = -0.02f;             //verbosity penalty
        }


        double potentialOld = -d13 / blockSize;
        double potentialNew = -d23 / blockSize;

        //when stopping the new and old potential will be same.
        double  reshapedReward     = rawReward + (potentialNew - potentialOld) / (10.0);
        Point3D preTransitionState = objLoc1 [this.indexObjMoved];

        double oraclePotential = this.potentialFromTrajectoryV2(preTransitionState,
                                                                action, this.trajectoryPoints, this.trajectory);

        reshapedReward = reshapedReward + oraclePotential;

        return((float)reshapedReward);
    }
Ejemplo n.º 24
0
    private List <GameObject> createLogoCubes(ObjectSystem system, GameObject sampleCube)
    {
        this.colors = this.getUniqueColors();
        List <GameObject> cubes = new List <GameObject> ();

        // Make the cube inactive
        sampleCube.SetActive(false);

        int   ix        = 0;
        float blockSize = (float)system.getSizeOfBlock();

        foreach (string brand in brandsList)
        {
            Debug.Log("Creating cube for brand: " + brand);
            Texture texture = (Texture2D)Resources.Load(brand);
            if (texture == null)
            {
                throw new System.Exception("texture is null");
            }

            // Create the game object
            GameObject newObj = (GameObject)Object
                                .Instantiate(sampleCube, sampleCube.transform.position, Quaternion.identity);

            if (!this.simplifiedProblem)
            {
                newObj.GetComponent <Renderer> ().materials [1].mainTexture = texture;
            }

            newObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f) * (float)blockSize;
            newObj.name = "Cube_Logo_" + ix;

            // Simplified problem adds a unique color to every block
            if (this.simplifiedProblem)
            {
                Material[] materials = newObj.GetComponent <Renderer> ().materials;
                materials [0].EnableKeyword("_EMISSION");
                materials [0].SetColor("_EmissionColor", this.colors [ix]);
            }

            newObj.SetActive(false);
            cubes.Add(newObj);
            ix++;
        }

        return(cubes);
    }
Ejemplo n.º 25
0
    // TEMPORARY: changes color of the block to be moved and moves the GoalState plane
    // to where the block has to be.
    private void highlightMainBlockAndGoal(ObjectSystem system, ObjectSystem toReach)
    {
        /*if (!this.simplifiedProblem) {
         *      return;
         * }*/

        // Find the changed object
        List <Point3D> system1 = system.getObjectLocations();
        List <Point3D> system2 = toReach.getObjectLocations();

        int i = 0;

        for (int k = 0; k < system1.Count; k++)
        {
            Point3D o1 = system1 [k];
            Point3D o2 = system2 [k];

            if (o1.calc2DL2Distance(o2) > 0.1f)
            {
                i = k;
                break;
            }
        }

        // Change all cube to their default color

        /*for(int j = 0; j < this.cubes.Count; j++) {
         *      GameObject cubeObj = this.cubes[j];
         *      Material[] materials = cubeObj.GetComponent<Renderer> ().materials;
         *      materials[0].SetColor ("_EmissionColor", this.colors[j]);
         * }
         *
         * // Change the select cube to BLACK color
         * GameObject selectedCubeObj = this.cubes [i];
         * Material[] selectedCubeMaterials = selectedCubeObj.GetComponent<Renderer> ().materials;
         * selectedCubeMaterials[0].SetColor ("_EmissionColor", Color.black);
         * Vector3 blackPos = selectedCubeObj.transform.position;
         * Debug.Log ("Black cube at " + blackPos.x + ", " + blackPos.y + ", " + blackPos.z);*/

        // Move plate to where the cubeObj has to be moved
        GameObject goalStatePlane = GameObject.Find("GoalState");
        Point3D    finalPoint     = system2 [i];

        goalStatePlane.transform.position = new Vector3((float)finalPoint.getX(),
                                                        (float)finalPoint.getY(), (float)finalPoint.getZ());
    }
Ejemplo n.º 26
0
    // This reward is based on potential. This reward is given based on
    // following oracle.
    private float calcPotentialBasedRewardFollowOracle(ObjectSystem current, ObjectSystem newState, int action,
                                                       MessageHeader header, bool stopAction, int numActions)
    {
        if (header == MessageHeader.FailureACK || header == MessageHeader.FailureAndResetACK)
        {
            return(-1.0f);
        }

        ObjectSystem toReach = this.end;

        // The system went from current to newState and it has to reach toReach
        List <Point3D> objLoc1 = current.getObjectLocations();

        // Compute distance d13 is pre-transition distance and d23 is post transition action.
        // double d23 = objLoc2 [this.indexObjMoved].calc2DL2Distance (objLoc3 [this.indexObjMoved]);
        double d23 = this.calcUnnormalizedSumOfEuclidean(newState, toReach);

        double blockSize = newState.getSizeOfBlock();

        double rawReward = -0.02f;

        if (stopAction /*|| numActions == this.horizon*/)
        {
            if (d23 < blockSize)               //1.0 if within 1 block distance
            {
                rawReward = 1.0f;
            }
            else
            {
                rawReward = this.stopActionReward;
            }
        }
        else
        {
            rawReward = -0.02f;             //verbosity penalty
        }

        Point3D preTransitionState = objLoc1 [this.indexObjMoved];

        double potentialNew   = this.potentialFromTrajectory(preTransitionState, action, this.trajectoryPoints, this.trajectory);
        double reshapedReward = rawReward + potentialNew - this.potentialOld;

        this.potentialOld = potentialNew;

        return((float)reshapedReward);
    }
Ejemplo n.º 27
0
    private void render(ObjectSystem system, Decoration pointDecoration)
    {
        List <Point3D> objectLocations = system.getObjectLocations();

        for (int i = 0; i < brandsList.Count; i++)
        {
            this.logoCubes [i].SetActive(false);
            this.digitCubes [i].SetActive(false);
            if (this.decoration == Decoration.Digits || this.decoration == Decoration.Both)
            {
                this.digitText [i].SetActive(false);
            }
        }

        int ix = 0;

        foreach (Point3D objectLocation in objectLocations)
        {
            Vector3 spawnPoint = new Vector3((float)objectLocation.getX(),
                                             (float)objectLocation.getY(),
                                             (float)objectLocation.getZ());
            GameObject cubeObj = null;
            if (pointDecoration == Decoration.Logos)
            {
                cubeObj = this.logoCubes [ix];
            }
            else if (pointDecoration == Decoration.Digits)
            {
                cubeObj = this.digitCubes [ix];
            }

            cubeObj.transform.position = spawnPoint;
            cubeObj.transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
            cubeObj.SetActive(true);

            if (pointDecoration == Decoration.Digits)
            {
                GameObject digitTex = this.digitText [ix];
                digitTex.transform.position = new Vector3(spawnPoint.x, spawnPoint.y, spawnPoint.z);
                digitTex.SetActive(true);
            }

            ix++;
        }
    }
Ejemplo n.º 28
0
        public double calculateShortestPathMetric()
        {
            ObjectSystem newState = this.getCurrentObjectSystem();

            //Compute distance between this newState and the old state
            TrajectoryResult result     = newState.findShortestPathAStar(this.end);
            List <int>       trajectory = result.getTrajectory();
            int count = trajectory.Count;

            if (trajectory [trajectory.Count - 1] == 80)
            {
                count--;
            }
            double distance             = this.stepSize * count + result.getMinDistanceAchieved();
            double shortestPathDistance = distance / this.blockSize;

            return(shortestPathDistance);
        }
 // Token: 0x0600004B RID: 75 RVA: 0x0000B0A0 File Offset: 0x000092A0
 public static void StartupRetroEngine()
 {
     if (!EngineCallbacks.engineInit)
     {
         GlobalAppDefinitions.CalculateTrigAngles();
         GraphicsSystem.GenerateBlendLookupTable();
         if (FileIO.CheckRSDKFile())
         {
             GlobalAppDefinitions.LoadGameConfig("Data/Game/GameConfig.bin".ToCharArray());
         }
         AudioPlayback.InitAudioPlayback();
         StageSystem.InitFirstStage();
         ObjectSystem.ClearScriptData();
         EngineCallbacks.engineInit = true;
         return;
     }
     RenderDevice.UpdateHardwareTextures();
 }
Ejemplo n.º 30
0
    // This reward is based on distance potential-based shaping term.
    private float calcPotentialBasedRewardReduceDistance(ObjectSystem current, ObjectSystem newState,
                                                         MessageHeader header, bool stopAction, int numActions)
    {
        if (header == MessageHeader.FailureACK || header == MessageHeader.FailureAndResetACK)
        {
            return(-1.0f);
        }

        ObjectSystem toReach = this.end;

        // The system went from current to newState and it has to reach toReach

        // Compute distance d13 is pre-transition distance and d23 is post transition action.
        double d13 = this.calcUnnormalizedSumOfEuclidean(current, toReach);
        double d23 = this.calcUnnormalizedSumOfEuclidean(newState, toReach);

        double blockSize = newState.getSizeOfBlock();

        double rawReward = -0.02f;

        if (stopAction /* || numActions == this.horizon*/)
        {
            if (d23 < blockSize)               //1.0 if within 1 block distance
            {
                rawReward = 1.0f;
            }
            else
            {
                rawReward = this.stopActionReward;
            }
        }
        else
        {
            rawReward = -0.02f;             //verbosity penalty
        }

        double potentialOld = -d13 / blockSize;
        double potentialNew = -d23 / blockSize;

        //when stopping the new and old potential will be same.
        double shapedReward = rawReward + potentialNew - potentialOld;

        return((float)shapedReward);
    }
Ejemplo n.º 31
0
        public double calcReward(bool stopAction)
        {
            ObjectSystem newState = this.getCurrentObjectSystem();

            if (stopAction)
            {
                this.actionID = 80;
            }

            float reward = this.mdpManager.calcRewardManager(this.current, newState, this.actionID,
                                                             this.messageHeader, stopAction, this.numActions);

            this.current = newState;

            // Updated closest approach metric
            this.updateClosestApproachMetric();

            return(reward);
        }
Ejemplo n.º 32
0
        static void Main()
        {
            //Create system
            var os = new ObjectSystem("/testSystem", new InMemoryBus(async: true));
            var log = os.Create(() => new LoggerObject(), "logger/1");
            var echo = os.Create(() => new EchoObject(), "echo");
            //send ping to echo actor from 50 different objects
            var taskArray = Enumerable
                .Range(0, 50)
                .Select(i => os.Create(() => new AskAnswerPingObject()).Ping("/testSystem/echo"))
                .ToArray();
            Task.WaitAll(taskArray);

            var log2 = os.Create(() => new LoggerObject(), "logger/2");
            var log3 = os.Create(() => new LoggerObject(), "logger/3");
            var slbp = os.Create(() => new SendingLogByPathObject());
            //send log messages to loggers, specify them with path
            slbp.SendLogByPath("/testSystem/logger/2");
            slbp.SendLogByPath("/testSystem/logger/2");
            slbp.SendLogByPath("/testSystem/logger/2");
            slbp.SendLogByPath("/testSystem/logger/3");
            slbp.SendLogByPath("/testSystem/logger/3");
            slbp.SendLogByPath("/testSystem/logger/3");
        }