public bool contains(Move move, Percept percept)
 {
     if (perception_data[move] == percept)
     {
         return(true);
     }
     return(false);
 }
        public PerceptionState()
        {
            perception_data = new SortedDictionary <Move, Percept>();
            foreach (var i in Move.get_moves())
            {
                perception_data.Add(i, Percept.initialized());
            }

            set_name();
        }
Exemple #3
0
        private readonly static List <Percept> list; //for counting

        //This might not be necessary

        static Percept()
        {
            wall_percept  = new Percept("Wall");
            empty_percept = new Percept("Empty");
            can_percept   = new Percept("Can");

            list = new List <Percept>();
            list.Add(wall_percept);
            list.Add(empty_percept);
            list.Add(can_percept);

            initialized_percept = new Percept("initialized");
        }
Exemple #4
0
        static public void small_dropdown_changed(ComboBox changed_dropdown)
        {
            if (changed_dropdown.SelectedText != "None.")
            {
                PerceptionState to_set       = new PerceptionState();
                Move            percept_move = null;

                foreach (var i in Move.list)
                {
                    if (changed_dropdown == list_qmatrix_comboboxes[i])
                    {
                        percept_move = i;
                    }
                }

                //get the percept of the dropdown
                Percept keep_for_best_fit = (Percept)changed_dropdown.SelectedItem;

                //Build a perception state that matches the dropdowns
                foreach (var i in Move.list)
                {
                    to_set.perception_data[i] = (Percept)list_qmatrix_comboboxes[i].SelectedItem;
                }

                to_set.set_name();
                to_set = PerceptionState.list_of_states[to_set]; //Convert to static instance

                //This state may not exist in our q-matrix states, because we only changed one of the dropdowns.
                //The best solution i think is to make the other dropdowns find the most accurate state.
                //Compare all the states in the q-matrix, and display any that is tied for best matched.
                //Also, the matching state must have the same item as the dropdown we just changed.

                int             compare_value        = 0;
                int             temp                 = 0;
                PerceptionState best_perceptionstate = null;
                foreach (PerceptionState i in qmatrix_state_combobox_large.Items)
                {
                    temp = to_set.compare(i);
                    if (temp > compare_value && i.contains(percept_move, keep_for_best_fit))
                    {
                        best_perceptionstate = i;
                        compare_value        = temp;
                    }
                }

                ViewQmatrixConfiguration(best_perceptionstate);
            }
        }
        static PerceptionState()
        {
            //Create all 243 possible configurations

            list_of_states = new Dictionary <PerceptionState, PerceptionState>();

            PerceptionState to_build;

            foreach (var i in Percept.get_list())
            {
                foreach (var j in Percept.get_list())
                {
                    foreach (var k in Percept.get_list())
                    {
                        foreach (var l in Percept.get_list())
                        {
                            foreach (var m in Percept.get_list())
                            {
                                to_build = new PerceptionState();
                                to_build.perception_data[Move.left()]  = i;
                                to_build.perception_data[Move.right()] = j;
                                to_build.perception_data[Move.down()]  = k;
                                to_build.perception_data[Move.up()]    = l;
                                to_build.perception_data[Move.grab()]  = m;
                                to_build.set_id(list_of_states.Count);
                                to_build.set_name();

                                list_of_states.Add(to_build, to_build);
                                //list_of_states[to_build] = to_build;
                                //Add the perception state to our dictionary at a location reachable if we can build a similar dictionary.
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        //Used when the robot moves *only*, otherwise, the perception will be checked from the state of the unit.
        //Generates percepts, and not MoveResults.
        public Percept percieve(Move move_to_check)
        {
            BaseSquare bender_location = board_data[bender.x_coordinate][bender.y_coordinate];

            if (move_to_check != Move.grab() && ((BoardSquare)bender_location).check_if_walls_prevent_move(move_to_check))
            {
                return(Percept.wall()); //Wall percieved
            }
            else
            {
                int percieve_x = bender.x_coordinate + move_to_check.grid_adjustment[0];
                int percieve_y = bender.y_coordinate + move_to_check.grid_adjustment[1];

                BaseSquare percieve_location = board_data[percieve_x][percieve_y];
                if (percieve_location.beer_can_present)
                {
                    return(Percept.can());
                }
                else
                {
                    return(Percept.empty());
                }
            }
        }