Exemplo n.º 1
0
 //
 //		  int       GetNumberOfWeights()const{return m_ItsBrain.GetNumberOfWeights();}
 public int GetNumberOfWeights() {
   return m_ItsBrain.GetNumberOfWeights();
 }
Exemplo n.º 2
0
 //
 //			//updates the ANN with information from the sweepers enviroment
 //			bool			Update(vector<SVector2D> &mines);
 public boolean Update(Vector<sVector2D> mines) {
   //		//this will store all the inputs for the NN
   //		vector<double> inputs;
   Vector<Double> inputs = new Vector<Double>();
   //
   //		//get vector to closest mine
   //		SVector2D vClosestMine = GetClosestMine(mines);
   sVector2D vClosestMine = GetClosestMine(mines);
   //
   //		//normalise it
   //	  Vec2DNormalize(vClosestMine);
   sVector2D.Vec2DNormalize(vClosestMine);
   //
   //	  //add in vector to closest mine
   //		inputs.push_back(vClosestMine.x);
   inputs.add(vClosestMine.x);
   //		inputs.push_back(vClosestMine.y);
   inputs.add(vClosestMine.y);
   //
   //		//add in sweepers look at vector
   //		inputs.push_back(m_vLookAt.x);
   inputs.add(m_vLookAt.x);
   //		inputs.push_back(m_vLookAt.y);
   inputs.add(m_vLookAt.y);
   //
   //
   //		//update the brain and get feedback
   //		vector<double> output = m_ItsBrain.Update(inputs);
   Vector<Double> output = m_ItsBrain.Update(inputs);
   //
   //		//make sure there were no errors in calculating the
   //		//output
   //		if (output.size() < CParams::iNumOutputs)
   if (output.size() < jParams.iNumOutputs) {
     //	  {
     //	    return false;
     return false;
     //	  }
   }
   //
   //		//assign the outputs to the sweepers left & right tracks
   //		m_lTrack = output[0];
   m_lTrack = output.get(0);
   //		m_rTrack = output[1];
   m_rTrack = output.get(1);
   //
   //		//calculate steering forces
   //		double RotForce = m_lTrack - m_rTrack;
   double RotForce = m_lTrack - m_rTrack;
   //
   //		//clamp rotation
   //		Clamp(RotForce, -CParams::dMaxTurnRate, CParams::dMaxTurnRate);
   utils.Clamp(RotForce, jParams.dMaxTurnRate, jParams.dMaxTurnRate);
   //
   //	  m_dRotation += RotForce;
   m_dRotation += RotForce;
   //
   //		m_dSpeed = (m_lTrack + m_rTrack);
   m_dSpeed = (m_lTrack + m_lTrack);
   //
   //		//update Look At
   //		m_vLookAt.x = -sin(m_dRotation);
   m_vLookAt.x = -Math.sin(m_dRotation);
   //		m_vLookAt.y = cos(m_dRotation);
   m_vLookAt.y = Math.cos(m_dRotation);
   //
   //		//update position
   //	  m_vPosition += (m_vLookAt * m_dSpeed);
   m_vPosition.plusEquals(sVector2D.times(m_vLookAt, m_dSpeed));
   //
   //		//wrap around window limits
   //		if (m_vPosition.x > CParams::WindowWidth) m_vPosition.x = 0;
   //		if (m_vPosition.x < 0) m_vPosition.x = CParams::WindowWidth;
   //		if (m_vPosition.y > CParams::WindowHeight) m_vPosition.y = 0;
   //		if (m_vPosition.y < 0) m_vPosition.y = CParams::WindowHeight;
   //
   //		return true;
   return true;
 }
Exemplo n.º 3
0
 //
 //		  void      PutWeights(vector<double> &w){m_ItsBrain.PutWeights(w);}
 public void PutWeights(Vector<Double> w) {
   m_ItsBrain.PutWeights(w);
 }