Ejemplo n.º 1
0
    private int rsize; /**< The number of rows. */

    #endregion Fields

    #region Constructors

    /**
     * Constructor.
     *
     * /param input The input chars map.
     * /param rsize The number of rows in the map.
     * /param csize The number of columns in the map.
     * /param mapWorld A link to the original GridWorldMap class.
     */
    public AreaFinder(char[] input, int rsize, int csize, GridWorldMap mapWorld)
    {
        this.input = input;
        this.rsize = rsize;
        this.csize = csize;
        equivalence = new Dictionary<int,int>();
        this.mapWorld = mapWorld;
    }
Ejemplo n.º 2
0
    private Dictionary <int, int> equivalence; /**< A dictionary that stores the equivalence class between labels. */

    /**
     * Constructor.
     *
     * /param input The input chars map.
     * /param rsize The number of rows in the map.
     * /param csize The number of columns in the map.
     * /param mapWorld A link to the original GridWorldMap class.
     */
    public AreaFinder(char[] input, int rsize, int csize, GridWorldMap mapWorld)
    {
        this.input    = input;
        this.rsize    = rsize;
        this.csize    = csize;
        equivalence   = new Dictionary <int, int>();
        this.mapWorld = mapWorld;
    }
Ejemplo n.º 3
0
        public GridWorldForm2(GridWorldMap gw1, int blockSize, ISolver A, INode start, INode goal)
        {
            //set image
            InitializeComponent();

            GridWorldMap gwMap = DrawResults(gw1, blockSize, A.getPolicy(), start, goal);



            pictureBox1.Width  = gwMap.BitMap.Width;
            pictureBox1.Height = gwMap.BitMap.Height;
            pictureBox1.Image  = gwMap.BitMap;
            pictureBox1.Update();


            // print solver parameters to dataview
            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

            col            = new DataGridViewTextBoxColumn();
            col.HeaderText = "Search parameters";
            ResultView.Columns.Add(col);
            ResultView.RowHeadersWidth = 50;

            col            = new DataGridViewTextBoxColumn();
            col.HeaderText = "Values";
            ResultView.Columns.Add(col);
            ResultView.RowHeadersWidth = 50;

            DataGridViewRow row;

            int i = 0;

            foreach (KeyValuePair <string, string> pair in A.GetSearchInfo().SearchResults.Union(A.GetSearchInfo().SearchParameters))
            {
                row = new DataGridViewRow();

                row.HeaderCell.Value = String.Format("{0}", i + 1);

                ResultView.Rows.Add(row);

                ResultView.Rows[i].Cells[0].Value = pair.Key;
                ResultView.Rows[i].Cells[1].Value = pair.Value;
                i += 1;
            }


            //add total reward
            row = new DataGridViewRow();
            row.HeaderCell.Value = String.Format("{0}", i + 1);
            ResultView.Rows.Add(row);
            ResultView.Rows[i].Cells[0].Value = "Cummulative reward";
            ResultView.Rows[i].Cells[1].Value = SumQ.ToString();

            ResultView.Width = col.Width + ResultView.RowHeadersWidth;
            ResultView.Update();
        }
Ejemplo n.º 4
0
        private void generateBtn_Click(object sender, EventArgs e)
        {
            GeneratingState();
            GenerateBtn.Enabled = false;
            blockSize           = 1;
            if (blockSizeList.SelectedItem == blockSizeList.Items[0])
            {
                blockSize = 1;
            }
            else
            if (blockSizeList.SelectedItem == blockSizeList.Items[1])
            {
                blockSize = 4;
            }
            else
            if (blockSizeList.SelectedItem == blockSizeList.Items[2])
            {
                blockSize = 10;
            }
            else
            if (blockSizeList.SelectedItem == blockSizeList.Items[3])
            {
                blockSize = 40;
            }
            else
            if (blockSizeList.SelectedItem == blockSizeList.Items[4])
            {
                blockSize = 80;
            }
            StartX = 0;
            StartY = 0;
            GoalX  = (gwMap.BitMap.Height / blockSize) * blockSize - blockSize;
            GoalY  = (gwMap.BitMap.Height / blockSize) * blockSize - blockSize;



            Random random = new Random();

            gwMap = new GridWorldMap(400, 400);
            gwMap.CreateBlocks(blockSize);
            gwMap.DrawBlock(StartX, StartY, Color.Red, blockSize);
            gwMap.DrawBlock(GoalX, GoalY, Color.Green, blockSize);
            Bitmap bitmap = new Bitmap(gwMap.BitMap);

            pictureBox1.Width  = bitmap.Width;
            pictureBox1.Height = bitmap.Height;
            pictureBox1.Image  = bitmap;
            pictureBox1.Update();
            ReadyState();
        }
