Beispiel #1
0
 public Controller()
 {
     this.players = new List <IPlayer>();
     this.players.Add(new MainPlayer());
     this.guns          = new Queue <IGun>();
     this.neighbourhood = new GangNeighbourhood();
 }
 public Controller()
 {
     player            = new MainPlayer();
     players           = new List <IPlayer>();
     this.queueOfGuns  = new Queue <IGun>();
     gangNeighbourhood = new GangNeighbourhood();
 }
 public Controller()
 {
     this.mainPlayer    = new MainPlayer();
     this.civilPlayers  = new List <IPlayer>();
     this.guns          = new List <IGun>();
     this.neighbourhood = new Neighbourhood();
 }
Beispiel #4
0
 public Controller()
 {
     this.civilPlayers      = new List <IPlayer>();
     this.mainPlayer        = new MainPlayer();
     this.gunRepository     = new GunRepository();
     this.gangNeighbourhood = new GangNeighbourhood();
 }
Beispiel #5
0
 public Controller()
 {
     main         = new MainPlayer();
     civils       = new List <IPlayer>();
     guns         = new List <IGun>();
     neighourhood = new Neighbourhood();
 }
 public Controller()
 {
     mainPlayer        = new MainPlayer();
     civilPlayers      = new List <IPlayer>();
     guns              = new Queue <IGun>();
     gangNeighbourhood = new GangNeighbourhood();
 }
Beispiel #7
0
 public Controller()
 {
     this.mainPlayer    = new MainPlayer();
     this.players       = new List <IPlayer>();
     this.guns          = new Queue <IGun>();
     this.gunFactory    = new GunFactory();
     this.neighbourhood = new GangNeighbourhood();
 }
        public Controller(IPlayer mainPlayer, INeighbourhood neighbourhood)
        {
            this.mainPlayer    = mainPlayer;
            this.gunsQueue     = new Queue <IGun>();
            this.neighbourhood = neighbourhood;

            this.civilPlayers = new List <IPlayer>();
        }
 public LocalSearch(IInitalise initalise, INeighbourhood neighbourhood, IStepFunction step, TerminateStrategy terminate, string name = "Local Search")
 {
     this.initalisationStrategy = initalise;
     this.neighbourhood         = neighbourhood;
     this.step = step;
     this.terminateStrategy = terminate;
     this.name = name;
 }
        public Controller()
        {
            IPlayer mainPlayer = new MainPlayer();

            this.players        = new List <IPlayer>();
            this.gunsRepository = new GunRepository();
            this.neighbourhood  = new GangNeighbourhood();
            this.players.Add(mainPlayer);
        }
        /// <summary>
        /// Initializes a new <see cref="CAEnvironment"/> object.
        /// </summary>
        /// <param name="size">The size of the grid.</param>
        /// <param name="endless">Is the grid endless.</param>
        /// <param name="ruleName">The name of the rule, which will operate.</param>
        /// <param name="neighbourhoodName">The name of the neighbourhood for all <see cref="Cell"/> objects.</param>
        /// <param name="ruleArgs">If needed - arguments for initializing a <see cref="IRule"/> object.</param>
        public CAEnvironment(Size size, bool endless, string ruleName, string neighbourhoodName, object[] ruleArgs)
        {
            Size = size;
            Endless = endless;

            _rule = RuleFactory.Create(ruleName, ruleArgs);
            _neighbourhood = NeighbourhoodFactory.Create(neighbourhoodName);
            States = new CellState();
            StatesNew = new CellState();
        }
Beispiel #12
0
        public Controller(
            MainPlayer mainPlayer,
            INeighbourhood neighbourhood,
            IGunFactory gunFactory,
            ICivilPlayerFactory civilPlayerFactory)
        {
            this.mainPlayer         = mainPlayer;
            this.neighbourhood      = neighbourhood;
            this.gunFactory         = gunFactory;
            this.civilPlayerFactory = civilPlayerFactory;

            this.civilPlayers = new List <IPlayer>();
            this.guns         = new Queue <IGun>();
        }
