Esempio n. 1
0
    public static void Main(String[] args)
    {
        try
        {
            Simulate sm=new Simulate();
            vehicles=new Vehicle[5];
            for(int i=0;i<noOfVehicles;i++)
            {
                vehicles[i]=new Vehicle(i);
                Thread t = new Thread(new ThreadStart(vehicles[i].exec));
                t.Start();
                Thread.Sleep(1000);
            }

        }
        catch (Exception ex)
        {
            System.Console.WriteLine(ex);

        }
    }
Esempio n. 2
0
 private void OnEnable()
 {
     simulator = target as Simulate;
 }
 /// <summary>
 /// Method to simulate one time step in conway's game of life.
 /// </summary>
 /// <param name="InitialTable"> The current game of life table. </param>
 /// <returns> The next time step game of life table. </returns>
 public int[,] SimulateNextStep(int[,] InitialTable)
 {
     return(Simulate.GenerateNextStep(InitialTable));
 }
Esempio n. 4
0
 static void Main(string[] args)
 {
     Task.Delay(1000).Wait();
     Simulate.Events().Hold(KeyCode.S).Wait(1000).Release(KeyCode.S).Invoke().Wait();
     Console.ReadLine();
 }
Esempio n. 5
0
 /// <summary>
 /// Simulate the events contained within this <see cref="EventBuilder"/>
 /// </summary>
 /// <param name="Options">Options that control the flow of these events</param>
 /// <returns></returns>
 public Task <bool> Invoke(InvokeOptions Options)
 {
     return(Simulate.Events(Options, Events.ToList()));
 }
