<commit_before>#include <vector>
#include <cmath>
#include <stdexcept>
#include "PriorityQueue.h"

//index with state_space_object[robot_state][angle][velocity]

class Action;

enum robot_states{TORSO_BACK,TORSO_FORWARDS};

//class to hold the 2d vector of containers of experiences that represents the robot's state and memory
class StateSpace
{
	public:
		//@_x_size: the size of the first vector
		//@_y_size: the size of the second vector
		explicit StateSpace(const unsigned int _angle_max, const unsigned int _velocity_max);
		~StateSpace();
		
		StateSpace(const StateSpace&)=delete;
		
		//these nested classes are neccessary so that the [][][] operator can be called on this class
		//the operator should be called with the continuous state variables which it will then discretise
		//-----------------------------------------------------------------------------
		class SubscrpitProxy1
		{
			public:
				SubscriptProxy1(std::vector<std::vector<PriorityQueue<Action*,double>>>& _vec):vec(_vec){}
				
				SubscriptProxy2 operator[](const double angle)
				{
					//error if angle exceeds bounds
					if(std::abs(angle)>M_PI/4)throw std::domain_error("angle argument exceeded");
					//descretise index
					int discrete_index=std::round(angle*100/angle_max)+angle_max/2;
					
					//return appropriate array
					return SubscriptProxy2(vec[discrete_index]);
				}
			
			private:
				std::vector<std::vector<PriorityQueue<Action*,double>>>& vec;
		};
		
		class SubscrpitProxy2
		{
			public:
				SubscriptProxy2(std::vector<PriorityQueue<Action*,double>>& _vec):vec(_vec){}
				
				PriorityQueue<Action*,double>& operator[](const double velocity)
				{
					//error if angle exceeds bounds
					if(std::abs(velocity)>1)throw std::domain_error("velocity argument exceeded");
					//descretise index
					int discrete_index=std::round(velocity*100/velocity_max)+velocity_max/2;
					
					//return appropriate array
					return SubscriptProxy2(vec[discrete_index]);
				}
			
			private:
				std::vector<PriorityQueue<Action*,double>>& vec;
		};
		//-----------------------------------------------------------------------------
		
		SubscriptProxy1 operator[](const unsigned int robot_state);
		
	private:
		//the sizes of the two arrays
		const int angle_max;
		const int velocity_max;
		
		//the 2d array that contains the robots previous experiences in each state
		std::vector<std::vector<PriorityQueue<Action*,double>>> space1;
		std::vector<std::vector<PriorityQueue<Action*,double>>> space2;
};<commit_msg>added a search by state object function<commit_after>#include <vector>
#include <cmath>
#include <stdexcept>
#include "PriorityQueue.h"

//index with state_space_object[robot_state][angle][velocity]

class Action;

enum robot_states{TORSO_BACK,TORSO_FORWARDS};

//class to hold the 2d vector of containers of experiences that represents the robot's state and memory
class StateSpace
{
	public:
		//@_x_size: the size of the first vector
		//@_y_size: the size of the second vector
		explicit StateSpace(const unsigned int _angle_max, const unsigned int _velocity_max);
		~StateSpace();
		
		StateSpace(const StateSpace&)=delete;
		
		//these nested classes are neccessary so that the [][][] operator can be called on this class
		//the operator should be called with the continuous state variables which it will then discretise
		//-----------------------------------------------------------------------------
		class SubscrpitProxy1
		{
			public:
				SubscriptProxy1(std::vector<std::vector<PriorityQueue<Action*,double>>>& _vec):vec(_vec){}
				
				SubscriptProxy2 operator[](const double angle)
				{
					//error if angle exceeds bounds
					if(std::abs(angle)>M_PI/4)throw std::domain_error("angle argument exceeded");
					//descretise index
					int discrete_index=std::round(angle*100/angle_max)+angle_max/2;
					
					//return appropriate array
					return SubscriptProxy2(vec[discrete_index]);
				}
			
			private:
				std::vector<std::vector<PriorityQueue<Action*,double>>>& vec;
		};
		
		class SubscrpitProxy2
		{
			public:
				SubscriptProxy2(std::vector<PriorityQueue<Action*,double>>& _vec):vec(_vec){}
				
				PriorityQueue<Action*,double>& operator[](const double velocity)
				{
					//error if angle exceeds bounds
					if(std::abs(velocity)>1)throw std::domain_error("velocity argument exceeded");
					//descretise index
					int discrete_index=std::round(velocity*100/velocity_max)+velocity_max/2;
					
					//return appropriate array
					return SubscriptProxy2(vec[discrete_index]);
				}
			
			private:
				std::vector<PriorityQueue<Action*,double>>& vec;
		};
		//-----------------------------------------------------------------------------
		
		SubscriptProxy1 operator[](const unsigned int robot_state);
		PriorityQueue<Action *, double> StateSearch(State * state);
	private:
		//the sizes of the two arrays
		const int angle_max;
		const int velocity_max;
		
		//the 2d array that contains the robots previous experiences in each state
		std::vector<std::vector<PriorityQueue<Action*,double>>> space1;
		std::vector<std::vector<PriorityQueue<Action*,double>>> space2;
};
{'fraction_non_alphanumeric': 0.1655951685174362, 'fraction_numerical': 0.008571985193843756, 'mean_word_length': 3.2429752066115705, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '790997', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1413, 'n_words': 380}