コード例 #1
0
//----Checks if there is a match, add activities, else creates a new association----//
void checkLocalCell()
{
	//uses a normalised version of the localTemp.  The comparison local cells are stored as normalised when 1st created
	char z;
	char match = 0;
	float dotTempValue = 0;
	float tempAngle = 0;
	if(nextEmptyCell == 0)
	{
	  //first localCellView
		addAssociation(nextEmptyCell);
    nextEmptyCell++;
    PlaySound(soundFastUpwardTones);
    while(bSoundActive) {}
	}
  else {
    for(z = 0; z<nextEmptyCell; z++)
    {
    	//search for a previous local cell that matches the current view to a certain degree
      memcpy(localComparison,poseAssoc[z].localView,numNeuralUnits*4);
      dotTempValue = dotMultiply();
      tempAngle = acos(dotTempValue);
      if(tempAngle<0.17) //if difference less than 10 degrees between vectors
      {
      	match = 1;
      	break; //save cycles break out
      }
    }
    if(match == 0)
    {//no match found - create a new local view cell
    	addAssociation(nextEmptyCell);
    	nextEmptyCell++;
    	nxtDisplayCenteredTextLine(6, "cell created");
      PlaySound(soundFastUpwardTones);
      while(bSoundActive) {}
    }
    else if(match == 1)
    {
    	char tempX, tempY, tempTheta;
    	tempX = poseAssoc[nextEmptyCell-1].xCell;
    	tempY = poseAssoc[nextEmptyCell-1].yCell;
    	tempTheta = poseAssoc[nextEmptyCell-1].thetaCell;
    	//injectEnergy(stepSize, tempX, tempY, tempTheta);
    	nxtDisplayCenteredTextLine(6, "Energy Injected");
      PlaySound(soundBeepBeep);
      while(bSoundActive) {}
    }
  }
}
コード例 #2
0
ファイル: d2.c プロジェクト: ITanCh/Compiler-NJU
 int main()
	 {

			 float a[10], c[10], b[10], d[10];
		 int i = 0;
		 struct Vector v1;
		 struct Vector v2;
		 while(i<10)
			{

				 v1.x = a[i];
				 v1.y = b[i];
				 v2.x = c[i];
				 v2.y = d[i];
				 i = i+1;
				
					dotMultiply(v1, v2);
			}
		 return 0;
		

	}
コード例 #3
0
ファイル: c1.c プロジェクト: ITanCh/Compiler-NJU
int main()
 {

	 float a[10], b, c[10];
	 float d[10];
	 int i = 0;
	 struct Vector sv1;
	 struct Vector sv2;
	 while(i<10)
		 {

			 sv1.x = a[i];
			 sv1.y = b;
			 sv2.x = c[i];
			 sv2.y = d[i];
			
				i = i+1;
				dotMultiply(sv1, sv2);
		}
	 return 0;
	

}
コード例 #4
0
ファイル: localNeural.c プロジェクト: mjs513/rsnxt08
void checkLocalCell()
{
	//uses a normalised version of the localTemp.  The comparison local cells are stored as normalised when 1st created
	char z;
	char match = 0;
	float dotTempValue = 0;
	float tempAngle = 0;
	if(nextEmptyCell == 0)
	{
	  //first localCellView
		fillStructArray(nextEmptyCell);
    nextEmptyCell++;
    //eraseDisplay();
    //nxtDisplayCenteredTextLine(3, "New Cell Created");
    //wait1Msec(1000);
    //eraseDisplay();
    PlaySoundFile("! Attention.rso");
    while(bSoundActive) {}
	}
  else {
    for(z = 0; z<nextEmptyCell; z++)
    {
    	//search for a previous local cell that matches the current view to a certain degree
  	  fillLocalComparison(z);
      dotTempValue = dotMultiply();
      tempAngle = acos(dotTempValue);
      eraseDisplay();
      nxtDisplayString(5, "%3.3f", tempAngle);
      wait1Msec(1000);
      if(tempAngle<0.17)
      {
        //a match - need to check
      	match = 1;
      	break;
      }
    }
    if(match == 0)
    {//no match found - create a new local view cell
    	fillStructArray(nextEmptyCell);
    	nextEmptyCell++;
    //	eraseDisplay();
     // nxtDisplayCenteredTextLine(3, "No Match");
    //  nxtDisplayCenteredTextLine(4, "New Cell Created");
     // wait1Msec(1000);
    //  eraseDisplay();
      PlaySoundFile("! Attention.rso");
      while(bSoundActive) {}
    }

    else if(match == 1)
    {
     // eraseDisplay();
     // nxtDisplayCenteredTextLine(3, "Match");
     // wait1Msec(1000);
     // eraseDisplay();
      PlaySoundFile("Woops.rso");
      while(bSoundActive) {}
    }

  }
}
コード例 #5
0
ファイル: b4 rat.c プロジェクト: mjs513/rsnxt08
//----Checks if there is a match, add activities, else creates a new association----//
void checkLocalCell()
{
	//uses a normalised version of the localTemp.  The comparison local cells are stored as normalised when 1st created
	char z;
	char breakSymbol =0;
	signed char cellCount = 0;
	char match = 0;
	float dotTempValue = 0;
	float tempAngle = 0;
	if(nextEmptyCell == 0)
	{
	  //first localCellView
		writeLocal();
    nextEmptyCell++;
    PlaySound(soundFastUpwardTones);
    while(bSoundActive) {}
	}
  else {
  OpenRead(hFileHandle3,nIoResultRead,sFileName1,nFileSize);
  while(nIoResultRead != ioRsltEndOfFile)
    {
    	//search for a previous local cell that matches the current view to a certain degree
    	for(z = 0; z<numNeuralUnits; z++)
    	{
    		ReadFloat(hFileHandle3,nIoResultRead,localComparison.localArray[z]);
    		if(nIoResultRead == ioRsltEndOfFile) {breakSymbol = 1;break;}
    	}
    	if(breakSymbol == 1) {break;}
      ReadByte(hFileHandle3, nIoResultRead, injectX);
      ReadByte(hFileHandle3, nIoResultRead, injectY);
      ReadByte(hFileHandle3, nIoResultRead, injectTheta);

      dotTempValue = dotMultiply();
      tempAngle = acos(dotTempValue);
      if(tempAngle<0.17)//0.17 //if difference less than 10 degrees between vectors
      {
      	match = 1;
      	Close(hFileHandle3,nIoResultRead);
      	break; //save cycles break out
      }
      cellCount++;
    }
    if(match == 0)
    {//no match found - create a new local view cell
      Close(hFileHandle3,nIoResultRead);
      swapFiles();
    	nextEmptyCell++;
      PlaySound(soundFastUpwardTones);
      while(bSoundActive) {}
    }
    else if(match == 1)
    {
    	injectEnergy(stepSize, injectX, injectY, injectTheta);
    	nxtDisplayStringAt(64,30,"x: %2d",injectX);
	    nxtDisplayStringAt(64,20,"y: %2d",injectY);
	    nxtDisplayStringAt(64,10,"T: %1d",injectTheta);
      PlaySound(soundBeepBeep);
      while(bSoundActive) {}
    }
  }
}