예제 #1
0
	void field_t::get_empty_around(const point& c,points_t& res,int bound_size) const
	{
		res.resize(0);
		for(int y=c.y-bound_size;y<=c.y+bound_size;y++)
		for(int x=c.x-bound_size;x<=c.x+bound_size;x++)
		{
			point p(x,y);
			if(at(p)==st_empty)
				res.push_back(p);
		}

		std::sort(res.begin(),res.end(),less_point_pr());
		res.erase(std::unique(res.begin(),res.end()),res.end());
	}
예제 #2
0
	void field_t::get_empty_around(points_t& res,int bound_size) const
	{
		res.resize(0);
		for(unsigned i=0;i<steps.size();i++)
		{
			const step_t& st=steps[i];
			for(int y=st.y-bound_size;y<=st.y+bound_size;y++)
			for(int x=st.x-bound_size;x<=st.x+bound_size;x++)
			{
				point p(x,y);
				if(at(p)==st_empty)
					res.push_back(p);
			}
		}

		std::sort(res.begin(),res.end(),less_point_pr());
		res.erase(std::unique(res.begin(),res.end()),res.end());
	}
	void bin2points(const data_t& bin,points_t& pts)
	{
		if((bin.size()%2)!=0)
			throw std::runtime_error("bin2points(): (bin.size()%2)!=0");

		pts.resize(bin.size()/2);

		for(unsigned i=0;i<pts.size();i++)
		{
			point& p=pts[i];

			char x=*reinterpret_cast<const unsigned char*>(&bin[i*2]);
			char y=*reinterpret_cast<const unsigned char*>(&bin[i*2+1]);

			p.x=x;
			p.y=y;
		}
	}