def _decode_node(self, reader, depth=0): row = next(reader) node = MonteCarloNode() d = node.details d.move_name = row[0] d.visits_count = int(row[1]) d.visits_count_pre_modified = int(row[2]) d.average_prize = float(row[3]) d.state_name = row[4] children = int(row[5]) for i in range(children): child = self._decode_node(reader, depth + 1) node.add_child_by_node(child) return node
def _decode_node(self, file): rc = MonteCarloNode() state_name = BinaryCodec.read_string(file) rc.details.state_name = state_name children_count = BinaryCodec.read_integer(file) for i in range(children_count): details = MonteCarloNodeDetails() details.move_name = BinaryCodec.read_string(file) details.visits_count = BinaryCodec.read_integer(file) details.visits_count_pre_modified = BinaryCodec.read_integer(file) details.average_prize = BinaryCodec.read_float(file) child, child_state_name = self._decode_node(file) details.state_name = child_state_name child.details = details rc.add_child_by_node(child) return rc, state_name