Exemplo n.º 1
0
        static void Main(string[] args)
        {
            stateHistory.Add(new TransformState()); // Empty start state

            var port = 9999;

            server            = new TCPServer("localhost", 9999);
            server.OnOpen    += OnClientConnected;
            server.OnClose   += OnClientDisconnected;
            server.OnMessage += OnReceiveMessage;
            server.Open();

            // Wait Forever
            new ManualResetEvent(false).WaitOne();
        }
Exemplo n.º 2
0
            public void UpdateForChangedVoxel(VoxelCell changedVoxel)
            {
                SolutionState state = FirstState.GetWithChangedCell(changedVoxel);

                StateHistory.Clear();
                StateHistory.Add(state);
            }
Exemplo n.º 3
0
        private void AddState(string state)
        {
            if (this.StateHistory == null)
            {
                this.StateHistory = new List <History>();
            }

            StateHistory.Add(new History(state));
        }
Exemplo n.º 4
0
 public void AdvanceOneStep()
 {
     if (StateHistory.Count < SolverLimit && !LastState.IsEverythingSolved)
     {
         SolutionState nextState = LastState.GetNextState();
         StateHistory.Add(nextState);
         Status = GetSolverStatus();
     }
 }
Exemplo n.º 5
0
        public void NextState()
        {
            var deadCount = 0;

            var currentBoard = StateHistory.Last();

            var ghosts = GhostMovement(currentBoard.Ghosts);

            var newPlayers = new List <PacManPlayer>();

            var coins = new List <Coin>(currentBoard.Coins);

            foreach (var player in currentBoard.Players)
            {
                var newPlayer = player.Copy();

                //Check if player is alive
                if (!newPlayer.Alive)
                {
                    continue;
                }

                PlayerMovement(newPlayer);

                var coin = CheckCoin(newPlayer, coins);

                if (coin != null)
                {
                    coins.Remove(coin);
                }

                if (CheckPlayerWallCollision(newPlayer))
                {
                    newPlayer.Alive = false;
                    deadCount++;
                    continue;
                }

                if (CheckPlayerGhostCollision(newPlayer, ghosts))
                {
                    deadCount++;
                    newPlayer.Alive = false;
                }

                newPlayers.Add(newPlayer);
            }

            if (deadCount == numberPlayers)
            {
                GameEnded = true;
            }

            NewMovements.Clear();

            StateHistory.Add(new Board(currentBoard.RoundID + 1, ghosts, newPlayers, coins));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Clears the state history and adds the "uninitialized" state
        /// </summary>
        private void SetUninitializedState()
        {
            StateHistory.Clear();

            PresentableMD5State uninitializedState = new PresentableMD5State();

            uninitializedState.State = MD5StateDescription.UNINITIALIZED;
            StateHistory.Add(uninitializedState);
            CurrentState = uninitializedState;

            CurrentStateNumber = 0;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds a new state to the history and sets it as the current state
        /// </summary>
        protected void AddNewState()
        {
            if (CurrentStateNumber == -1)
            {
                CurrentState = new PresentableMD5State();
            }
            else
            {
                CurrentState = new PresentableMD5State(StateHistory[CurrentStateNumber]);
            }

            StateHistory.Add(CurrentState);
            CurrentStateNumber = StateHistory.Count - 1;
        }
        public void SetCurrentState(IState state)
        {
            if (state != null)
            {
                Definition.CheckState(state);
            }

            StateHistory.Add(CurrentStateId, state.id);
            PreviousStateId = CurrentStateId;

            CurrentState   = state;
            CurrentStateId = state.id;

            if (state.EndPoint)
            {
                Finished = true;
            }
        }
Exemplo n.º 9
0
        private void StateChanged(object sender, Events.StateChangedArgs e)
        {
            //todo: this should be pushed directly to a queue to minimize time in method. the queue can be picked up by a processor that does what this method is currently doing.
            Dispatcher.Invoke((state) =>
            {
                State = state as ITelloState;
                StateHistory.Add(state as ITelloState);
                if (StateHistory.Count > 500)
                {
                    StateHistory.RemoveAt(0);
                }
            },
                              e.State);


            var group = _repository.NewEntity <ObservationGroup>(_session);

            _repository.Insert(new StateObservation(group, e.State));
            _repository.Insert(new AirSpeedObservation(group, e.State));
            _repository.Insert(new AttitudeObservation(group, e.State));
            _repository.Insert(new BatteryObservation(group, e.State));
            _repository.Insert(new HobbsMeterObservation(group, e.State));
            _repository.Insert(new PositionObservation(group, e.State));
        }
Exemplo n.º 10
0
        public void Start()
        {
            var coinCounter = 1;

            List <ServerGhost> ghosts = new List <ServerGhost>();

            List <PacManPlayer> players = new List <PacManPlayer>();

            List <Coin> coins = new List <Coin>();

            //Inicialize Ghosts
            ghosts.Add(new ServerGhost(GhostColor.Red, new Position(180, 73), 1, new Speed(5, 0)));
            ghosts.Add(new ServerGhost(GhostColor.Yellow, new Position(221, 273), 2, new Speed(5, 0)));
            ghosts.Add(new ServerGhost(GhostColor.Pink, new Position(301, 72), 3, new Speed(5, 5)));
            //Inicialize Players
            for (var i = 1; i <= numberPlayers; i++)
            {
                players.Add(new PacManPlayer(i, new Position(8, i * 40), Movement.Direction.Stopped, 0, true));
            }
            //Inicializa 1 Column of coins
            for (var i = 1; i <= 8; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(8, i * 40)));
            }
            //Inicializa 2 Column of coins
            for (var i = 1; i <= 8; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(48, i * 40)));
            }
            //Inicializa 3 Column of coins
            for (var i = 1; i <= 5; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(88, i * 40 + 120)));
            }
            //Inicializa 4 Column of coins
            for (var i = 1; i <= 5; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(128, i * 40)));
            }
            //Inicializa 5 Column of coins
            for (var i = 1; i <= 8; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(168, i * 40)));
            }
            //Inicializa 6 Column of coins
            for (var i = 1; i <= 8; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(208, i * 40)));
            }
            //Inicializa 7 Column of coins
            for (var i = 1; i <= 5; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(248, i * 40 + 120)));
            }
            //Inicializa 8 Column of coins
            for (var i = 1; i <= 5; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(288, i * 40)));
            }
            //Inicializa 9 Column of coins
            for (var i = 1; i <= 8; i++)
            {
                coins.Add(new Coin(coinCounter++, new Position(328, i * 40)));
            }

            StateHistory.Add(new Board(0, ghosts, players, coins));
        }