コード例 #1
0
        public void Load(GraphicsDeviceManager graphics, ContentManager Content)
        {
            // TODO: use this.Content to load your game content here
            tank          = Content.Load <Texture2D>("Tank");
            position_tank = new Vector2(30 * 20f, 0 * 20f);
            origin        = new Vector2(tank.Width / 2f, tank.Height / 2f);

            pixel_black = Content.Load <Texture2D>("Pixel_2_black");
            pixel_red   = Content.Load <Texture2D>("Pixel_2_red");
            font_wheels = Content.Load <SpriteFont>("Game");

            r_pos        = new List <Vector2>();
            b_pos        = new List <Vector2>();
            lines        = new List <Vector2>();
            line_closest = new List <Vector2>();
            r_pos        = g.RedPositions;
            b_pos        = g.BluePositions;

            vec_closest_r = ClosestDot(DOTS.RED);
            AngleDist(vec_closest_r, out dir_closest_r, out dist_r);
            vec_closest_b = ClosestDot(DOTS.BLUE);
            AngleDist(vec_closest_b, out dir_closest_b, out dist_b);
            net = new BNet(neurons, 1, .25f, .9f);//neurons, slope?, learningrate, momentum
            net.Randomize();
        }
コード例 #2
0
        public void ProcessBeliefNetwork()
        {
            m_net = new BNet();
            m_query = new ArrayList();

            m_net.Build(fileName);
            m_net.PrintNet("BNet_layout.txt");

            infer = new BElim(m_net);

            _nodes.Clear();
            foreach (BNode node in m_net.Nodes)
                _nodes.Add(node.Name);

            Console.WriteLine("For example: " + _nodes[0] + "=1; " + _nodes[1] + "=0");
            Console.WriteLine("For example: " + _nodes[2] + "=1");

            string evidence = "cloudy=1; sprinkler=0".TrimEnd(';'); // cloudy=1; sprinkler=0
            string query = "wetgrass=1".TrimEnd(';'); //wetgrass=1
            string obs = evidence.Trim();
            string x = query.Trim();

            if (IsValid(x, obs))
            {
                double pr = infer.GetBelief(x, obs);

                string out1 = " P( " + x;
                out1 += (obs.Length > 0) ? " | " + obs + " )" : " )";
                string out2 = "  = " + pr.ToString("F4");
                string result = "";
                result += out1;
                result += out2;
            }
        }
コード例 #3
0
ファイル: DAGLoader.cs プロジェクト: asyncmeonov/BayesianPDG
        /// <summary>
        /// Loads the network by instantiating the Net property of the DAGLoader
        /// </summary>
        /// <param name="path">relative path from BaseDirectory</param>
        public BNet LoadBNet(string path)
        {
            Debug.WriteLine($"Loading Bayesian Network from {path}...");
            _app.Visible = false;
            string   net_file_name = AppDomain.CurrentDomain.BaseDirectory + path;
            Streamer file          = _app.NewStream(net_file_name, null);
            BNet     net           = _app.ReadBNet(file);

            net.Compile();
            return(net);
        }