Beispiel #13
0
        public SPD(Func <Coord, PointMatrix> mFunc, INeighbourhood neighbourhood, int[,] initialConfiguration, IDictionary <int, IStrategy> possibleStrategies, int stepNum, int threadNum = 1, OptimizationKind optimizationKind = OptimizationKind.Absolute)
        {
            if (threadNum <= 0)
            {
                throw new ArgumentException();
            }
            OptimizationKind  = optimizationKind;
            Width             = initialConfiguration.GetLength(0);
            Height            = initialConfiguration.GetLength(1);
            Matrix            = mFunc;
            ThreadCount       = threadNum;
            StepsPerIteration = stepNum;
            CurrentIteration  = 0;
            var concernes = new List <Coord> [ThreadCount];

            for (var i = 0; i < ThreadCount; i++)
            {
                concernes[i] = new List <Coord>();
            }

            var index = 0;

            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    var key = new Coord(x, y);
                    _strategies.AddOrUpdate(key, possibleStrategies[initialConfiguration[x, y]].GetCopy(),
                                            (c, s) => possibleStrategies[initialConfiguration[x, y]].GetCopy());
                    var neigh = neighbourhood.GetHalfNeighbours(key).ToArray();//GetNeighbours(key).ToArray();
                    _neighbours.AddOrUpdate(key, neigh.ToArray(),
                                            (a, b) => b.Union(neigh).ToArray());
                    var neigh2 = neighbourhood.GetNeighbours(key).ToArray();
                    _fullNeighbours.AddOrUpdate(key, neigh2, (a, b) => b.Union(neigh2).ToArray());
                    concernes[index].Add(key);
                    index = (index + 1) % ThreadCount;
                }
            }
            for (var i = 0; i < ThreadCount; i++)
            {
                _threadConcernes.AddOrUpdate(i, concernes[i].ToArray(), (a, b) => concernes[i].ToArray());
            }

            ProcessHistory(initialConfiguration);
        }
Beispiel #14
0
 public SPD(PointMatrix m, INeighbourhood neighbourhood, int[,] initialConfiguration, IDictionary <int, IStrategy> possibleStrategies, int stepNum, int threadNum = 1, OptimizationKind optimizationKind = OptimizationKind.Absolute)
     : this(
         coord => m, neighbourhood, initialConfiguration, possibleStrategies, stepNum, threadNum,
         optimizationKind)
 {
 }
Beispiel #15
0
        /// <summary>
        /// Konstruktor okna realizującego symulacje
        /// </summary>
        /// <param name="PayValues">Tablica zawierająca informacje wyekstrahowane z macierzy wypłat </param>
        /// <param name="strategies">Tablica zawierająca początkowe strategie w automacie</param>
        /// <param name="torus">Zmienna informująca czy obliczenia automatu realizowane są na torusie</param>
        /// <param name="vonneumann">Zmienna informująca czy obliczenia automatu realizowane są z sąsiedztwem Von Neumanna</param>
        public SPDView(PointMatrixPick Matrix, int[,] strategies, int _neighboursCount, INeighbourhood _neighbourhood)
        {
            _tooltip            = -1;
            _strategyCount      = 2 + _neighboursCount;
            _sumPointsHistory   = new List <double[]>();
            _sumPoints          = new double[_strategyCount];
            DataContext         = this;
            pointMatrixPick     = Matrix;
            float[,] fakePoints = new float[strategies.GetLength(0), strategies.GetLength(1)];

            AddHistory(strategies, fakePoints);

            for (int i = 0; i < _sumPoints.Length; i++)
            {
                _sumPoints[i] = 0;
            }

            _strategies   = strategies;
            neighbourhood = _neighbourhood;
#if DEBUG
            var threadNum = 1; //debugging purposes DON'T remove
#else
            var threadNum = 16;
#endif
            _strategyDictionary = GenerateIntegerStrategies(_strategyCount);

            _spd =

                new SPD.Engine.SPD(
                    Matrix.Function,
                    neighbourhood, strategies,
                    _strategyDictionary, 10, threadNum, Matrix.ModifiedPointCounting ? OptimizationKind.Relative : OptimizationKind.Absolute);

            Speed             = 1;
            PointsModel       = new PlotModel();
            CountModel        = new PlotModel();
            ChangeModel       = new PlotModel();
            SumModel          = new PlotModel();
            PointsModel.Title = "Średnie wartości punktowe";
            CountModel.Title  = "Liczebność strategii";
            ChangeModel.Title = "Niestabilność układu";
            SumModel.Title    = "Punkty dla strategii zagregowane";
            _iterations       = new List <Tuple <int, string> >();

            PointsModel.Axes.Add(new CategoryAxis {
                ItemsSource = _iterations, LabelField = "Item2"
            });

            CountModel.Axes.Add(new CategoryAxis {
                ItemsSource = _iterations, LabelField = "Item2"
            });
            PointsModel.Axes.Add(new LinearAxis {
                MinimumPadding = 0, AbsoluteMinimum = 0
            });
            CountModel.Axes.Add(new LinearAxis {
                MinimumPadding = 0, AbsoluteMinimum = 0
            });

            PointsModel.Series.Add(new ColumnSeries {
                ColumnWidth = 10, IsStacked = true
            });
            CountModel.Series.Add(new ColumnSeries {
                ColumnWidth = 10, IsStacked = true
            });

            ChangeModel.Axes.Add(new CategoryAxis {
                ItemsSource = _iterations, LabelField = "Item2"
            });
            ChangeModel.Axes.Add(new LinearAxis {
                MinimumPadding = 0, AbsoluteMinimum = 0
            });
            ChangeModel.Series.Add(new ColumnSeries {
                ColumnWidth = 10, IsStacked = true
            });
            SumModel.Axes.Add(new CategoryAxis {
                ItemsSource = _iterations, LabelField = "Item2"
            });
            SumModel.Axes.Add(new LinearAxis {
                MinimumPadding = 0, AbsoluteMinimum = 0
            });
            SumModel.Series.Add(new ColumnSeries {
                ColumnWidth = 10, IsStacked = true
            });


            UpdateModels();

            InitializeComponent();
            Iteration = 0;

            var D = SPDAssets.GenerateLegend(Legenda.Height, _strategyCount);


            _width  = _strategies.GetLength(0);
            _height = _strategies.GetLength(1);
            var image2 = new Image
            {
                Source = GenerateImage(_spd, 0, 0, _strategies.GetLength(0), _strategies.GetLength(1))
            };


            Canvas.SetTop(D, 0);
            Canvas.SetLeft(D, 0);
            Legenda.Children.Add(D);
            Canvas.Children.Add(image2);
        }
