Пример #1
0
 public CellularNoise(int size, NeighbourhoodType type, int iterations, int neighborhoodSize, float limit, float variance, float decay) : base(size) {
     this.neighbourhoodType = type;
     this.iterations = iterations;
     this.neighbourhoodSize = neighborhoodSize;
     this.limit = limit;
     this.variance = variance;
     this.decay = decay;
 }
Пример #2
0
 public MainDrawing(MatrixType matrix,               //= MatrixType.RANDOM,
                    NeighbourhoodType neighbourhood, //= NeighbourhoodType.CONWAY,
                    MeshType mesh,                   //= MeshType.SQUARE,
                    List <int> borns,                //= {2, 3},
                    List <int> survives,             //= {2},
                    bool ageT                        //= false*/
                    )
 {
     this.matrix        = matrix;
     this.neighbourhood = neighbourhood;
     this.mesh          = mesh;
     this.borns         = borns;
     this.survives      = survives;
     this.ageT          = ageT;
 }
Пример #3
0
    private void SetupParameters()
    {
        CASettings settings = UICASettings.instance.GetSettings();

        seed          = settings.seed;
        useRandomSeed = settings.useRandomSeed;

        columns          = settings.levelWidth;
        rows             = settings.levelHeight;
        wallsFillPercent = settings.wallFill;

        smoothingIterations = settings.iterations1;
        neighbourhoodType   = settings.ruleset1.neighbourhoodType;
        surviveMin          = settings.ruleset1.survMin;
        surviveMax          = settings.ruleset1.survMax;
        newMin = settings.ruleset1.newMin;
        newMax = settings.ruleset1.newMax;

        hybridMode = settings.enableSecondRuleset;
        smoothingIterationsHybrid = settings.iterations1;
        neighbourhoodTypeHybrid   = settings.ruleset2.neighbourhoodType;
        surviveMinHybrid          = settings.ruleset2.survMin;
        surviveMaxHybrid          = settings.ruleset2.survMax;
        newMinHybrid = settings.ruleset2.newMin;
        newMaxHybrid = settings.ruleset2.newMax;

        roomThreshold      = settings.minRoomSize;
        roomUpperThreshold = settings.maxRoomSize;
        wallThreshold      = settings.minWallSize;
        wallUpperThreshold = settings.maxWallSize;

        connectRooms = settings.enableConnections;
        if (settings.useDirectConnections)
        {
            connectionType = ConnectionType.direct;
        }
        else
        {
            connectionType = ConnectionType.straight;
        }
        connectionUpperThreshold = settings.maxLeavingConnections;
        connectionSizeFactor     = settings.connectionSizeFactor;
        maxCorridorLengthX       = settings.maxConnectionLengthX;
        maxCorridorLengthY       = settings.maxConnectionLengthY;
    }
Пример #4
0
        public Lattice(int height, int width, NeighbourhoodType neighbourhoodType, GameSymmetric game, Reselector reselector)
        {
            this.Height = height;
            this.Width  = width;

            switch (neighbourhoodType)
            {
            case NeighbourhoodType.Moore: this.NeighbourDeterminer = new NeighbourDeterminerMoore(this); break;

            case NeighbourhoodType.VonNeumann: this.NeighbourDeterminer = new NeighbourDeterminerVonNeumann(this); break;
            }

            this.Game = game;

            switch (reselector)
            {
            case Reselector.Max: ActionReselector = new ActionReselectorMax(); break;

            case Reselector.Replicator4: ActionReselector = new ActionReselectorReplicator(Game.maxPayoff, Game.minPayoff, 4.0); break;

            case Reselector.Replicator8: ActionReselector = new ActionReselectorReplicator(Game.maxPayoff, Game.minPayoff, 8.0); break;

            case Reselector.Custom: ActionReselector = new ActionReselectorCustom(); break;
            }

            player = new Player[height, width];

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    this.player[i, j] = new Player();
                }
            }

            recalculateRatios();
        }
