Generated by Cython 0.29.32
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: monopoly.cpp
+001: # cython: language_level=3
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
002: # distutils: language = c++
003:
004: from libcpp.set cimport set
005:
+006: from random import random
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_random); __Pyx_GIVEREF(__pyx_n_s_random); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_random); __pyx_t_2 = __Pyx_Import(__pyx_n_s_random, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __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_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
007:
+008: cdef enum:
enum { __pyx_e_3app_10cython_ext_8monopoly_JAIL = 40 };
009: JAIL = 40
010:
+011: cdef class Monopoly():
struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly { PyObject_HEAD struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *__pyx_vtab; int num_spaces; std::set<int> community_squares; std::set<int> chance_squares; PyObject *community_cards; PyObject *chance_cards; int roll_values[36]; std::set<int> double_indices; PyObject *community_deck; PyObject *chance_deck; PY_LONG_LONG results[41]; PY_LONG_LONG total_turns; int current_position; int doubles; }; struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly { PyObject *(*take_turns)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *, PY_LONG_LONG, int __pyx_skip_dispatch); int (*roll_dice)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*move_spaces)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *, int); PyObject *(*move_to)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *, int); PyObject *(*end_turn)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*move_to_utility)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*move_to_railroad)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*draw_community_chest)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*draw_chance)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *); PyObject *(*shuffle_deck)(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *, PyObject *); }; static struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *__pyx_vtabptr_3app_10cython_ext_8monopoly_Monopoly;
012: cdef int num_spaces
013: cdef set[int] community_squares # this is correct, but differs from maths.py # THIS IS WHERE THE DESCREPANCY
014: cdef set[int] chance_squares # this is correct, but differs from maths.py # IN PROBABILITIES COMES FROM
015: cdef list community_cards # Two cards change your position, the rest don't matter
016: cdef list chance_cards # 9 cards change your position
017: cdef int[36] roll_values # all possible combos of dice rolls
018: cdef set[int] double_indices # more efficient than rolling dice twice
019: cdef list community_deck
020: cdef list chance_deck
+021: cdef readonly long long[41] results
/* Python wrapper */ static PyObject *__pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_7results_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_7results_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_3app_10cython_ext_8monopoly_8Monopoly_7results___get__(((struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3app_10cython_ext_8monopoly_8Monopoly_7results___get__(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_carray_to_py_PY_LONG_LONG(__pyx_v_self->results, 41); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __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("app.cython_ext.monopoly.Monopoly.results.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
022: cdef long long total_turns
023: cdef int current_position
024: cdef int doubles
025:
+026: def __init__(self):
/* Python wrapper */ static int __pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; __pyx_r = __pyx_pf_3app_10cython_ext_8monopoly_8Monopoly___init__(((struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_3app_10cython_ext_8monopoly_8Monopoly___init__(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { CYTHON_UNUSED long __pyx_7genexpr__pyx_v_i; CYTHON_UNUSED long __pyx_8genexpr1__pyx_v_i; CYTHON_UNUSED long __pyx_8genexpr2__pyx_v_i; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+027: self.num_spaces = 40
__pyx_v_self->num_spaces = 40;
+028: self.community_squares = {2,17,33}
__pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PySet_Add(__pyx_t_1, __pyx_int_2) < 0) __PYX_ERR(0, 28, __pyx_L1_error) if (PySet_Add(__pyx_t_1, __pyx_int_17) < 0) __PYX_ERR(0, 28, __pyx_L1_error) if (PySet_Add(__pyx_t_1, __pyx_int_33) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __pyx_t_2 = __pyx_convert_set_from_py_int(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->community_squares = __pyx_t_2;
+029: self.chance_squares = {7,22,36}
__pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PySet_Add(__pyx_t_1, __pyx_int_7) < 0) __PYX_ERR(0, 29, __pyx_L1_error) if (PySet_Add(__pyx_t_1, __pyx_int_22) < 0) __PYX_ERR(0, 29, __pyx_L1_error) if (PySet_Add(__pyx_t_1, __pyx_int_36) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __pyx_t_2 = __pyx_convert_set_from_py_int(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->chance_squares = __pyx_t_2;
+030: self.community_cards = [0,JAIL] + [None for i in range(14)]
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_3app_10cython_ext_8monopoly_JAIL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_0); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_1 = 0; { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); for (__pyx_t_4 = 0; __pyx_t_4 < 14; __pyx_t_4+=1) { __pyx_7genexpr__pyx_v_i = __pyx_t_4; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)Py_None))) __PYX_ERR(0, 30, __pyx_L1_error) } } /* exit inner scope */ __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->community_cards); __Pyx_DECREF(__pyx_v_self->community_cards); __pyx_v_self->community_cards = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+031: self.chance_cards = [0,5,11,24,39,'U','R','B',JAIL] + [None for i in range(7)]
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_e_3app_10cython_ext_8monopoly_JAIL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_5); __Pyx_GIVEREF(__pyx_int_5); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_5); __Pyx_INCREF(__pyx_int_11); __Pyx_GIVEREF(__pyx_int_11); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_11); __Pyx_INCREF(__pyx_int_24); __Pyx_GIVEREF(__pyx_int_24); PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_24); __Pyx_INCREF(__pyx_int_39); __Pyx_GIVEREF(__pyx_int_39); PyList_SET_ITEM(__pyx_t_1, 4, __pyx_int_39); __Pyx_INCREF(__pyx_n_u_U); __Pyx_GIVEREF(__pyx_n_u_U); PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_u_U); __Pyx_INCREF(__pyx_n_u_R); __Pyx_GIVEREF(__pyx_n_u_R); PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_u_R); __Pyx_INCREF(__pyx_n_u_B); __Pyx_GIVEREF(__pyx_n_u_B); PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_u_B); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_1, 8, __pyx_t_5); __pyx_t_5 = 0; { /* enter inner scope */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); for (__pyx_t_4 = 0; __pyx_t_4 < 7; __pyx_t_4+=1) { __pyx_8genexpr1__pyx_v_i = __pyx_t_4; if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)Py_None))) __PYX_ERR(0, 31, __pyx_L1_error) } } /* exit inner scope */ __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->chance_cards); __Pyx_DECREF(__pyx_v_self->chance_cards); __pyx_v_self->chance_cards = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+032: self.roll_values = [2,3,4,5,6,7,3,4,5,6,7,8,4,5,6,7,8,9,5,6,7,8,9,10,6,7,8,9,10,11,7,8,9,10,11,12]
__pyx_t_6[0] = 2; __pyx_t_6[1] = 3; __pyx_t_6[2] = 4; __pyx_t_6[3] = 5; __pyx_t_6[4] = 6; __pyx_t_6[5] = 7; __pyx_t_6[6] = 3; __pyx_t_6[7] = 4; __pyx_t_6[8] = 5; __pyx_t_6[9] = 6; __pyx_t_6[10] = 7; __pyx_t_6[11] = 8; __pyx_t_6[12] = 4; __pyx_t_6[13] = 5; __pyx_t_6[14] = 6; __pyx_t_6[15] = 7; __pyx_t_6[16] = 8; __pyx_t_6[17] = 9; __pyx_t_6[18] = 5; __pyx_t_6[19] = 6; __pyx_t_6[20] = 7; __pyx_t_6[21] = 8; __pyx_t_6[22] = 9; __pyx_t_6[23] = 10; __pyx_t_6[24] = 6; __pyx_t_6[25] = 7; __pyx_t_6[26] = 8; __pyx_t_6[27] = 9; __pyx_t_6[28] = 10; __pyx_t_6[29] = 11; __pyx_t_6[30] = 7; __pyx_t_6[31] = 8; __pyx_t_6[32] = 9; __pyx_t_6[33] = 10; __pyx_t_6[34] = 11; __pyx_t_6[35] = 12; memcpy(&(__pyx_v_self->roll_values[0]), __pyx_t_6, sizeof(__pyx_v_self->roll_values[0]) * (36));
+033: self.double_indices = {0,7,14,21,28,35}
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_int_0) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (PySet_Add(__pyx_t_3, __pyx_int_7) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (PySet_Add(__pyx_t_3, __pyx_int_14) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (PySet_Add(__pyx_t_3, __pyx_int_21) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (PySet_Add(__pyx_t_3, __pyx_int_28) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (PySet_Add(__pyx_t_3, __pyx_int_35) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __pyx_t_2 = __pyx_convert_set_from_py_int(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->double_indices = __pyx_t_2;
034:
+035: self.community_deck = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->community_deck); __Pyx_DECREF(__pyx_v_self->community_deck); __pyx_v_self->community_deck = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+036: self.chance_deck = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->chance_deck); __Pyx_DECREF(__pyx_v_self->chance_deck); __pyx_v_self->chance_deck = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+037: self.results = [0 for i in range(self.num_spaces+1)] # +1 because we are counting jail vs visiting separately
{ /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = (__pyx_v_self->num_spaces + 1); __pyx_t_7 = __pyx_t_4; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_8genexpr2__pyx_v_i = __pyx_t_8; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_int_0))) __PYX_ERR(0, 37, __pyx_L1_error) } } /* exit inner scope */ if (unlikely(__Pyx_carray_from_py_PY_LONG_LONG(__pyx_t_3, __pyx_t_9, 41) < 0)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; memcpy(&(__pyx_v_self->results[0]), __pyx_t_9, sizeof(__pyx_v_self->results[0]) * (41));
+038: self.total_turns = 0
__pyx_v_self->total_turns = 0;
+039: self.current_position = 0
__pyx_v_self->current_position = 0;
+040: self.doubles = 0
__pyx_v_self->doubles = 0;
041:
+042: cpdef take_turns(self, long long turns):
static PyObject *__pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_3take_turns(PyObject *__pyx_v_self, PyObject *__pyx_arg_turns); /*proto*/ static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_take_turns(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self, PY_LONG_LONG __pyx_v_turns, int __pyx_skip_dispatch) { int __pyx_v_spaces; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("take_turns", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_take_turns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_3take_turns)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_turns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); 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_XDECREF(__pyx_t_5); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.take_turns", __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_3app_10cython_ext_8monopoly_8Monopoly_3take_turns(PyObject *__pyx_v_self, PyObject *__pyx_arg_turns); /*proto*/ static PyObject *__pyx_pw_3app_10cython_ext_8monopoly_8Monopoly_3take_turns(PyObject *__pyx_v_self, PyObject *__pyx_arg_turns) { PY_LONG_LONG __pyx_v_turns; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("take_turns (wrapper)", 0); assert(__pyx_arg_turns); { __pyx_v_turns = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_arg_turns); if (unlikely((__pyx_v_turns == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.take_turns", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_3app_10cython_ext_8monopoly_8Monopoly_2take_turns(((struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self), ((PY_LONG_LONG)__pyx_v_turns)); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3app_10cython_ext_8monopoly_8Monopoly_2take_turns(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self, PY_LONG_LONG __pyx_v_turns) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("take_turns", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_3app_10cython_ext_8monopoly_8Monopoly_take_turns(__pyx_v_self, __pyx_v_turns, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __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("app.cython_ext.monopoly.Monopoly.take_turns", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+043: while self.total_turns < turns:
while (1) { __pyx_t_6 = ((__pyx_v_self->total_turns < __pyx_v_turns) != 0); if (!__pyx_t_6) break;
+044: spaces = self.roll_dice()
__pyx_v_spaces = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->roll_dice(__pyx_v_self);
+045: if self.doubles == 3:
__pyx_t_6 = ((__pyx_v_self->doubles == 3) != 0); if (__pyx_t_6) { /* … */ goto __pyx_L5; }
+046: self.move_to(JAIL)
__pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, __pyx_e_3app_10cython_ext_8monopoly_JAIL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+047: self.doubles = 0 # reset after 3 doubles (differs from maths.py)
__pyx_v_self->doubles = 0;
048: else:
+049: self.move_spaces(spaces)
/*else*/ { __pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_spaces(__pyx_v_self, __pyx_v_spaces); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+050: if self.current_position == 30: # Go to Jail
__pyx_t_6 = ((__pyx_v_self->current_position == 30) != 0); if (__pyx_t_6) { /* … */ goto __pyx_L6; }
+051: self.move_to(JAIL)
__pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, __pyx_e_3app_10cython_ext_8monopoly_JAIL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+052: elif self.community_squares.count(self.current_position) == 1:
__pyx_t_6 = ((__pyx_v_self->community_squares.count(__pyx_v_self->current_position) == 1) != 0); if (__pyx_t_6) { /* … */ goto __pyx_L6; }
+053: self.draw_community_chest()
__pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->draw_community_chest(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+054: elif self.chance_squares.count(self.current_position) == 1:
__pyx_t_6 = ((__pyx_v_self->chance_squares.count(__pyx_v_self->current_position) == 1) != 0); if (__pyx_t_6) { /* … */ } __pyx_L6:; } __pyx_L5:;
+055: self.draw_chance()
__pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->draw_chance(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+056: self.end_turn()
__pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->end_turn(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
057:
+058: cdef int roll_dice(self):
static int __pyx_f_3app_10cython_ext_8monopoly_8Monopoly_roll_dice(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { int __pyx_v_roll_index; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("roll_dice", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_WriteUnraisable("app.cython_ext.monopoly.Monopoly.roll_dice", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
059: # cdef int roll_index = randrange(36) # This seems to take a little longer
+060: cdef int roll_index = int(random()*36)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_int_36); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_roll_index = __pyx_t_4;
061: # cdef int roll_index = rand()%36
+062: if self.double_indices.count(roll_index) == 1:
__pyx_t_5 = ((__pyx_v_self->double_indices.count(__pyx_v_roll_index) == 1) != 0); if (__pyx_t_5) { /* … */ goto __pyx_L3; }
+063: self.doubles+=1
__pyx_v_self->doubles = (__pyx_v_self->doubles + 1);
064: else:
+065: self.doubles = 0
/*else*/ { __pyx_v_self->doubles = 0; } __pyx_L3:;
+066: return self.roll_values[roll_index]
__pyx_r = (__pyx_v_self->roll_values[__pyx_v_roll_index]); goto __pyx_L0;
067:
+068: cdef move_spaces(self, int spaces):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_move_spaces(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self, int __pyx_v_spaces) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("move_spaces", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+069: if self.current_position == JAIL: # We are in jail, move us to just visiting
__pyx_t_1 = ((__pyx_v_self->current_position == __pyx_e_3app_10cython_ext_8monopoly_JAIL) != 0); if (__pyx_t_1) { /* … */ }
+070: self.current_position = 10
__pyx_v_self->current_position = 10;
+071: self.current_position += spaces
__pyx_v_self->current_position = (__pyx_v_self->current_position + __pyx_v_spaces);
+072: if self.current_position >= self.num_spaces:
__pyx_t_1 = ((__pyx_v_self->current_position >= __pyx_v_self->num_spaces) != 0); if (__pyx_t_1) { /* … */ }
+073: self.current_position -= self.num_spaces
__pyx_v_self->current_position = (__pyx_v_self->current_position - __pyx_v_self->num_spaces);
074:
+075: cdef move_to(self, int square):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_move_to(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self, int __pyx_v_square) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("move_to", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+076: self.current_position = square
__pyx_v_self->current_position = __pyx_v_square;
077:
+078: cdef end_turn(self):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_end_turn(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("end_turn", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+079: self.results[self.current_position]+=1
__pyx_t_1 = __pyx_v_self->current_position; (__pyx_v_self->results[__pyx_t_1]) = ((__pyx_v_self->results[__pyx_t_1]) + 1);
+080: self.total_turns+=1
__pyx_v_self->total_turns = (__pyx_v_self->total_turns + 1);
+081: if self.total_turns % 100000 == 0:
__pyx_t_2 = ((__Pyx_mod_PY_LONG_LONG(__pyx_v_self->total_turns, 0x186A0) == 0) != 0); if (__pyx_t_2) { /* … */ }
+082: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { } /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
083: pass
084:
+085: cdef move_to_utility(self):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_move_to_utility(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("move_to_utility", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.move_to_utility", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+086: if self.current_position > 12 and self.current_position < 28:
__pyx_t_2 = ((__pyx_v_self->current_position > 12) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((__pyx_v_self->current_position < 28) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+087: self.move_to(28)
__pyx_t_3 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, 28); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
088: else:
+089: self.move_to(12)
/*else*/ { __pyx_t_3 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, 12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:;
090:
+091: cdef move_to_railroad(self):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_move_to_railroad(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_v_distance_rr = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("move_to_railroad", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.move_to_railroad", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_distance_rr); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+092: distance_rr = (self.current_position+5)%10
__pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_mod_long((__pyx_v_self->current_position + 5), 10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_distance_rr = __pyx_t_1; __pyx_t_1 = 0;
+093: if distance_rr != 0:
__pyx_t_1 = __Pyx_PyInt_NeObjC(__pyx_v_distance_rr, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+094: distance_rr = 10-distance_rr
__pyx_t_1 = __Pyx_PyInt_SubtractCObj(__pyx_int_10, __pyx_v_distance_rr, 10, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_distance_rr, __pyx_t_1); __pyx_t_1 = 0;
+095: self.move_spaces(distance_rr)
__pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_distance_rr); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error) __pyx_t_1 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_spaces(__pyx_v_self, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
096:
+097: cdef draw_community_chest(self):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_draw_community_chest(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_v_card = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("draw_community_chest", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.draw_community_chest", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_card); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+098: if len(self.community_deck) == 0:
__pyx_t_1 = __pyx_v_self->community_deck; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 98, __pyx_L1_error) } __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((__pyx_t_2 == 0) != 0); if (__pyx_t_3) { /* … */ }
099: # self.community_deck = random.sample(self.community_cards, len(self.community_cards))
+100: self.community_deck = self.shuffle_deck(self.community_cards)
__pyx_t_1 = __pyx_v_self->community_cards; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->shuffle_deck(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->community_deck); __Pyx_DECREF(__pyx_v_self->community_deck); __pyx_v_self->community_deck = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0;
+101: card = self.community_deck.pop()
if (unlikely(__pyx_v_self->community_deck == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop"); __PYX_ERR(0, 101, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyList_Pop(__pyx_v_self->community_deck); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_card = __pyx_t_4; __pyx_t_4 = 0;
+102: if card is not None:
__pyx_t_3 = (__pyx_v_card != Py_None); __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { /* … */ }
+103: self.move_to(card)
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_card); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 103, __pyx_L1_error) __pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
104:
+105: cdef draw_chance(self):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_draw_chance(struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self) { PyObject *__pyx_v_card = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("draw_chance", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.draw_chance", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_card); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+106: if len(self.chance_deck) == 0:
__pyx_t_1 = __pyx_v_self->chance_deck; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 106, __pyx_L1_error) } __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((__pyx_t_2 == 0) != 0); if (__pyx_t_3) { /* … */ }
107: # self.chance_deck = random.sample(self.chance_cards, len(self.chance_cards))
+108: self.chance_deck = self.shuffle_deck(self.chance_cards)
__pyx_t_1 = __pyx_v_self->chance_cards; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->shuffle_deck(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->chance_deck); __Pyx_DECREF(__pyx_v_self->chance_deck); __pyx_v_self->chance_deck = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0;
+109: card = self.chance_deck.pop()
if (unlikely(__pyx_v_self->chance_deck == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop"); __PYX_ERR(0, 109, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyList_Pop(__pyx_v_self->chance_deck); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_card = __pyx_t_4; __pyx_t_4 = 0;
+110: if card == 'U':
__pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_card, __pyx_n_u_U, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 110, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L4; }
+111: self.move_to_utility()
__pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to_utility(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+112: elif card == 'R':
__pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_card, __pyx_n_u_R, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 112, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L4; }
+113: self.move_to_railroad()
__pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to_railroad(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+114: elif card == 'B':
__pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_card, __pyx_n_u_B, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 114, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L4; }
+115: self.move_spaces(-3)
__pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_spaces(__pyx_v_self, -3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+116: elif card is not None:
__pyx_t_3 = (__pyx_v_card != Py_None); __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { /* … */ } __pyx_L4:;
+117: self.move_to(card)
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_card); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L1_error) __pyx_t_4 = ((struct __pyx_vtabstruct_3app_10cython_ext_8monopoly_Monopoly *)__pyx_v_self->__pyx_vtab)->move_to(__pyx_v_self, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
118:
+119: cdef list shuffle_deck(self, list deck):
static PyObject *__pyx_f_3app_10cython_ext_8monopoly_8Monopoly_shuffle_deck(CYTHON_UNUSED struct __pyx_obj_3app_10cython_ext_8monopoly_Monopoly *__pyx_v_self, PyObject *__pyx_v_deck) { PyObject *__pyx_v_shuffled = 0; int __pyx_v_i; int __pyx_v_r; PyObject *__pyx_v_move = 0; int __pyx_v_n; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shuffle_deck", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("app.cython_ext.monopoly.Monopoly.shuffle_deck", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_shuffled); __Pyx_XDECREF(__pyx_v_move); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+120: cdef list shuffled = deck.copy()
__pyx_t_1 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_copy, __pyx_v_deck); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 120, __pyx_L1_error) __pyx_v_shuffled = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
121: cdef int i,r
122: cdef move
+123: cdef int n = len(shuffled)
if (unlikely(__pyx_v_shuffled == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 123, __pyx_L1_error) } __pyx_t_2 = PyList_GET_SIZE(__pyx_v_shuffled); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 123, __pyx_L1_error) __pyx_v_n = __pyx_t_2;
+124: for i in range(n-1,0,-1):
for (__pyx_t_3 = (__pyx_v_n - 1); __pyx_t_3 > 0; __pyx_t_3-=1) { __pyx_v_i = __pyx_t_3;
+125: r = int(random()*i)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyNumber_Multiply(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_r = __pyx_t_6;
+126: move = shuffled[r]
if (unlikely(__pyx_v_shuffled == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 126, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_shuffled, __pyx_v_r, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_move, __pyx_t_4); __pyx_t_4 = 0;
+127: shuffled[r] = shuffled[i]
if (unlikely(__pyx_v_shuffled == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 127, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_shuffled, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__pyx_v_shuffled == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 127, __pyx_L1_error) } if (unlikely(__Pyx_SetItemInt(__pyx_v_shuffled, __pyx_v_r, __pyx_t_4, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+128: shuffled[i] = move
if (unlikely(__pyx_v_shuffled == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 128, __pyx_L1_error) } if (unlikely(__Pyx_SetItemInt(__pyx_v_shuffled, __pyx_v_i, __pyx_v_move, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 128, __pyx_L1_error) }
+129: return shuffled
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_shuffled); __pyx_r = __pyx_v_shuffled; goto __pyx_L0;