python
-
boost python + lambda프로그래밍/c++ 2015. 11. 20. 11:01
Boost python + lambda 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970// 실패 script_dict["lobby_class"] = py::class_("lobby_class", py::no_init) .def("name", &lobby::name) .def("async_accept", [&lobby_](const std::string addr, unsigned short port){ … }) ; // 실패auto async_accept = [&lobby_](const std::string& addr, ..
-
pyd 파일 없이 c++과 python 연동하기프로그래밍/c++ 2015. 11. 20. 05:44
pyd 파일 만들지 않고 c++과 Python 연동하기 서버 코드에 일부 변동될 수 있는 부분들을 스크립트로 빼고 싶었다. 유저 accept를 할 포트, 최대 유저 수, 방 인스턴스 수 등등.. 부터,특정 상황마다 콜백이 불려서 뭔가를 체크하는 간단한 행동 정도면 오케이.그리고 석찬이 형이 테스트 할 부분을 스크립트로 빼면, 형도 부담 없이 이런저런 수치를 바꿔보며 테스트를 할 수도 있고, 나는 다른 작업을 할 수 있으니까 편할 것이다. 고작 졸업 프로젝트 정도인데? 라고도 생각할 사람도 있겠지만, 다른 스킬들을 익혀봐야 나쁠 거 없으니까. 여튼, 단순히 변수의 값을 설정하는 정도라면 텍스트 파일 정도로만 빼도 상관이 없었지만 약간의 처리 로직까지 첨부가 되어야한다면 텍스트 파일 정도로는 부족한 걸 사실..
-
[c++] std::vector를 boost::python::list로프로그래밍/c++ 2015. 11. 19. 11:41
12345678910template boost::python::list vector_to_pylist(const std::vector& v){ boost::python::object get_itor = boost::python::iterator(); boost::python::object iter = get_itor(v); py::list pylist(iter); return pylist;} Colored by Color Scriptercs 참고 http://stackoverflow.com/questions/6157409/stdvector-to-boostpythonlist
-
[python] 야구 게임프로그래밍/코드 조각 2015. 11. 15. 10:41
#-*- coding: utf-8 -*- import random class text_baseball_game: maxround = int() nummax = int() numnumbers = int() nums = list() # maxround: 최대 게임의 라운드입니다. # nummax: 맞춰야 할 수의 최대값 입니다. # numnumbers 맞춰야 할 수의 개수입니다. def __init__(self, maxround: int = 10, nummax: int = 9, numnumbers: int = 3): if(nummax < numnumbers): raise ValueError("numnumbers too big") self.maxround = maxround self.nummax = numma..