Пример #5
0
        public Scope Grow(Scope previousStructure, NeighbourhoodType neighbourhoodType, int?growthProbability, List <int> remainingIds = null)
        {
            var currentStructure = new Scope(previousStructure.Width, previousStructure.Height);

            StructureHelpers.AddBlackBorder(currentStructure);

            var          isFull           = true;
            var          isGrowthExtended = neighbourhoodType == NeighbourhoodType.ExtendedMoore ? true : false;
            List <Grain> neighbourhood    = new List <Grain>();

            for (int i = 1; i < previousStructure.Width - 1; i++)
            {
                for (int j = 1; j < previousStructure.Height - 1; j++)
                {
                    if (previousStructure.StructureArray[i, j].Id != 0)
                    {
                        currentStructure.StructureArray[i, j] = previousStructure.StructureArray[i, j];
                    }
                    else if (previousStructure.StructureArray[i, j].Id == 0)
                    {
                        if (!isGrowthExtended)
                        {
                            switch (neighbourhoodType)
                            {
                            case NeighbourhoodType.Moore:
                                neighbourhood = TakeMooreNeighbourhood(i, j, previousStructure.StructureArray);
                                break;

                            case NeighbourhoodType.Neumann:
                                neighbourhood = TakeNeumannNeighbourhood(i, j, previousStructure.StructureArray);
                                break;
                            }

                            IEnumerable <IGrouping <int, Grain> > groups = null;
                            if (remainingIds != null && remainingIds.Count() > 0)
                            {
                                groups = neighbourhood
                                         .Where(g => (!StructureHelpers.IsIdSpecial(g.Id)) && !remainingIds.Any(id => id.Equals(g.Id)))
                                         .GroupBy(g => g.Id);
                            }
                            else
                            {
                                groups = neighbourhood
                                         .Where(g => (!StructureHelpers.IsIdSpecial(g.Id))).GroupBy(g => g.Id);
                            }

                            if (groups.Any())
                            {
                                var dictionary = new Dictionary <Grain, int>();
                                foreach (var group in groups)
                                {
                                    var number = group.Key;
                                    var total  = group.Count();
                                    dictionary.Add(group.FirstOrDefault(), total);
                                }
                                var orderedNeighbourhood = dictionary.OrderByDescending(x => x.Value);
                                currentStructure.StructureArray[i, j] = orderedNeighbourhood.First().Key;
                            }
                            else
                            {
                                currentStructure.StructureArray[i, j] = new Grain()
                                {
                                    Id    = 0,
                                    Color = Color.White
                                };
                            }
                        }
                        else
                        {
                            var grainGrowth = false;
                            var dictionary  = new Dictionary <Grain, int>();
                            // rule 1
                            neighbourhood = TakeMooreNeighbourhood(i, j, previousStructure.StructureArray);
                            IEnumerable <IGrouping <int, Grain> > groups = null;
                            if (remainingIds != null && remainingIds.Count() > 0)
                            {
                                groups = neighbourhood
                                         .Where(g => (!StructureHelpers.IsIdSpecial(g.Id)) && !remainingIds.Any(id => id.Equals(g.Id)))
                                         .GroupBy(g => g.Id);
                            }
                            else
                            {
                                groups = neighbourhood
                                         .Where(g => (!StructureHelpers.IsIdSpecial(g.Id))).GroupBy(g => g.Id);
                            }
                            if (groups.Any())
                            {
                                foreach (var group in groups)
                                {
                                    var number = group.Key;
                                    var total  = group.Count();
                                    dictionary.Add(group.FirstOrDefault(), total);
                                }
                                var orderedNeighbourhood = dictionary.OrderByDescending(x => x.Value);
                                if (orderedNeighbourhood.First().Value >= 5)
                                {
                                    currentStructure.StructureArray[i, j] = orderedNeighbourhood.First().Key;
                                    grainGrowth = true;
                                }
                                else
                                {
                                    // rule 2
                                    neighbourhood = TakeNearestMooreNeighbourhood(i, j, previousStructure.StructureArray);
                                    if (remainingIds != null && remainingIds.Count() > 0)
                                    {
                                        groups = neighbourhood
                                                 .Where(g => (!StructureHelpers.IsIdSpecial(g.Id)) && !remainingIds.Any(id => id.Equals(g.Id)))
                                                 .GroupBy(g => g.Id);
                                    }
                                    else
                                    {
                                        groups = neighbourhood
                                                 .Where(g => (!StructureHelpers.IsIdSpecial(g.Id))).GroupBy(g => g.Id);
                                    }
                                    if (groups.Any())
                                    {
                                        orderedNeighbourhood = dictionary.OrderByDescending(x => x.Value);
                                        if (orderedNeighbourhood.First().Value >= 3)
                                        {
                                            currentStructure.StructureArray[i, j] = orderedNeighbourhood.First().Key;
                                            grainGrowth = true;
                                        }
                                    }
                                    if (!grainGrowth)
                                    {
                                        // rule 3
                                        neighbourhood = TakeFurtherMooreNeighbourhood(i, j, previousStructure.StructureArray);
                                        if (remainingIds != null && remainingIds.Count() > 0)
                                        {
                                            groups = neighbourhood
                                                     .Where(g => (!StructureHelpers.IsIdSpecial(g.Id)) && !remainingIds.Any(id => id.Equals(g.Id)))
                                                     .GroupBy(g => g.Id);
                                        }
                                        else
                                        {
                                            groups = neighbourhood
                                                     .Where(g => (!StructureHelpers.IsIdSpecial(g.Id))).GroupBy(g => g.Id);
                                        }
                                        if (groups.Any())
                                        {
                                            orderedNeighbourhood = dictionary.OrderByDescending(x => x.Value);
                                            if (orderedNeighbourhood.First().Value >= 3)
                                            {
                                                currentStructure.StructureArray[i, j] = orderedNeighbourhood.First().Key;
                                                grainGrowth = true;
                                            }
                                        }
                                    }
                                    if (!grainGrowth)
                                    {
                                        // rule 4 - Moore with probability
                                        neighbourhood = TakeMooreNeighbourhood(i, j, previousStructure.StructureArray);
                                        if (remainingIds != null && remainingIds.Count() > 0)
                                        {
                                            groups = neighbourhood
                                                     .Where(g => (!StructureHelpers.IsIdSpecial(g.Id)) && !remainingIds.Any(id => id.Equals(g.Id)))
                                                     .GroupBy(g => g.Id);
                                        }
                                        else
                                        {
                                            groups = neighbourhood
                                                     .Where(g => (!StructureHelpers.IsIdSpecial(g.Id))).GroupBy(g => g.Id);
                                        }
                                        var randomProbability = random.Next(0, 100);
                                        if (groups.Any() && (randomProbability <= growthProbability))
                                        {
                                            orderedNeighbourhood = dictionary.OrderByDescending(x => x.Value);
                                            currentStructure.StructureArray[i, j] = orderedNeighbourhood.First().Key;
                                            grainGrowth = true;
                                        }
                                    }
                                }
                            }
                            if (!grainGrowth)
                            {
                                // no grain yet
                                currentStructure.StructureArray[i, j] = new Grain()
                                {
                                    Id    = 0,
                                    Color = Color.White
                                };
                            }
                        }
                    }

                    if (currentStructure.StructureArray[i, j].Id == 0)
                    {
                        isFull = false;
                    }
                }
            }

            currentStructure.IsFull = isFull;

            StructureHelpers.UpdateBitmap(currentStructure);

            return(currentStructure);
        }