Esempio n. 6
0
    void Start()
    {
        //Setting the size of the mesh, specially the density
        //int gridSize = gridSizeNew + (gridSizeNew - 1);
        int gridSize = gridSizeNew + gridSizeNew * (gridSizeNew - 1);

        //Initialice the list of particles, springs and triangles.
        _particles = new List <Particles>();
        _springs   = new List <Springs>();
        _triangles = new List <Triangles>();
        _sphere    = new List <GameObject>();
        _edges     = new List <Edges>();

        //To be able to change the size of the sphere
        sphereControl.transform.localScale = new Vector3(sphereScale, sphereScale, sphereScale);

        //In the editor to have a parent of all the particles
        var particleParent = new GameObject("particleParent");

        //Calcule the area of the cloth
        float area = 0.2f * (gridSize - 1) * 0.2f * (gridSize - 1);

        //Calcule the total mass of the cloth with the density
        float massTotal = clothDensity * area;
        //Calcule the mass of each particle
        float mass = massTotal / (gridSize * gridSize);

        //Instantiate the position of the particles and the gameobject.
        float jP = 0;
        float iP = 0;
        int   pi = 0;
        int   pj = 0;

        for (int i = 0; i < gridSize; i++)
        {
            for (int j = 0; j < gridSize; j++)
            {
                jP = j * 0.1f;
                iP = i * 0.1f;

                var newP = ParticlesBehaviour.Create(transform.position + new Vector3(jP, 0.0f, iP), mass, pi, pj, sphereControl);
                newP.transform.SetParent(particleParent.transform, false);
                newP.transform.localPosition = (new Vector3(jP, 0.0f, iP) + transform.position);
                newP.particles.Position      = newP.transform.position;
                _particles.Add(newP.particles);
                pi++;
            }
            pj++;
        }

        int edgesCount = 0;

        //Instntiate all the springs and all the edges to
        //be able to check collisions (just edges that mades all the triangles)
        //Springs
        //Structural Horizontal - Right
        for (int j = 0; j < gridSize; j++)
        {
            for (int i = 0; i < gridSize - 1; i++)
            {
                var index = j * gridSize + i;
                var c     = _particles[index];
                var right = _particles[index + 1];
                var re    = new Springs(c, right, elasticConstantStructural, dampingConstant, 1);
                _springs.Add(re);
                var ed = new Edges(index, index + 1, edgesCount);
                edgesCount++;
                ed.PosEdges(c.Position, right.Position);
                _edges.Add(ed);
            }
        }

        //Structural Vertical - Bot
        for (int j = 0; j < gridSize - 1; j++)
        {
            for (int i = 0; i < gridSize; i++)
            {
                var index_1 = j * gridSize + i;
                var index_2 = (j + 1) * gridSize + i;
                var c       = _particles[index_1];
                var right   = _particles[index_2];
                var re      = new Springs(c, right, elasticConstantStructural, dampingConstant, 1);
                _springs.Add(re);
                var ed = new Edges(index_1, index_2, edgesCount);
                edgesCount++;
                ed.PosEdges(c.Position, right.Position);
                _edges.Add(ed);
            }
        }

        //Shear - \ - Down
        for (int j = 0; j < gridSize - 1; j++)
        {
            for (int i = 0; i < gridSize - 1; i++)
            {
                var index_1 = j * gridSize + i;
                var index_2 = (j + 1) * gridSize + i + 1;
                var c       = _particles[index_1];
                var bot     = _particles[index_2];
                var re      = new Springs(c, bot, elasticConstantShear, dampingConstant, 2);
                _springs.Add(re);
                var ed = new Edges(index_1, index_2, edgesCount);
                edgesCount++;
                ed.PosEdges(c.Position, bot.Position);
                _edges.Add(ed);
            }
        }

        //Shear - / - Down
        for (int j = 0; j < gridSize - 1; j++)
        {
            for (int i = 1; i < gridSize; i++)
            {
                var index_1 = j * gridSize + i;
                var index_2 = (j + 1) * gridSize + i - 1;
                var c       = _particles[index_1];
                var top     = _particles[index_2];
                var re      = new Springs(c, top, elasticConstantShear, dampingConstant, 2);
                _springs.Add(re);
            }
        }

        //Bend - Left
        for (int j = 0; j < gridSize; j++)
        {
            for (int i = 0; i < gridSize - 2; i++)
            {
                var index_1 = j * gridSize + i;
                var index_2 = j * gridSize + i + 2;
                var c       = _particles[index_1];
                var left    = _particles[index_2];
                var re      = new Springs(c, left, elasticConstantBend, dampingConstant, 3);
                _springs.Add(re);
            }
        }

        //Bend - Down
        for (int j = 0; j < gridSize - 2; j++)
        {
            for (int i = 0; i < gridSize; i++)
            {
                var index_1 = j * gridSize + i;
                var index_2 = (j + 2) * gridSize + i;
                var c       = _particles[index_1];
                var left    = _particles[index_2];
                var re      = new Springs(c, left, elasticConstantBend, dampingConstant, 3);
                _springs.Add(re);
            }
        }

        //Fix two particles
        _particles[0].isActive            = false;
        _particles[gridSize - 1].isActive = false;

        Vector3.Normalize(normalSecondPlane);

        //Calcule a part of the wind force and call the simulation script to incitialize it with all the needed information
        winddirectiondensity = windDirection * windModule * clothDensity;
        simulator            = new Simulate(_particles, _springs, _triangles, _edges, winddirectiondensity, plane, secondPlane, normalSecondPlane, gridSize, frictionConstPlane, dissipationConstPlane, frictionConstCloth, dissipationConstCloth, drawSprings, EdgeOrPointCheck, SphereRightHand, frictionConstShpereHand, dissipationConstSphereHand, SphereLeftHand);

        //Creating the mess
        mesh = new Mesh();
        GetComponent <MeshFilter>().mesh = mesh;
        CreateShape();
        UpdateMesh();
        UpdateEdges();
    }
Esempio n. 7
0
 protected sealed override Task <bool> Invoke(InvokeOptions Options)
 {
     return(Simulate.Events(Options, Children));
 }
