示例#1
0
        public void run()
        {
            /// TRAINING DATASET
            for (int i = 0; i < 10; i++)
            {
                MiniPixelJSON pd = PixelDataGenerator();
                PixelConsolDrawing(pd);

                string MiniPixelLabel = Console.ReadLine();
                pd.PixelLabel = MiniPixelLabel;
                PutData(JsonConvert.SerializeObject(pd));
            }
            ///

            /// AI proposals
            for (int i = 0; i < 10; i++)
            {
                MiniPixelJSON pd     = PixelDataGenerator();
                string        result = AI(pd);
                PixelConsolDrawing(pd);
                Console.WriteLine(result);
                Console.Read();
            }
            ///

            Console.Read();
        }
示例#2
0
        private MiniPixelJSON PixelDataGenerator()
        {
            int[,] PixelDrawXY = new int[4, 4];

            Random r = new Random();

            int z = r.Next(4);
            int d;
            int sd = 0;

            for (int y = 0; y <= 3; y++)
            {
                for (int x = 0; x <= 3; x++)
                {
                    if (x == z)
                    {
                        PixelDrawXY[x, y] = 1;
                    }
                    else
                    {
                        PixelDrawXY[x, y] = 0;
                    }
                }

                d = r.Next(-1, 2);
                if (y != 0)
                {
                    if (d == 1 && sd == -1)
                    {
                        d = r.Next(-1, 1);
                    }
                    else if (d == -1 && sd == 1)
                    {
                        d = r.Next(2);
                    }
                }
                sd = d;
                z  = z + d;

                if (z == -1)
                {
                    z++;
                }
                if (z == 4)
                {
                    z--;
                }
            }

            MiniPixelJSON p = new MiniPixelJSON();

            p.PixelID     = HexGen();
            p.PixelLabel  = "-";
            p.PixelDataXY = PixelDrawXY;

            return(p);
        }
示例#3
0
        private string AI(MiniPixelJSON data)
        {
            double s = 0;
            double c = 0;

            List <MiniPixelJSON_DB> PixelList = GetData();

            foreach (MiniPixelJSON_DB Pixeldb in PixelList)
            {
                MiniPixelJSON Pixel = JsonConvert.DeserializeObject <MiniPixelJSON>(Pixeldb.PixelJSON);

                int xy = 4;

                int compare = 0;

                for (int x = 0; x < xy; x++)
                {
                    for (int y = 0; y < xy; y++)
                    {
                        if (Pixel.PixelDataXY[x, y] == 1)
                        {
                            if (data.PixelDataXY[x, y] == Pixel.PixelDataXY[x, y])
                            {
                                compare++;
                            }
                        }
                    }
                }

                double comparedpercent = (int)Math.Round((double)(100 * compare) / 4);

                //if (comparedpercent == 100)
                //{
                //    string result = "";
                //    if (Pixel.PixelLabel == "s") { result = "S=100% / C=0%"; }
                //    if (Pixel.PixelLabel == "c") { result = "S=0% / C=100%"; }

                //    return result;
                //}

                if (Pixel.PixelLabel == "s")
                {
                    s = s / comparedpercent;
                }
                if (Pixel.PixelLabel == "c")
                {
                    c = c / comparedpercent;
                }
            }

            //s = s / PixelList.Count;
            //c = c / PixelList.Count;

            return("S=" + s.ToString() + "% / C=" + c.ToString() + "%");
        }
示例#4
0
        private void PixelConsolDrawing(MiniPixelJSON data)
        {
            Console.WriteLine("──────────────────────────────");
            Console.WriteLine();
            Console.WriteLine("PixelID:    " + data.PixelID);
            Console.WriteLine("PixelLabel: " + data.PixelLabel);
            Console.WriteLine();


            Console.Write("┌");
            for (int i = 0; i < 4; i++)
            {
                Console.Write("─");
            }
            Console.WriteLine("┐");

            for (int y = 0; y <= 3; y++)
            {
                Console.Write("│");
                for (int x = 0; x <= 3; x++)
                {
                    if (data.PixelDataXY[y, x] == 0)
                    {
                        Console.Write(" ");
                    }
                    else if (data.PixelDataXY[y, x] == 1)
                    {
                        Console.Write("█");
                    }
                }
                Console.WriteLine("│");
            }
            Console.Write("└");
            for (int i = 0; i < 4; i++)
            {
                Console.Write("─");
            }
            Console.WriteLine("┘");
            Console.WriteLine();
        }