Пример #6
0
 public Address(CityType city, NeighbourhoodType neighbourhood)
 {
     this.City          = city;
     this.Neighbourhood = neighbourhood;
 }
Пример #7
0
    void OnChanged(object sender, EventArgs e)
    {
        CheckBox clickedButton = sender as CheckBox;

        if (clickedButton == null) // just to be on the safe side
        {
            return;
        }

        //Cancel closes the window
        if (cancel.Checked)
        {
            Close();
        }
        //OK sends the information
        else if (ok.Checked)
        {
            //Sending information to the next form,
            //that saves and gives away it.
            MatrixType        matrix        = MatrixType.RANDOM;
            NeighbourhoodType neighbourhood = NeighbourhoodType.CONWAY;

            if (pointRb.Checked)
            {
                matrix = MatrixType.ONE_POINT;
            }
            else if (randomRb.Checked)
            {
                matrix = MatrixType.RANDOM;
            }
            if (ulamRb.Checked)
            {
                neighbourhood = NeighbourhoodType.ULAM;
            }
            else if (conwayRb.Checked)
            {
                neighbourhood = NeighbourhoodType.CONWAY;
            }
            else if (knightRb.Checked)
            {
                neighbourhood = NeighbourhoodType.KNIGHT;
            }
            else if (greatConwayRb.Checked)
            {
                neighbourhood = NeighbourhoodType.GREAT_CONWAY;
            }
            else if (obliqueRb.Checked)
            {
                neighbourhood = NeighbourhoodType.OBLIQUE;
            }

            if (mesh == MeshType.SQUARE)
            {
                cancel.BackColor = Color.Red;
            }
            cancel.Show();
            cancel.Visible = true;
            //Constructs the window for RuleSettings
            RuleSettings rules = new RuleSettings(matrix, neighbourhood, mesh);
            rules.ShowDialog();
            this.Visible = false;
            this.Hide();
            this.Dispose();
        }
    }
        /// <summary>
        /// Checkt de naastgelegen posities om de afstanden te bepalen.
        /// Heeft een neighbourhoodtype nodig. Moore of Neumann neighbourhood.
        /// </summary>
        List<AstarObject> GetNeighbours(AstarObject A, ref AstarObject[,] Set, NeighbourhoodType NType, int MapsizeX, int MapsizeY)
        {
            switch (NType)
            {
                case NeighbourhoodType.Moore:
                    List<AstarObject> Neighbours = new List<AstarObject>();
                    for (int x = -1; x <= 1; x++)
                    {
                        for (int y = -1; y <= 1; y++)
                        {
                            if (x == 0 && y == 0)
                                continue;

                            int CheckX = A.x + x;
                            int CheckY = A.y + y;

                            if (CheckX >= 0 && CheckX < MapsizeX && CheckY >= 0 && CheckY < MapsizeY)
                            {
                                Neighbours.Add(Set[CheckX, CheckY]);
                            }
                        }
                    }
                    return Neighbours;
                case NeighbourhoodType.Neumann:
                    if (NType == NeighbourhoodType.Neumann)
                    {
                        List<AstarObject> Neighbours2 = new List<AstarObject>();
                        int CheckX = A.x + 1;
                        int CheckY = A.y;
                        if (CheckX >= 0 && CheckX < MapsizeX && CheckY >= 0 && CheckY < MapsizeY)
                        {
                            Neighbours2.Add(Set[CheckX, CheckY]);
                        }
                        CheckX = A.x - 1;
                        if (CheckX >= 0 && CheckX < MapsizeX && CheckY >= 0 && CheckY < MapsizeY)
                        {
                            Neighbours2.Add(Set[CheckX, CheckY]);
                        }
                        CheckX = A.x;
                        CheckY = A.y - 1;
                        if (CheckX >= 0 && CheckX < MapsizeX && CheckY >= 0 && CheckY < MapsizeY)
                        {
                            Neighbours2.Add(Set[CheckX, CheckY]);
                        }
                        CheckX = A.x;
                        CheckY = A.y + 1;
                        if (CheckX >= 0 && CheckX < MapsizeX && CheckY >= 0 && CheckY < MapsizeY)
                        {
                            Neighbours2.Add(Set[CheckX, CheckY]);
                        }
                        return Neighbours2;
                    }
                    break;
                default:
                    return null;
            }
            return null;
        }
