Exemple #1
0
 public GenetskiAlg(List <nurikabePoint> tockeZKaterimiDelam, betterArray arr, int pop = 100, int elita = 4, int randomFolk = 1, double moznostMutacije = 0.002, double moznostKrizanja = 0.3)
 {
     this.tockeZKaterimiDelam = tockeZKaterimiDelam;
     this.arr             = arr;
     this.pop             = pop;
     this.elita           = elita;
     this.moznostMutacije = moznostMutacije;
     this.moznostKrizanja = moznostKrizanja;
     velikostEnega        = tockeZKaterimiDelam.Count;
     vhodniArrCop         = arr.arr;
     this.randomFolk      = randomFolk;
 }
Exemple #2
0
        public Nurikabe(string strPath)
        {
            //nalozimo datoteko in inicializiramo zadevo
            this.strPath = strPath;
            var text = File.ReadAllLines(strPath);

            var first = true;

            foreach (var str in text)
            {
                if (first)
                {
                    first = false;
                    var words = str.Split(' ');
                    var xy    = Array.ConvertAll(words, int.Parse);
                    xSize       = xy[0];
                    ySize       = xy[1];
                    nurikabeArr = new betterArray(xSize, ySize);
                }
                else
                {
                    if (str == "")
                    {
                        continue;
                    }
                    var words = str.Split(' ').ToList();
                    words.Remove("");
                    var xy = Array.ConvertAll(words.ToArray(), int.Parse);
                    var p  = new nurikabePoint(xy[0], xy[1], xy[2]);
                    if (xy[2] != 1)
                    {
                        var wh = new Island(xy[0], xy[1], xy[2]);
                        islandList.Add(wh);
                    }

                    nurikabeArrIndx.Add(p);
                    nurikabeArr[xy[0], xy[1]] = xy[2];
                }
            }
        }
Exemple #3
0
        public bool semJazResitev(betterArray ba)
        {
            (var steviloCrnih, var steviloBelih, var steviloPrevelikihBelih, var steviloStikajocihBelih,
             var kolicinaPrevecPreveliko) = dobiSteviloOtokov(this.arr);
            if (steviloCrnih != 1)
            {
                return(false);
            }
            if (steviloBelih != ba.beliIsland.Count)
            {
                return(false);
            }
            if (steviloPrevelikihBelih != 0)
            {
                return(false);
            }
            if (steviloStikajocihBelih != 0)
            {
                return(false);
            }

            return(true);
        }