<commit_before>#include "robocup-py.hpp"
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <string>
#include <sstream>

using namespace boost::python;

#include <Geometry2d/Point.hpp>
#include <Geometry2d/Rect.hpp>
#include <Robot.hpp>
#include <SystemState.hpp>
#include <protobuf/LogFrame.pb.h>


//	this is here so boost can work with std::shared_ptr
template<class T> T * get_pointer( std::shared_ptr<T> const& p) {
	return p.get();
}

std::string Point_repr(Geometry2d::Point *thiss) {
	std::ostringstream ss;
	ss << "Point(";
	ss << thiss->x;
	ss << ", ";
	ss << thiss->y;
	ss << ")";
	
	std::string repr(ss.str());
	return repr;
}

std::string Robot_repr(Robot *thiss) {
	std::ostringstream ss;
	ss << "<Robot ";
	ss << (thiss->self() ? "us[" : "them[");
	ss << thiss->shell();
	ss << "], pos=";
	ss << Point_repr(&(thiss->pos));
	ss << ">";

	std::string repr(ss.str());
	return repr;
}


void OurRobot_move_to(OurRobot *thiss, Geometry2d::Point *to) {
	thiss->move(*to);
}

bool Rect_contains_rect(Geometry2d::Rect *thiss, Geometry2d::Rect *other) {
	return thiss->contains(*other);
}

bool Rect_contains_point(Geometry2d::Rect *thiss, Geometry2d::Point *pt) {
	return thiss->contains(*pt);
}


/**
 * The code in this block wraps up c++ classes and makes them
 * accessible to python in the 'robocup' module.
 */
BOOST_PYTHON_MODULE(robocup)
{
	class_<Geometry2d::Point>("Point", init<float, float>())
		.def_readwrite("x", &Geometry2d::Point::x)
		.def_readwrite("y", &Geometry2d::Point::y)
		.def(self - self)
		.def(self + self)
		.def("mag", &Geometry2d::Point::mag)
		.def("__repr__", &Point_repr)
	;

	class_<Geometry2d::Segment>("Segment", init<Geometry2d::Point, Geometry2d::Point>())
		.def("center", &Geometry2d::Segment::center)
	;

	class_<Geometry2d::Rect>("Rect", init<Geometry2d::Point, Geometry2d::Point>())
		.def("contains_rect", &Rect_contains_rect)
		.def("contains_point", &Rect_contains_point)
		.def("min_x", &Geometry2d::Rect::minx)
		.def("min_y", &Geometry2d::Rect::miny)
		.def("max_x", &Geometry2d::Rect::maxx)
		.def("max_y", &Geometry2d::Rect::maxy)
		.def("near_point", &Geometry2d::Rect::nearPoint)
		.def("intersects_rect", &Geometry2d::intersects)
	;

	//		I'm holding off for now because GameState needs some attention on the C++
	//		side of things before we spread its shortcomings into the python world too...
	class_<GameState>("GameState")
		.def_readonly("our_score", &GameState::ourScore)<commit_msg>fixed Rect python wrapper<commit_after>#include "robocup-py.hpp"
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <string>
#include <sstream>

using namespace boost::python;

#include <Geometry2d/Point.hpp>
#include <Geometry2d/Rect.hpp>
#include <Robot.hpp>
#include <SystemState.hpp>
#include <protobuf/LogFrame.pb.h>


//	this is here so boost can work with std::shared_ptr
template<class T> T * get_pointer( std::shared_ptr<T> const& p) {
	return p.get();
}

std::string Point_repr(Geometry2d::Point *thiss) {
	std::ostringstream ss;
	ss << "Point(";
	ss << thiss->x;
	ss << ", ";
	ss << thiss->y;
	ss << ")";
	
	std::string repr(ss.str());
	return repr;
}

std::string Robot_repr(Robot *thiss) {
	std::ostringstream ss;
	ss << "<Robot ";
	ss << (thiss->self() ? "us[" : "them[");
	ss << thiss->shell();
	ss << "], pos=";
	ss << Point_repr(&(thiss->pos));
	ss << ">";

	std::string repr(ss.str());
	return repr;
}


void OurRobot_move_to(OurRobot *thiss, Geometry2d::Point *to) {
	thiss->move(*to);
}

bool Rect_contains_rect(Geometry2d::Rect *thiss, Geometry2d::Rect *other) {
	return thiss->contains(*other);
}

bool Rect_contains_point(Geometry2d::Rect *thiss, Geometry2d::Point *pt) {
	return thiss->contains(*pt);
}


/**
 * The code in this block wraps up c++ classes and makes them
 * accessible to python in the 'robocup' module.
 */
BOOST_PYTHON_MODULE(robocup)
{
	class_<Geometry2d::Point>("Point", init<float, float>())
		.def_readwrite("x", &Geometry2d::Point::x)
		.def_readwrite("y", &Geometry2d::Point::y)
		.def(self - self)
		.def(self + self)
		.def("mag", &Geometry2d::Point::mag)
		.def("__repr__", &Point_repr)
	;

	class_<Geometry2d::Segment>("Segment", init<Geometry2d::Point, Geometry2d::Point>())
		.def("center", &Geometry2d::Segment::center)
	;

	class_<Geometry2d::Rect>("Rect", init<Geometry2d::Point, Geometry2d::Point>())
		.def("contains_rect", &Rect_contains_rect)
		.def("contains_point", &Rect_contains_point)
		.def("min_x", &Geometry2d::Rect::minx)
		.def("min_y", &Geometry2d::Rect::miny)
		.def("max_x", &Geometry2d::Rect::maxx)
		.def("max_y", &Geometry2d::Rect::maxy)
		.def("near_point", &Geometry2d::Rect::nearPoint)
		.def("intersects_rect", &Geometry2d::Rect::intersects)
	;

	//		I'm holding off for now because GameState needs some attention on the C++
	//		side of things before we spread its shortcomings into the python world too...
	class_<GameState>("GameState")
		.def_readonly("our_score", &GameState::ourScore)
{'fraction_non_alphanumeric': 0.18953722334004025, 'fraction_numerical': 0.01006036217303823, 'mean_word_length': 5.663538873994638, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2739777', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1878, 'n_words': 374}