Пример #9
0
    public RuleSettings(MatrixType matrix = MatrixType.RANDOM,
                        NeighbourhoodType neighbourhood = NeighbourhoodType.CONWAY,
                        MeshType mesh = MeshType.SQUARE)
    {
        //Saves information for MainDrawing
        this.matrix        = matrix;
        this.neighbourhood = neighbourhood;
        this.mesh          = mesh;

        Text  = "Életjáték él-hal szabályainak beállításai";
        sizeX = 700;
        sizeY = 340;
        Size  = new Size(sizeX, sizeY);

        cancel            = new System.Windows.Forms.CheckBox();
        cancel.Appearance = System.Windows.Forms.Appearance.Button;
        cancel.Text       = "Mégsem";
        cancel.Parent     = this;
        cancel.Location   = new Point(560, 150);
        cancel.BackColor  = Color.Coral;
        cancel.Show();
        cancel.Visible = true;
        Controls.Add(cancel);

        ok            = new System.Windows.Forms.CheckBox();
        ok.Appearance = System.Windows.Forms.Appearance.Button;
        ok.Text       = "OK";
        ok.Parent     = this;
        ok.Location   = new Point(560, 240);
        ok.BackColor  = Color.Coral;
        ok.Show();
        ok.Visible = true;
        Controls.Add(ok);

        //Labelse for panels
        string birthLabelText   = "A születő sejtek szomszédai";
        string surviveLabelText = "A túlélő sejtek szomszédai";


        Label birth = new Label();

        birth.Parent    = this;
        birth.Text      = birthLabelText;
        birth.Location  = new Point(30, 30);
        birth.BackColor = Color.Coral;

        Label survive = new Label();

        survive.Parent    = this;
        survive.Text      = surviveLabelText;
        survive.Location  = new Point(270, 30);
        survive.BackColor = Color.Coral;

        birth1           = new CheckBox();
        birth1.Parent    = this;
        birth1.Location  = new Point(30, 90);
        birth1.Text      = "1";
        birth1.Checked   = false;
        birth1.BackColor = Color.Coral;

        birth2           = new CheckBox();
        birth2.Parent    = this;
        birth2.Location  = new Point(30, 120);
        birth2.Text      = "2";
        birth2.Checked   = false;
        birth2.BackColor = Color.Coral;

        birth3           = new CheckBox();
        birth3.Parent    = this;
        birth3.Location  = new Point(30, 150);
        birth3.Text      = "3";
        birth3.Checked   = false;
        birth3.BackColor = Color.Coral;

        birth4           = new CheckBox();
        birth4.Parent    = this;
        birth4.Location  = new Point(30, 180);
        birth4.Text      = "4";
        birth4.Checked   = false;
        birth4.BackColor = Color.Coral;

        birth5           = new CheckBox();
        birth5.Parent    = this;
        birth5.Location  = new Point(30, 210);
        birth5.Text      = "5";
        birth5.Checked   = false;
        birth5.BackColor = Color.Coral;

        birth6           = new CheckBox();
        birth6.Parent    = this;
        birth6.Location  = new Point(30, 240);
        birth6.Text      = "6";
        birth6.Checked   = false;
        birth6.BackColor = Color.Coral;

        birth7           = new CheckBox();
        birth7.Parent    = this;
        birth7.Location  = new Point(150, 90);
        birth7.Text      = "7";
        birth7.Checked   = false;
        birth7.BackColor = Color.Coral;

        birth8           = new CheckBox();
        birth8.Parent    = this;
        birth8.Location  = new Point(150, 120);
        birth8.Text      = "8";
        birth8.Checked   = false;
        birth8.BackColor = Color.Coral;

        birth9           = new CheckBox();
        birth9.Parent    = this;
        birth9.Location  = new Point(150, 150);
        birth9.Text      = "9";
        birth9.Checked   = false;
        birth9.BackColor = Color.Coral;

        birth10           = new CheckBox();
        birth10.Parent    = this;
        birth10.Location  = new Point(150, 180);
        birth10.Text      = "10";
        birth10.Checked   = false;
        birth10.BackColor = Color.Coral;

        birth11           = new CheckBox();
        birth11.Parent    = this;
        birth11.Location  = new Point(150, 210);
        birth11.Text      = "11";
        birth11.Checked   = false;
        birth11.BackColor = Color.Coral;

        birth12           = new CheckBox();
        birth12.Parent    = this;
        birth12.Location  = new Point(150, 240);
        birth12.Text      = "12";
        birth12.Checked   = false;
        birth12.BackColor = Color.Coral;



        survive1           = new CheckBox();
        survive1.Parent    = this;
        survive1.Location  = new Point(270, 90);
        survive1.Text      = "1";
        survive1.Checked   = false;
        survive1.BackColor = Color.Coral;

        survive2           = new CheckBox();
        survive2.Parent    = this;
        survive2.Location  = new Point(270, 120);
        survive2.Text      = "2";
        survive2.Checked   = false;
        survive2.BackColor = Color.Coral;

        survive3           = new CheckBox();
        survive3.Parent    = this;
        survive3.Location  = new Point(270, 150);
        survive3.Text      = "3";
        survive3.Checked   = false;
        survive3.BackColor = Color.Coral;

        survive4           = new CheckBox();
        survive4.Parent    = this;
        survive4.Location  = new Point(270, 180);
        survive4.Text      = "4";
        survive4.Checked   = false;
        survive4.BackColor = Color.Coral;

        survive5           = new CheckBox();
        survive5.Parent    = this;
        survive5.Location  = new Point(270, 210);
        survive5.Text      = "5";
        survive5.Checked   = false;
        survive5.BackColor = Color.Coral;

        survive6           = new CheckBox();
        survive6.Parent    = this;
        survive6.Location  = new Point(270, 240);
        survive6.Text      = "6";
        survive6.Checked   = false;
        survive6.BackColor = Color.Coral;

        survive7           = new CheckBox();
        survive7.Parent    = this;
        survive7.Location  = new Point(390, 90);
        survive7.Text      = "7";
        survive7.Checked   = false;
        survive7.BackColor = Color.Coral;

        survive8           = new CheckBox();
        survive8.Parent    = this;
        survive8.Location  = new Point(390, 120);
        survive8.Text      = "8";
        survive8.Checked   = false;
        survive8.BackColor = Color.Coral;

        survive9           = new CheckBox();
        survive9.Parent    = this;
        survive9.Location  = new Point(390, 150);
        survive9.Text      = "9";
        survive9.Checked   = false;
        survive9.BackColor = Color.Coral;

        survive10           = new CheckBox();
        survive10.Parent    = this;
        survive10.Location  = new Point(390, 180);
        survive10.Text      = "10";
        survive10.Checked   = false;
        survive10.BackColor = Color.Coral;

        survive11           = new CheckBox();
        survive11.Parent    = this;
        survive11.Location  = new Point(390, 210);
        survive11.Text      = "11";
        survive11.Checked   = false;
        survive11.BackColor = Color.Coral;

        survive12           = new CheckBox();
        survive12.Parent    = this;
        survive12.Location  = new Point(390, 240);
        survive12.Text      = "12";
        survive12.Checked   = false;
        survive12.BackColor = Color.Coral;

        age           = new CheckBox();
        age.Parent    = this;
        age.Location  = new Point(500, 90);
        age.Text      = "Kor szerinti\nszínezés";
        age.Checked   = false;
        age.BackColor = Color.Coral;

        //Setting the EventHandlers
        cancel.CheckedChanged += new EventHandler(OnCancelChanged);
        ok.CheckedChanged     += new EventHandler(OnOkChanged);

        Paint += new PaintEventHandler(OnPaint);
        Console.WriteLine(mesh);
        CenterToScreen();
    }