Ejemplo n.º 5
0
        public GridWorldForm()
        {
            InitializeComponent();
            Dock = DockStyle.Fill;
            ReadyState();
            blockSizeList.SelectedItem = "Size 1";
            Bitmap bitmap = new Bitmap(400, 400);

            for (int i = 0; i < bitmap.Height; i++)
            {
                for (int j = 0; j < bitmap.Width; j++)
                {
                    bitmap.SetPixel(j, i, Color.White);
                }
            }
            gwMap              = new GridWorldMap(bitmap);
            pictureBox1.Width  = bitmap.Width;
            pictureBox1.Height = bitmap.Height;
            pictureBox1.Image  = bitmap;
            pictureBox1.Update();
            blockSize   = 1;
            listOfForms = new List <Form>();



            StartX = 0;
            StartY = 0;
            GoalX  = (gwMap.BitMap.Height / blockSize) * blockSize - blockSize;
            GoalY  = (gwMap.BitMap.Height / blockSize) * blockSize - blockSize;


            hcal      = new GWHCal(blockSize);
            sucgen    = new ANodeSucGen(new GridWorld(gwMap, blockSize));
            uctSucGen = new UCTNodeSucGen(new GridWorld(gwMap, blockSize));


            radioButton1.Checked = true;
            blockSizeList.Text   = blockSizeList.Items[0].ToString();


            InitialState();
        }
Ejemplo n.º 6
0
        public GridWorldMap DrawResults(GridWorldMap gw1)
        {
            if (gw1 == null || A == null)
            {
                return(null);
            }

            GridWorldMap gw2 = new GridWorldMap(gw1);


            IPolicy        policy       = A.getPolicy();
            GridWorldState currentState = (GridWorldState)start.State;
            GridWorldState goalState    = (GridWorldState)goal.State;
            IEnvironment   env          = new GridWorld(gwMap, blockSize);

            gw2.DrawBlock(currentState.X, currentState.Y, Color.Red, blockSize);
            gw2.DrawBlock(goalState.X, goalState.Y, Color.Green, blockSize);


            int i    = 0;
            int maxi = 3000;

            while (policy != null && !currentState.Equals(goal.State) && i < maxi)
            {
                i++;
                IOperator op = policy.action(currentState);

                IOutcome outcome = env.act(currentState, policy.action(currentState));

                currentState = (GridWorldState)outcome.State;

                gw2.DrawBlock(currentState.X, currentState.Y, Color.Red, blockSize);
            }

            if (i >= maxi)
            {
                MessageBox.Show("Path not found");
            }
            ;

            return(gw2);
        }
Ejemplo n.º 7
0
        public GridWorldMap DrawResults(GridWorldMap gw1, int blockSize, IPolicy policy, INode start, INode goal)
        {
            GridWorldMap gw2 = new GridWorldMap(gw1);


            GridWorldState currentState = (GridWorldState)start.State;
            IEnvironment   env          = new GridWorld(gw2, blockSize);

            gw2.DrawBlock(currentState.X, currentState.Y, Color.Red, blockSize);

            int i    = 0;
            int maxi = 3000;


            if (policy == null)
            {
                MessageBox.Show("Path not found");
            }

            while (policy != null && !currentState.Equals(goal.State) && i < maxi)
            {
                i++;
                IOperator op = policy.action(currentState);

                IOutcome outcome = env.act(currentState, policy.action(currentState));

                SumQ += outcome.Reward;

                currentState = (GridWorldState)outcome.State;

                gw2.DrawBlock(currentState.X, currentState.Y, Color.Red, blockSize);
            }

            if (i >= maxi)
            {
                MessageBox.Show("Path not found");
            }
            ;

            return(gw2);
        }
Ejemplo n.º 8
0
 // Use this for initialization
 protected virtual void Awake()
 {
     mapWorld = GameObject.Find("MapGenerator").GetComponent <GridWorldMap>();
 }
Ejemplo n.º 9
0
 // Use this for initialization
 protected virtual void Awake()
 {
     mapWorld = GameObject.Find("MapGenerator").GetComponent<GridWorldMap>();
 }