コード例 #4
0
        public void Update()
        {
            // TODO: Add your update logic here
            r_pos        = new List <Vector2>();
            b_pos        = new List <Vector2>();
            lines        = new List <Vector2>();
            line_closest = new List <Vector2>();
            r_pos        = g.RedPositions;
            b_pos        = g.BluePositions;
            currentState = Keyboard.GetState();
            if (currentState.IsKeyDown(Keys.R))
            {
                position_tank = new Vector2(30 * 20f, 0 * 20f);
                rotation      = 90f;
                wheels[0]     = .5f;
                wheels[1]     = .5f;

                r_pos        = new List <Vector2>();
                lines        = new List <Vector2>();
                line_closest = new List <Vector2>();
                r_pos        = g.RedPositions;

                vec_closest_r = ClosestDot(DOTS.RED);
                AngleDist(vec_closest_r, out dir_closest_r, out dist_r);
                net = new BNet(neurons, 1, .25f, .9f);//neurons, slope?, learningrate, momentum
                net.Randomize();
            }

            if (draw)
            {
                draw = false;
            }
            CalcRotation();
            CalcPosition();
            DrawLines(DOTS.RED);
            g.Collision((int)position_tank.X, (int)position_tank.Y, vec_closest_r);
            if (currentState.IsKeyDown(Keys.N) || g.Reset)
            {
                float dist;
                vec_closest_r = ClosestDot(DOTS.RED);
                g.Reset       = false;
            }
            else
            {
                AngleDot(vec_closest_r, out dir_closest_r);
            }

            Train();
            AdjustWheels();
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: wsjager/PythonNetica
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Welcome to Netica API for C# !");
                Netica.Application app = new Netica.Application();
                app.Visible = true;
                string net_file_name = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\..\\ChestClinic.dne";

                Streamer file = app.NewStream(net_file_name, null);
                BNet     net  = app.ReadBNet(file, "");
                net.Compile();
                BNode  TB  = net.Node("Tuberculosis");
                double bel = TB.GetBelief("present");
                Console.WriteLine("The probability of tuberculosis is " + bel.ToString("G4"));

                BNode XRay = net.Node("XRay");
                XRay.EnterFinding("abnormal");
                bel = TB.GetBelief("present");
                Console.WriteLine("Given an abnormal X-Ray, the probability of tuberculosis is " + bel.ToString("G4"));

                net.Node("VisitAsia").EnterFinding("visit");
                bel = TB.GetBelief("present");
                Console.WriteLine("Given abnormal X-Ray and visit to Asia, the probability of TB is " + bel.ToString("G4"));

                net.Node("Cancer").EnterFinding("present");
                bel = TB.GetBelief("present");
                Console.WriteLine("Given abnormal X-Ray, Asia visit, and lung cancer, the probability of TB is " + bel.ToString("G4"));

                net.Delete();
                if (!app.UserControl)
                {
                    app.Quit();
                }
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Console.WriteLine("Netica Demo: Error " + (e.ErrorCode & 0x7FFF) + ": " + e.Message);
            }
            Console.WriteLine("Press <enter> to quit.");
            Console.ReadLine();
        }
コード例 #6
0
        public void ProcessBeliefNetwork()
        {
            m_net   = new BNet();
            m_query = new ArrayList();

            m_net.Build(fileName);
            m_net.PrintNet("BNet_layout.txt");

            infer = new BElim(m_net);

            _nodes.Clear();
            foreach (BNode node in m_net.Nodes)
            {
                _nodes.Add(node.Name);
            }

            Console.WriteLine("For example: " + _nodes[0] + "=1; " + _nodes[1] + "=0");
            Console.WriteLine("For example: " + _nodes[2] + "=1");

            string evidence = "cloudy=1; sprinkler=0".TrimEnd(';'); // cloudy=1; sprinkler=0
            string query    = "wetgrass=1".TrimEnd(';');            //wetgrass=1
            string obs      = evidence.Trim();
            string x        = query.Trim();

            if (IsValid(x, obs))
            {
                double pr = infer.GetBelief(x, obs);

                string out1 = " P( " + x;
                out1 += (obs.Length > 0) ? " | " + obs + " )" : " )";
                string out2   = "  = " + pr.ToString("F4");
                string result = "";
                result += out1;
                result += out2;
            }
        }
コード例 #7
0
 private void MainForm_Load(object sender, System.EventArgs e)
 {
     m_net   = new BNet();
     m_query = new ArrayList();
 }
コード例 #8
0
 public SpaceModel(DAGLoader loader)
 {
     net = loader.Net;
 }
コード例 #9
0
ファイル: DAGLoader.cs プロジェクト: asyncmeonov/BayesianPDG
 public DAGLoader(string netPath, Application context)
 {
     _app = context;
     Net  = LoadBNet(netPath);
 }