Пример #10
0
    void OnChanged(object sender, EventArgs e)
    {
        CheckBox clickedButton = sender as CheckBox;

        //CheckBox clickedButton = (CheckBox)sender;
        if (clickedButton == null) // just to be on the safe side
        {
            return;
        }

        //Cancel closes the window
        if (cancel.Checked)
        {
            Close();
        }
        //OK sends the information
        else if (ok.Checked)
        {
            //Sending information to the next form,
            //that saves and gives away it.
            MatrixType        matrix        = MatrixType.RANDOM;
            NeighbourhoodType neighbourhood = NeighbourhoodType.CONWAY;
            MeshType          mesh          = MeshType.SQUARE;

            if (pointRb.Checked)
            {
                matrix = MatrixType.ONE_POINT;
            }
            else if (randomRb.Checked)
            {
                matrix = MatrixType.RANDOM;
            }
            if (ulamRb.Checked)
            {
                neighbourhood = NeighbourhoodType.ULAM;
            }
            else if (conwayRb.Checked)
            {
                neighbourhood = NeighbourhoodType.CONWAY;
            }
            else if (knightRb.Checked)
            {
                neighbourhood = NeighbourhoodType.KNIGHT;
            }
            if (squareRb.Checked)
            {
                mesh = MeshType.SQUARE;
            }
            else if (triangleRb.Checked)
            {
                mesh = MeshType.TRIANGLE;
            }
            else if (hexagonRb.Checked)
            {
                mesh = MeshType.HEXAGON;
            }

            RuleSettings rules = new RuleSettings(matrix, neighbourhood, mesh);
            rules.ShowDialog();
            this.Visible = false;
            this.Hide();
            this.Dispose();
        }


        // Ha az előbbiek felsorolási típusok lesznek, akkor itt konstruáljuk meg
        // az él-hal szabály párbeszédablakát
    }
