Esempio n. 1
0
void Solver::PrintSolutionFile(void)
{
	ofsteam myfile;
	myfile.open ("exampleSolution.txt");
	int i;
	for (i = 0; i < solutionLength1; i++)
		myfile << Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0))
		     << " ";
	for (i = 0; i < solutionLength2; i++)
		myfile << Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1))
		     << " ";
}
Esempio n. 2
0
void Solver::PrintSolution(void)
{
	int i;
	for (i = 0; i < solutionLength1; i++)
		cout << Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0))
		     << " ";
	cout << ". ";
	for (i = 0; i < solutionLength2; i++)
		cout << Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1))
		     << " ";
	cout << "(" << solutionLength1 + solutionLength2 << ")" << endl;
}
Esempio n. 3
0
void Solver::PrintSolution(void)
{
	AnimCube->MoveList.Reset();
	Window->ListClear();
	Window->ListAdd(0);
	Window->SetMovesNum(solutionLength1 + solutionLength2);
	
	for (int i = 0; i < solutionLength1; i++)
		AddMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0));
		
	for (int i = 0; i < solutionLength2; i++)
		AddMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1));
}
Esempio n. 4
0
void Solver::PrintSolutionFile(void)
{
	ofstream myfile;
	myfile.open("exampleSolution.txt");
	int i;
	for (i = 0; i < solutionLength1; i++)
	{	
		string moveHere = Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0));
	}
	for (i = 0; i < solutionLength2; i++)
	{
		string moveHere = Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1));
	}
	exit(0);
}
Esempio n. 5
0
void Solver::PrintSolution(void)
{
	int i;
	Moves = new char[170];
	for(int i=0; i<170; i++) Moves[i] = 0;
	for (i = 0; i < solutionLength1; i++)
	{
		cout
		<< Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0))
		    << " ";
		if(i>0)
			std::sprintf(Moves,"%s %s",Moves,Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0)));
		else
			std::sprintf(Moves,"%s",Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0)));
	}
	cout << ". ";
	for (i = 0; i < solutionLength2; i++)
	{
		cout << Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1))
		     << " ";
		if(i==0 && solutionLength1 <= 0)
			std::sprintf(Moves,"%s",Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1)));
		else
			std::sprintf(Moves,"%s %s",Moves,Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1)));

	}
	cout << "(" << solutionLength1 + solutionLength2 << ")" << endl;
}
Esempio n. 6
0
void Solver::toArduinoInterf(void)
{
	string answer;
	String^ portName;
	int baudRate = 9600;
	portName = "COM4";
	// arduino settings
	SerialPort^ arduino;
	arduino = gcnew SerialPort(portName, baudRate);
	// open port
	try
	{
		arduino->Open();

		int i;
		for (i = 0; i < solutionLength1; i++)
		{
			// Get move
			answer = Cube::NameOfMove(TranslateMove(solutionMoves1[i], solutionPowers1[i], 0));
			// Parse to a,b,c,...r
			arduino->WriteLine(arduinoParser(answer));
			// Wait for arduino to return 1
			while (arduino->ReadLine() != "1") {}
		}
		for (i = 0; i < solutionLength2; i++)
		{
			answer = Cube::NameOfMove(TranslateMove(solutionMoves2[i], solutionPowers2[i], 1));
			arduino->WriteLine(arduinoParser(answer));
			while (arduino->ReadLine() != "1") {}
		}
		// close port to arduino
		arduino->Close();
	}
	catch (IO::IOException^ e)
	{
		Console::WriteLine(e->GetType()->Name + ": Port is not ready");
	}
	catch (ArgumentException^ e)
Esempio n. 7
0
void CcdrawDoc::TranslateMove(double dx, double dy, int EditAction)
{
	int i;

	if(EditAction==0)
	{
		for(i=0;i<nodelist.GetSize();i++)
		{
			if(nodelist[i].IsSelected==TRUE){
				nodelist[i].x+=dx;
				nodelist[i].y+=dy;
			}
		}
		EnforcePSLG();
		return;
	}

	if(EditAction==1)
	{
		for(i=0;i<linelist.GetSize();i++)
		{
			if(linelist[i].IsSelected==TRUE){
				nodelist[linelist[i].n0].IsSelected=TRUE;
				nodelist[linelist[i].n1].IsSelected=TRUE;
			}
		}
		TranslateMove(dx,dy,0);
		return;
	}

	if(EditAction==2)
	{
		for(i=0;i<blocklist.GetSize();i++)
		{
			if(blocklist[i].IsSelected==TRUE){
				blocklist[i].x+=dx;
				blocklist[i].y+=dy;
			}
		}
		EnforcePSLG();
		return;
	}

	if(EditAction==3)
	{
		for(i=0;i<arclist.GetSize();i++)
		{
			if(arclist[i].IsSelected==TRUE){
				nodelist[arclist[i].n0].IsSelected=TRUE;
				nodelist[arclist[i].n1].IsSelected=TRUE;
			}
		}
		TranslateMove(dx,dy,0);
		return;
	}

	if(EditAction==4)
	{
		for(i=0;i<linelist.GetSize();i++)
		{
			if(linelist[i].IsSelected==TRUE){
				nodelist[linelist[i].n0].IsSelected=TRUE;
				nodelist[linelist[i].n1].IsSelected=TRUE;
			}
		}
		
		for(i=0;i<arclist.GetSize();i++)
		{
			if(arclist[i].IsSelected==TRUE){
				nodelist[arclist[i].n0].IsSelected=TRUE;
				nodelist[arclist[i].n1].IsSelected=TRUE;
			}
		}
		
		for(i=0;i<nodelist.GetSize();i++)
		{
			if(nodelist[i].IsSelected==TRUE){
				nodelist[i].x+=dx;
				nodelist[i].y+=dy;
			}
		}

		for(i=0;i<blocklist.GetSize();i++)
		{
			if(blocklist[i].IsSelected==TRUE){
				blocklist[i].x+=dx;
				blocklist[i].y+=dy;
			}
		}
		
		EnforcePSLG();
		return;
		
	}


}