Generated by Cython 0.29.13
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: CACompute.cpp
+001: # distutils: language=c++
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
002: """
003: cdef extern from "Compute.cpp":
004: cdef struct compute_return:
005: int lower_x, lower_y, upper_x, upper_y
006: unordered_map[pair[int, int], int] dict_grid
007: unordered_set[pair[int, int]] cells_changed
008:
009: cdef compute_return compute(vector[pair[int, int]] neighbourhood, bool first,
010: unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
011: int upper_y, unordered_map[pair[int, int], int] copy_grid,
012: unordered_map[pair[int, int], int] dict_grid)
013:
014:
015: cpdef pycompute(vector[pair[int, int]] neighbourhood, bool first,
016: unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
017: int upper_y, unordered_map[pair[int, int], int] copy_grid,
018: unordered_map[pair[int, int], int] dict_grid):
019:
020: cdef compute_return ans = compute(neighbourhood, first, cells_changed, lower_x, upper_x, lower_y, upper_y,
021: copy_grid, dict_grid)
022:
023: return ans.lower_x, ans.lower_y, ans.upper_x, ans.upper_y, ans.cells_changed, ans.dict_grid
024:
025:
026: """
027:
+028: import importlib
__pyx_t_1 = __Pyx_Import(__pyx_n_s_importlib, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_importlib, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+029: import transFunc
__pyx_t_1 = __Pyx_Import(__pyx_n_s_transFunc, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_transFunc, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
030: from libcpp.vector cimport vector
031: from libcpp.pair cimport pair
032: from libcpp.map cimport map
033: from libcpp.string cimport string
034: from libcpp.unordered_map cimport unordered_map
035: from libcpp.unordered_set cimport unordered_set
+036: from CAComputeParse.Bounds import correct_coor
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_correct_coor); __Pyx_GIVEREF(__pyx_n_s_correct_coor); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_correct_coor); __pyx_t_2 = __Pyx_Import(__pyx_n_s_CAComputeParse_Bounds, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_correct_coor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_correct_coor, __pyx_t_1) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
037:
038: cdef extern from "compute.cpp":
039: pass
040:
041:
042: cdef unordered_map[pair[int, int], int] depends_cache
043: cdef map[pair[vector[int], int], int] transition_func_cache
+044: cdef int alternating_period2 = transFunc.alternating_period
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_9CACompute_alternating_period2 = __pyx_t_3;
045: cdef int x_bound, y_bound
046: cdef string bound_type
047:
+048: cpdef void reload():
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static void __pyx_f_9CACompute_reload(CYTHON_UNUSED int __pyx_skip_dispatch) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload", 0);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_WriteUnraisable("CACompute.reload", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_L0:;
__Pyx_RefNannyFinishContext();
}
/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload (wrapper)", 0);
__pyx_r = __pyx_pf_9CACompute_reload(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_9CACompute_reload(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_void_to_None(__pyx_f_9CACompute_reload(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("CACompute.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
049: global depends_cache, transition_func_cache, alternating_period2
+050: importlib.reload(transFunc)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_importlib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reload); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+051: depends_cache.clear()
__pyx_v_9CACompute_depends_cache.clear();
+052: transition_func_cache.clear()
__pyx_v_9CACompute_transition_func_cache.clear();
+053: alternating_period2 = transFunc.alternating_period
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_9CACompute_alternating_period2 = __pyx_t_5;
054:
+055: cpdef set_bounds(int x, int y, string type1):
static PyObject *__pyx_pw_9CACompute_3set_bounds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9CACompute_set_bounds(int __pyx_v_x, int __pyx_v_y, std::string __pyx_v_type1, CYTHON_UNUSED int __pyx_skip_dispatch) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("set_bounds", 0);
/* … */
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_3set_bounds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_9CACompute_3set_bounds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
int __pyx_v_x;
int __pyx_v_y;
std::string __pyx_v_type1;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("set_bounds (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_type1,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("set_bounds", 1, 3, 3, 1); __PYX_ERR(0, 55, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type1)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("set_bounds", 1, 3, 3, 2); __PYX_ERR(0, 55, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_bounds") < 0)) __PYX_ERR(0, 55, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
}
__pyx_v_x = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_x == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L3_error)
__pyx_v_y = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L3_error)
__pyx_v_type1 = __pyx_convert_string_from_py_std__in_string(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("set_bounds", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 55, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("CACompute.set_bounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_9CACompute_2set_bounds(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_type1);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_9CACompute_2set_bounds(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_x, int __pyx_v_y, std::string __pyx_v_type1) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("set_bounds", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_f_9CACompute_set_bounds(__pyx_v_x, __pyx_v_y, __pyx_v_type1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("CACompute.set_bounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
056: global x_bound, y_bound, bound_type
+057: x_bound, y_bound = x, y
__pyx_t_1 = __pyx_v_x; __pyx_t_2 = __pyx_v_y; __pyx_v_9CACompute_x_bound = __pyx_t_1; __pyx_v_9CACompute_y_bound = __pyx_t_2;
+058: bound_type = type1
__pyx_v_9CACompute_bound_type = __pyx_v_type1;
059:
+060: cpdef compute(vector[pair[int, int]] neighbourhood,
static PyObject *__pyx_pw_9CACompute_5compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9CACompute_compute(std::vector<std::pair<int,int> > __pyx_v_neighbourhood, std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed, std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid, int __pyx_v_generations, CYTHON_UNUSED int __pyx_skip_dispatch) {
std::vector<int> __pyx_v_neighbours;
std::unordered_set<std::pair<int,int> > __pyx_v_cells_to_check;
int __pyx_v_ans;
std::pair<int,int> __pyx_v_coordinates;
std::pair<int,int> __pyx_v_coordinates2;
std::pair<int,int> __pyx_v_neighbour;
std::pair<int,int> __pyx_v_coor;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute", 0);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_XDECREF(__pyx_t_13);
__Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_5compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_9CACompute_5compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
std::vector<std::pair<int,int> > __pyx_v_neighbourhood;
std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed;
std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid;
std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid;
int __pyx_v_generations;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_neighbourhood,&__pyx_n_s_cells_changed,&__pyx_n_s_copy_grid,&__pyx_n_s_dict_grid,&__pyx_n_s_generations,0};
PyObject* values[5] = {0,0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_neighbourhood)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cells_changed)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 1); __PYX_ERR(0, 60, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_copy_grid)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 2); __PYX_ERR(0, 60, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dict_grid)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 3); __PYX_ERR(0, 60, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_generations)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 4); __PYX_ERR(0, 60, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute") < 0)) __PYX_ERR(0, 60, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
}
__pyx_v_neighbourhood = __pyx_convert_vector_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L3_error)
__pyx_v_cells_changed = __pyx_convert_unordered_set_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error)
__pyx_v_copy_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L3_error)
__pyx_v_dict_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L3_error)
__pyx_v_generations = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_generations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 60, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_9CACompute_4compute(__pyx_self, __pyx_v_neighbourhood, __pyx_v_cells_changed, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_9CACompute_4compute(CYTHON_UNUSED PyObject *__pyx_self, std::vector<std::pair<int,int> > __pyx_v_neighbourhood, std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed, std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid, int __pyx_v_generations) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_f_9CACompute_compute(__pyx_v_neighbourhood, __pyx_v_cells_changed, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
061: unordered_set[pair[int, int]] cells_changed,
062: unordered_map[pair[int, int], int] copy_grid, unordered_map[pair[int, int], int] dict_grid,
063: int generations):
064:
065: cdef vector[int] neighbours
+066: neighbours.reserve(neighbourhood.size() + 1)
__pyx_v_neighbours.reserve((__pyx_v_neighbourhood.size() + 1));
067:
068: cdef unordered_set[pair[int, int]] cells_to_check
069:
070: cdef int i, j
071: cdef int ans
072: cdef pair[int, int] coordinates, coordinates2
073: cdef pair[int, int] neighbour
074:
+075: for coor in cells_changed:
__pyx_t_1 = __pyx_v_cells_changed.begin();
for (;;) {
if (!(__pyx_t_1 != __pyx_v_cells_changed.end())) break;
__pyx_t_2 = *__pyx_t_1;
++__pyx_t_1;
__pyx_v_coor = __pyx_t_2;
/* … */
}
+076: for neighbour in neighbourhood:
__pyx_t_3 = __pyx_v_neighbourhood.begin();
for (;;) {
if (!(__pyx_t_3 != __pyx_v_neighbourhood.end())) break;
__pyx_t_2 = *__pyx_t_3;
++__pyx_t_3;
__pyx_v_neighbour = __pyx_t_2;
/* … */
}
+077: coordinates.first = coor.first + neighbour.first
__pyx_v_coordinates.first = (__pyx_v_coor.first + __pyx_v_neighbour.first);
+078: coordinates.second = coor.second + neighbour.second
__pyx_v_coordinates.second = (__pyx_v_coor.second + __pyx_v_neighbour.second);
+079: cells_to_check.insert(coordinates)
(void)(__pyx_v_cells_to_check.insert(__pyx_v_coordinates));
080:
+081: cells_to_check.insert(coor)
(void)(__pyx_v_cells_to_check.insert(__pyx_v_coor));
082:
+083: if alternating_period2 > 1:
__pyx_t_4 = ((__pyx_v_9CACompute_alternating_period2 > 1) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L7;
}
+084: if generations % (alternating_period2 - 1) == 0:
__pyx_t_4 = (((__pyx_v_generations % (__pyx_v_9CACompute_alternating_period2 - 1)) == 0) != 0);
if (__pyx_t_4) {
/* … */
}
+085: cells_changed.clear()
__pyx_v_cells_changed.clear();
086: else:
+087: cells_changed.clear()
/*else*/ {
__pyx_v_cells_changed.clear();
}
__pyx_L7:;
088:
+089: for coordinates in cells_to_check:
__pyx_t_1 = __pyx_v_cells_to_check.begin();
for (;;) {
if (!(__pyx_t_1 != __pyx_v_cells_to_check.end())) break;
__pyx_t_2 = *__pyx_t_1;
++__pyx_t_1;
__pyx_v_coordinates = __pyx_t_2;
/* … */
}
+090: coordinates = correct_coor(coordinates, bound_type, x_bound, y_bound)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_correct_coor); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __pyx_convert_pair_to_py_int____int(__pyx_v_coordinates); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_9CACompute_bound_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_9CACompute_x_bound); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_9CACompute_y_bound); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_13 = PyTuple_New(4+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_12, __pyx_t_10); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __pyx_convert_pair_from_py_int__and_int(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_coordinates = __pyx_t_2;
091:
+092: neighbours.clear()
__pyx_v_neighbours.clear();
+093: ans = -1
__pyx_v_ans = -1;
094:
+095: if copy_grid.find(coordinates) == copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) == __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L11;
}
+096: if depends_cache.find(pair[int, int] (0, generations % alternating_period2)) == \
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 96, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_depends_cache.find(__pyx_t_2) == __pyx_v_9CACompute_depends_cache.end()) != 0);
/* … */
if (__pyx_t_4) {
/* … */
goto __pyx_L12;
}
097: depends_cache.end():
+098: ans = transFunc.depend_on_neighbours(0, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_int_0, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_int_0, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_12, __pyx_int_0); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_12, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_12;
+099: depends_cache[pair[int, int] (0, generations % alternating_period2)] = ans
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 99, __pyx_L1_error)
}
(__pyx_v_9CACompute_depends_cache[__pyx_t_2]) = __pyx_v_ans;
100: else:
+101: ans = depends_cache[pair[int, int] (0, generations % alternating_period2)]
/*else*/ {
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 101, __pyx_L1_error)
}
__pyx_v_ans = (__pyx_v_9CACompute_depends_cache[__pyx_t_2]);
}
__pyx_L12:;
102: else:
+103: if depends_cache.find(pair[int, int] (copy_grid[coordinates],
/*else*/ {
/* … */
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 103, __pyx_L1_error)
}
/* … */
if (__pyx_t_4) {
/* … */
goto __pyx_L13;
}
+104: generations % alternating_period2)) == \
__pyx_t_4 = ((__pyx_v_9CACompute_depends_cache.find(__pyx_t_2) == __pyx_v_9CACompute_depends_cache.end()) != 0);
105: depends_cache.end():
+106: ans = transFunc.depend_on_neighbours(copy_grid[coordinates], generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyInt_From_int((__pyx_v_copy_grid[__pyx_v_coordinates])); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_13, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_13, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_12, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_12, __pyx_t_6); __pyx_t_13 = 0; __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_12;
+107: depends_cache[pair[int, int] (copy_grid[coordinates], generations % alternating_period2)] = ans
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 107, __pyx_L1_error)
}
(__pyx_v_9CACompute_depends_cache[__pyx_t_2]) = __pyx_v_ans;
108: else:
+109: ans = depends_cache[pair[int, int] (copy_grid[coordinates], generations % alternating_period2)]
/*else*/ {
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 109, __pyx_L1_error)
}
__pyx_v_ans = (__pyx_v_9CACompute_depends_cache[__pyx_t_2]);
}
__pyx_L13:;
}
__pyx_L11:;
110:
+111: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+112: for neighbour in neighbourhood:
__pyx_t_3 = __pyx_v_neighbourhood.begin();
for (;;) {
if (!(__pyx_t_3 != __pyx_v_neighbourhood.end())) break;
__pyx_t_2 = *__pyx_t_3;
++__pyx_t_3;
__pyx_v_neighbour = __pyx_t_2;
/* … */
}
+113: coordinates2 = correct_coor(pair[int, int] (coordinates.first + neighbour.first,
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_correct_coor); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); /* … */ try { __pyx_t_2 = std::pair<int,int> ((__pyx_v_coordinates.first + __pyx_v_neighbour.first), (__pyx_v_coordinates.second + __pyx_v_neighbour.second)); } catch(...) { __Pyx_CppExn2PyErr(); __PYX_ERR(0, 113, __pyx_L1_error) } /* … */ __pyx_t_8 = __pyx_convert_pair_to_py_int____int(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __pyx_t_2 = __pyx_convert_pair_from_py_int__and_int(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_coordinates2 = __pyx_t_2;
114: coordinates.second + neighbour.second),
+115: bound_type, x_bound, y_bound)
__pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_9CACompute_bound_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_9CACompute_x_bound); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_9CACompute_y_bound); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_8, __pyx_t_6, __pyx_t_13, __pyx_t_10}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_8, __pyx_t_6, __pyx_t_13, __pyx_t_10}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_11 = PyTuple_New(4+__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_12, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_12, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_12, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_12, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_6 = 0; __pyx_t_13 = 0; __pyx_t_10 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+116: if copy_grid.find(coordinates2) != copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates2) != __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L17;
}
+117: neighbours.push_back(copy_grid[coordinates2])
try {
__pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates2]));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 117, __pyx_L1_error)
}
118: else:
+119: neighbours.push_back(0)
/*else*/ {
try {
__pyx_v_neighbours.push_back(0);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 119, __pyx_L1_error)
}
}
__pyx_L17:;
120:
+121: if copy_grid.find(coordinates) != copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) != __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L18;
}
+122: neighbours.push_back(copy_grid[coordinates])
try {
__pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates]));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 122, __pyx_L1_error)
}
+123: if transition_func_cache.find(
if (__pyx_t_4) {
/* … */
goto __pyx_L19;
}
+124: pair[vector[int], int] (neighbours, generations % alternating_period2)) == \
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 124, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_transition_func_cache.find(__pyx_t_14) == __pyx_v_9CACompute_transition_func_cache.end()) != 0);
125: transition_func_cache.end():
+126: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+127: ans = transFunc.transition_func(neighbours, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_13 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_9, __pyx_t_10}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_9, __pyx_t_10}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_12, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_12, __pyx_t_10); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_12;
128: transition_func_cache[
+129: pair[vector[int], int] (neighbours, generations % alternating_period2)] = ans
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 129, __pyx_L1_error)
}
(__pyx_v_9CACompute_transition_func_cache[__pyx_t_14]) = __pyx_v_ans;
130: else:
+131: if ans == -1: ans = transition_func_cache[
/*else*/ {
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
__pyx_v_ans = (__pyx_v_9CACompute_transition_func_cache[__pyx_t_14]);
}
}
__pyx_L19:;
+132: pair[vector[int], int] (neighbours, generations % alternating_period2)]
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 132, __pyx_L1_error)
}
133:
+134: if ans == 0:
__pyx_t_4 = ((__pyx_v_ans == 0) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L22;
}
+135: dict_grid.erase(coordinates)
(void)(__pyx_v_dict_grid.erase(__pyx_v_coordinates));
+136: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+137: elif ans != copy_grid[coordinates]:
__pyx_t_4 = ((__pyx_v_ans != (__pyx_v_copy_grid[__pyx_v_coordinates])) != 0);
if (__pyx_t_4) {
/* … */
}
__pyx_L22:;
+138: dict_grid[coordinates] = ans
(__pyx_v_dict_grid[__pyx_v_coordinates]) = __pyx_v_ans;
+139: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
140: else:
+141: neighbours.push_back(0)
/*else*/ {
try {
__pyx_v_neighbours.push_back(0);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 141, __pyx_L1_error)
}
+142: if transition_func_cache.find(
if (__pyx_t_4) {
/* … */
goto __pyx_L23;
}
+143: pair[vector[int], int] (neighbours, generations % alternating_period2)) == \
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 143, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_transition_func_cache.find(__pyx_t_14) == __pyx_v_9CACompute_transition_func_cache.end()) != 0);
144: transition_func_cache.end():
+145: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+146: ans = transFunc.transition_func(neighbours, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10); __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_12;
147: transition_func_cache[
+148: pair[vector[int], int] (neighbours, generations % alternating_period2)] = ans
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 148, __pyx_L1_error)
}
(__pyx_v_9CACompute_transition_func_cache[__pyx_t_14]) = __pyx_v_ans;
149: else:
+150: if ans == -1: ans = transition_func_cache[
/*else*/ {
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
__pyx_v_ans = (__pyx_v_9CACompute_transition_func_cache[__pyx_t_14]);
}
}
__pyx_L23:;
+151: pair[vector[int], int] (neighbours, generations % alternating_period2)]
try {
__pyx_t_14 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 151, __pyx_L1_error)
}
152:
+153: if ans != 0:
__pyx_t_4 = ((__pyx_v_ans != 0) != 0);
if (__pyx_t_4) {
/* … */
}
}
__pyx_L18:;
+154: dict_grid.insert(pair[pair[int, int], int] (coordinates, ans))
try {
__pyx_t_15 = std::pair<std::pair<int,int> ,int> (__pyx_v_coordinates, __pyx_v_ans);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 154, __pyx_L1_error)
}
(void)(__pyx_v_dict_grid.insert(__pyx_t_15));
+155: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
156:
+157: return cells_changed, dict_grid
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __pyx_convert_unordered_set_to_py_std_3a__3a_pair_3c_int_2c_int_3e___(__pyx_v_cells_changed); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_convert_unordered_map_to_py_std_3a__3a_pair_3c_int_2c_int_3e_______int(__pyx_v_dict_grid); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0;