Example #1
0
        public Agent(int position_x, int position_y, double learning_rate, LabSpace lab, Game game, bool fastLearning = false, double radius = .25)
        {
            this.position_x = position_x;
            this.position_y = position_y;
            this.radius     = radius;

            // Set learning rate
            if (learning_rate < 0)
            {
                learning_rate = 0;
            }
            if (learning_rate > .99)
            {
                learning_rate = .99;
            }
            this.learning_rate = learning_rate;

            // Set fast learning
            this.fastLearning = fastLearning;

            // Set game instance
            this.game = game;

            // Set lab in which agent have to learn
            this.lab = lab;

            // Start Q and A matrix as zero matrix
            Q = new Matrix(game.getR().getLength());
            A = new Matrix(game.getR().getLength());

            // Start async brain operations
            brain = new Thread(new ThreadStart(brainWorker));
            brain.Start();
        }
Example #2
0
        // PUBLIC FUNCTIONS
        public void drawLabWalls(int x, int y, int width, int height, Color color)
        {
            lab = new LabSpace(x, y, width, height, color);

            // Start R matrix - direct rewards matrix (top-right screen)
            R = new Matrix((width - 1) * (height - 1));
            R.setValue(width - 3, width - 2, 1);
            R.setValue((width - 1) * 2 - 1, width - 2, 1);
        }