Esempio n. 8
0
    static void Main(string[] args)
    {
        string[] inputs;

        // game loop
        while (true)
        {
            map = new Map();

            turnType = int.Parse(Console.ReadLine());
            for (int i = 0; i < 7; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                for (int j = 0; j < 7; j++)
                {
                    string tile = inputs[j];
                    //Console.Error.WriteLine(tile);
                    map.add(new Point(j, i), new Tile(tile));
                }
            }

            players = new List <Player>();

            for (int i = 0; i < 2; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                int    numPlayerCards = int.Parse(inputs[0]); // the total number of quests for a player (hidden and revealed)
                int    playerX        = int.Parse(inputs[1]);
                int    playerY        = int.Parse(inputs[2]);
                string playerTile     = inputs[3];

                players.Add(new Player(playerX, playerY, numPlayerCards, new Tile(playerTile)));
            }

            items = new List <Item>();

            int numItems = int.Parse(Console.ReadLine()); // the total number of items available on board and on player tiles
            for (int i = 0; i < numItems; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                string itemName     = inputs[0];
                int    itemX        = int.Parse(inputs[1]);
                int    itemY        = int.Parse(inputs[2]);
                int    itemPlayerId = int.Parse(inputs[3]);

                items.Add(new Item(itemX, itemY, itemName, itemPlayerId));
                players[itemPlayerId].items.Add(items[i]);
            }

            int numQuests = int.Parse(Console.ReadLine()); // the total number of revealed quests for both players
            for (int i = 0; i < numQuests; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                // Console.Error.WriteLine(inputs[0], inputs[1]);
                string questItemName = inputs[0];
                int    questPlayerId = int.Parse(inputs[1]);
                players[questPlayerId].quests.Add(questItemName);
            }

            players[0].setTargetList();
            players[1].setTargetList();

            players[0].opponent = players[1];
            players[1].opponent = players[0];

            map.backup();

            Simulate sim = new Simulate();

            Console.WriteLine(sim.bestMove());
        }
    }
 private void Awake()
 {
     simulate = Global.sim;
 }
Esempio n. 10
0
    public bool formato_rut()
    {
        bool tempformato_rut = false;

        //VALIDAR RUT
        int i = 0;
        //Dim X As Integer
        int total      = 0;
        int totaltotal = 0;
        int por        = 0;
        int rut        = 0;
        int guion      = 0;
        //Dim nrut As Integer
        int  posicion = 0;
        int  valor    = 0;
        bool verdad   = false;

        if (txt_dv.Text == "k")
        {
            txt_dv.Text = "K";
        }

        i          = 1;
        total      = 0;
        totaltotal = 0;

        rut      = txt_rut.Text.Length;
        posicion = rut;
        por      = 2;


        //RECORRER EL R.U.T.
        for (i = 1; i <= rut; i++)
        {
            if (por == 8)
            {
                por = 2;
            }

            total      = Convert.ToInt32(por * Simulate.Val(txt_rut.Text.Substring(posicion - 1, 1)));
            posicion   = posicion - 1;
            totaltotal = totaltotal + total;
            por        = por + 1;
        }

        valor = totaltotal % 11;
        guion = Convert.ToInt32(Math.Floor((double)(11 - valor)));
        if (guion == Simulate.Val(txt_dv.Text.Substring(0, 1)) || guion == 10 && (txt_dv.Text.Substring(0, 1)) == "K" || guion == 11 && (txt_dv.Text.Substring(0, 1)) == "0" || guion == 10 && (txt_dv.Text.Substring(0, 1)) == "K")
        {
            verdad          = true;
            tempformato_rut = verdad;
            //If MsgBox("Rut valido ¿Desea Ingresar otro?", vbQuestion + vbYesNo, "Ingresar Otro") = vbYes Then
            //    txt_rut.Text = ""
            //    txt_dv.Text = ""

            //Else

            //End If
        }
        else
        {
            //MsgBox(" El R.U.T. ingresado NO es Valido", vbCritical, "Error.....")
            verdad          = false;
            tempformato_rut = verdad;
            //Response.Write("<script>")
            //Response.Write("alert('El formato del RUT es incorrecto!');")
            //Response.Write("</script>")
            //txt_rut.Text = ""
            txt_rut.Focus();
        }

        return(tempformato_rut);
    }