Beispiel #16
0
        /// <summary>
        /// Konstruktor okna realizującego symulacje
        /// </summary>
        /// <param name="PayValues">Tablica zawierająca informacje wyekstrahowane z macierzy wypłat </param>
        /// <param name="strategies">Tablica zawierająca początkowe strategie w automacie</param>
        /// <param name="torus">Zmienna informująca czy obliczenia automatu realizowane są na torusie</param>
        /// <param name="vonneumann">Zmienna informująca czy obliczenia automatu realizowane są z sąsiedztwem Von Neumanna</param>
        public SPDView(PointMatrixPick Matrix, int[,] strategies, int _neighboursCount, INeighbourhood _neighbourhood)
        {
            _tooltip = -1;
            _strategyCount = 2 + _neighboursCount;
            _sumPointsHistory = new List<double[]>();
            _sumPoints = new double[_strategyCount];
            DataContext = this;
            pointMatrixPick = Matrix;
            float[,] fakePoints = new float[strategies.GetLength(0), strategies.GetLength(1)];

            AddHistory(strategies,fakePoints);
            
            for (int i = 0; i < _sumPoints.Length; i++) _sumPoints[i] = 0;
            
            _strategies = strategies;
            neighbourhood = _neighbourhood;
#if DEBUG
            var threadNum = 1; //debugging purposes DON'T remove
#else
            var threadNum = 16;
#endif
            _strategyDictionary = GenerateIntegerStrategies(_strategyCount);
            
            _spd =

                new SPD.Engine.SPD(
                    Matrix.Function,
                    neighbourhood, strategies,
                  _strategyDictionary, 10, threadNum, Matrix.ModifiedPointCounting ? OptimizationKind.Relative : OptimizationKind.Absolute);

            Speed = 1;
            PointsModel = new PlotModel();
            CountModel = new PlotModel();
            ChangeModel = new PlotModel();
            SumModel = new PlotModel();
            PointsModel.Title = "Średnie wartości punktowe";
            CountModel.Title = "Liczebność strategii";
            ChangeModel.Title = "Niestabilność układu";
            SumModel.Title = "Punkty dla strategii zagregowane";
            _iterations = new List<Tuple<int, string>>();

            PointsModel.Axes.Add(new CategoryAxis { ItemsSource = _iterations, LabelField = "Item2" });

            CountModel.Axes.Add(new CategoryAxis { ItemsSource = _iterations, LabelField = "Item2" });
            PointsModel.Axes.Add(new LinearAxis { MinimumPadding = 0, AbsoluteMinimum = 0 });
            CountModel.Axes.Add(new LinearAxis { MinimumPadding = 0, AbsoluteMinimum = 0 });

            PointsModel.Series.Add(new ColumnSeries { ColumnWidth = 10, IsStacked = true });
            CountModel.Series.Add(new ColumnSeries { ColumnWidth = 10, IsStacked = true });

            ChangeModel.Axes.Add(new CategoryAxis { ItemsSource = _iterations, LabelField = "Item2" });
            ChangeModel.Axes.Add(new LinearAxis { MinimumPadding = 0, AbsoluteMinimum = 0 });
            ChangeModel.Series.Add(new ColumnSeries {ColumnWidth = 10, IsStacked = true});
                 SumModel.Axes.Add(new CategoryAxis { ItemsSource = _iterations, LabelField = "Item2" });
            SumModel.Axes.Add(new LinearAxis { MinimumPadding = 0, AbsoluteMinimum = 0 });
            SumModel.Series.Add(new ColumnSeries { ColumnWidth = 10, IsStacked = true });
       

            UpdateModels();

            InitializeComponent();
            Iteration = 0;

            var D =  SPDAssets.GenerateLegend(Legenda.Height, _strategyCount);

           
            _width = _strategies.GetLength(0);
            _height = _strategies.GetLength(1);
            var image2 = new Image
            {
                Source = GenerateImage(_spd, 0, 0, _strategies.GetLength(0), _strategies.GetLength(1))

            };


            Canvas.SetTop(D, 0);
            Canvas.SetLeft(D, 0);
            Legenda.Children.Add(D);
            Canvas.Children.Add(image2);
        }