Пример #11
0
        public NeightbourHandler produce(MeshType mesh, NeighbourhoodType neighbourhood)
        {
            NeightbourHandler nh = new QuadraticConwayNeightbourHandler();

            if (mesh == MeshType.SQUARE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new QuadraticUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.KNIGHT)
                {
                    nh = new QuadraticKnightNeightbourHandler();
                }
            }
            else if (mesh == MeshType.TRIANGLE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new TriangleUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new TriangleConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.KNIGHT)
                {
                    nh = new TriangleKnightNeightbourHandler();
                }
            }
            else if (mesh == MeshType.HEXAGON)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new HexagonUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new HexagonConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.KNIGHT)
                {
                    nh = new HexagonKnightNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON1)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon1UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new Pentagon1ObliqueNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON3)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon3UlamNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON4)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon4UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Pentagon4ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.KITE5)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Kite5UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Kite5SmallConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new Kite5ObliqueNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.GREAT_CONWAY)
                {
                    nh = new Kite5GrandConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON10)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon10UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Pentagon10ConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new Pentagon10ObliqueNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON11)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon11UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Pentagon11ConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new Pentagon11ObliqueNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON12)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon12UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Pentagon12ConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new Pentagon12ObliqueNeightbourHandler();
                }
            }
            else if (mesh == MeshType.PENTAGON14)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Pentagon14UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Pentagon14ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.RECTANGLE1)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Rectangle1UlamNeightbourHandler();
                }
            }
            else if (mesh == MeshType.RECTANGLE2)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new Rectangle2UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new Rectangle2ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.TILED_RECTANGLE1)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new TiledRectangle1UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new TiledRectangle1ConwayNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.OBLIQUE)
                {
                    nh = new TiledRectangle1ObliqueNeightbourHandler();
                }
            }
            else if (mesh == MeshType.RECTANGLE_SQUARE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new RectangleSquareUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new RectangleSquareConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.SQUARE_TRIANGLE1)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new SquareTriangle1UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new SquareTriangle1ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.SQUARE_TRIANGLE2)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new SquareTriangle2UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new SquareTriangle2ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.HEXAGON_TRIANGLE1)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new HexagonTriangleUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new HexagonTriangleConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.HEXAGON_TRIANGLE2)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new HexagonTriangle2UlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new HexagonTriangle2ConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.OCTOGON_SQUARE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new OctogonSquareUlamNeightbourHandler();
                }
            }
            else if (mesh == MeshType.DODECAGON_TRIANGLE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new DodecagonTriangleUlamNeightbourHandler();
                }
            }
            else if (mesh == MeshType.HEXAGON_SQUARE_TRIANGLE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new HexagonSquareTriangleUlamNeightbourHandler();
                }
                else if (neighbourhood == NeighbourhoodType.CONWAY)
                {
                    nh = new HexagonSquareTriangleConwayNeightbourHandler();
                }
            }
            else if (mesh == MeshType.DODECAGON_HEXAGON_SQUARE)
            {
                if (neighbourhood == NeighbourhoodType.ULAM)
                {
                    nh = new DodecagonHexagonSquareUlamNeightbourHandler();
                }
            }
            return(nh);
        }