Ejemplo n.º 1
0
void ad_grid(stream<axiRawValues> &inData, stream<axiValues> &outData){
	#pragma HLS pipeline II=1 enable_flush

	// Current Raw Values
	axiRawValues currRawValues = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

	// Current Values
	axiValues currValues = {0, 0, 0, 0, 0, 0};

	// Read In Values
	inData.read(currRawValues);

	MATHTYPE det_det_prev 	= currRawValues.det_det_prev;
	MATHTYPE det_ref_prev 	= currRawValues.det_ref_prev;
	MATHTYPE det_curr_prev 	= currRawValues.det_curr_prev;

	MATHTYPE ref_det_prev	= currRawValues.ref_det_prev;
	MATHTYPE ref_ref_prev	= currRawValues.ref_ref_prev;
	MATHTYPE ref_curr_prev	= currRawValues.ref_curr_prev;

	MATHTYPE det_det_curr	= currRawValues.det_det_curr;
	MATHTYPE det_ref_curr	= currRawValues.det_ref_curr;
	MATHTYPE det_curr_curr	= currRawValues.det_curr_curr;

	MATHTYPE ref_det_curr	= currRawValues.ref_det_curr;
	MATHTYPE ref_ref_curr	= currRawValues.ref_ref_curr;
	MATHTYPE ref_curr_curr	= currRawValues.ref_curr_curr;

	// Remove det_window[0], det_window[1]
	MATHTYPE det_rm;
	#pragma HLS RESOURCE variable=det_rm core=AddSubnS
	det_rm = (det_det_prev - ref_det_prev);

	// Remove ref_window[0], ref_window[1]
	MATHTYPE ref_rm;
	#pragma HLS RESOURCE variable=ref_rm core=AddSubnS
	ref_rm = (det_ref_prev - ref_ref_prev);

	// Remove currWord.data, det_window[DET_W-2]
	MATHTYPE curr_rm;
	#pragma HLS RESOURCE variable=curr_rm core=AddSubnS
	curr_rm = (det_curr_prev - ref_curr_prev);

	// Add det_window[0], det_window[1]
	MATHTYPE det_add;
	#pragma HLS RESOURCE variable=det_add core=AddSubnS
	det_add = (det_det_curr - ref_det_curr);

	// Add ref_window[0], ref_window[1]
	MATHTYPE ref_add;
	#pragma HLS RESOURCE variable=ref_add core=AddSubnS
	ref_add = (det_ref_curr - ref_ref_curr);

	// Add currWord.data, det_window[DET_W-2]
	MATHTYPE curr_add;
	#pragma HLS RESOURCE variable=curr_add core=AddSubnS
	curr_add = (det_curr_curr - ref_curr_curr);

	currValues.det_rm 	= det_rm;
	currValues.ref_rm 	= ref_rm;
	currValues.curr_rm 	= curr_rm;
	currValues.det_add 	= det_add;
	currValues.ref_add 	= ref_add;
	currValues.curr_add = curr_add;

	outData.write(currValues);

}
Ejemplo n.º 2
0
void MappedRAM::read(const stream& memory) {
  memory.read(data_, min(memory.size(), size_));
}
Ejemplo n.º 3
0
bool FuegoAssistant::estimateTerritory(int color)
{
	string command;
	string readLine;
	//uct_param_globalsearch territory_statistics 1
	if(!setTerritoryParam){
		sendCommandWithEmptyResponse("uct_param_globalsearch territory_statistics 1", readLine);
		setTerritoryParam = true;
	}

	//the problem here is that i need to generate a move from fuego first before i can see the territory stats
	//first, disable tree search (node threhold normally = 3)
	//uct_param_search expand_threshold 10000000   
	sendCommandWithEmptyResponse("uct_param_search expand_threshold 100000000", readLine);

	//disable forced player move
	sendCommandWithEmptyResponse("uct_param_player forced_opening_moves 0", readLine);
	
	
	//if there are book moves, should probably disable book first
	command = "book_moves";
	writeToFuego << command<<endl;
	writeToFuego.flush();
	do{
		getline(readFromFuego, readLine);
	}while(readLine[0]!='=');	
	vector<string> l;
	if(helper::split(readLine, l, ' ') >1)
	{
		//needs to remove book
		sendCommandWithEmptyResponse("book_clear", readLine);
		bookLoaded =false;
	}
	addStone_mutex.lock();
	//generate a fake move from fuego
	sendCommandWithEmptyResponse(string("genmove ")+ helper::convert_int_color(color), readLine);
	//undo the move
	sendCommandWithEmptyResponse("undo", readLine);
	addStone_mutex.unlock();
	//get territory stats
	if(!sendCommandWithEmptyResponse("uct_stat_territory", readLine)){
		//this problem should be fixed
		fprintf(stderr, "[FuegoAssistant]something is wrong probably cuz fuego uses forced opening moves\n");
		for(int i=0; i<19*19; i++){
			estimateScore[i] = 0;
		}
		return false;
	}

	
	//save the result
	for(int i=18; i>=0; i--){
		getline(readFromFuego, readLine);

		//cout<<"return: "<<endl<<readLine<<endl<<"END"<<endl;
		//cout <<"is this okay?"<<endl;
		helper::split(readLine, l, ' ');

		int j=0;
		for(int z=0; z<l.size(); z++)
		{
			if(l[z][0] != ' '){
				estimateScore[i*19+j] = ::atof(l[z].c_str());
				j++;
			}

		}
	}	

	
	return true;

}
Ejemplo n.º 4
0
void Interface::save(unsigned id, const stream &stream) {
  if(id == ID::RAM) {
    stream.write(cartridge.ram_data(), cartridge.ram_size());
  }
}