• 英雄联盟胜负预测--简易肯德基上校


    作为一名英雄联盟老玩家,巅峰时也曾打上过艾欧尼亚超凡大师,通过这关游戏让我认识了很多朋友,它也陪我度过了大部分校园青春。这是我第一次以学者的角度去面对它。

    这里我们使用决策树ID3算法完成简易的英雄联盟胜负的预测。

    AI遮天传 ML-决策树_老师我作业忘带了的博客-CSDN博客

     

    第一步:战绩获取

    首先呢我们可以进入英雄联盟官网,根据不同的游戏id爬取出这个赛季的详细战绩。

    这里我们获取前10分钟的特征(因此不考虑纳什男爵等因素)

    c47030c06c564890902595b61d2421c6.png

    过程虽然有些麻烦但还算简单,感兴趣的可以自己爬一下(注:国内官网 和 opgg 返回的信息各有优缺点,不怕麻烦的建议使用opgg爬取外服某玩家战绩每个event一点点累加,比如我之前就是以大飞老师“hide on bush”为例,局数多也是韩服千分王者质量局。) 

    也可以使用现成的League of Legends Diamond Ranked Games (10 min) | Kaggle

    815f4795542a42c99275acc6377379da.png

    这里一共包含了9879场钻一到大师段位的单双排对局,对局双方几乎是同一水平。每条数据是前10分钟的对局情况,每支队伍有19个特征,红蓝双方共38个特征。这些特征包括英雄击杀、死亡,视野、金钱、经验、等级情况等等。

     

    第二步:数据处理

    导入工具包

    1. import numpy as np
    2. import pandas as pd
    3. from collections import Counter
    4. from sklearn.model_selection import train_test_split, cross_validate # 划分数据集函数
    5. from sklearn.metrics import accuracy_score # 准确率函数
    6. RANDOM_SEED = 2020 # 固定随机种子

    读入数据

    1. csv_data = './data/high_diamond_ranked_10min.csv' # 数据路径
    2. data_df = pd.read_csv(csv_data, sep=',') # 读入csv文件为pandas的DataFrame
    3. data_df = data_df.drop(columns='gameId') # 去掉对局ID列

    数据概览

    对数据分布有个大致了解,比如我们可以通过.iloc[0]取出数据的第一行并输出。不难看出每个特征都存成了float64浮点数,该对局蓝色方开局10分钟有小优势。同时也可以发现有些特征列是重复冗余的,比如blueGoldDiff表示蓝色队金币优势,redGoldDiff表示红色方金币优势,这两个特征是完全对称的互为相反数,等等。

    比如blueKills蓝色方击杀英雄数在前十分钟的平均数是6.14、方差为2.93,中位数是6,百分之五十以上的对局中该特征在4-8之间,等等。

    68ca09f892e04b71a0f82b3e6ade3814.png

    增删特征

    除去一些冗杂信息,且像上面说的一般蓝色方击杀等于红色方死亡,或者蓝色与红色方方金币数可以合并为经济差,又或者红色方发生了1血那么蓝色方就没有发生...

    1. drop_features = ['blueGoldDiff', 'redGoldDiff',
    2. 'blueExperienceDiff', 'redExperienceDiff',
    3. 'blueCSPerMin', 'redCSPerMin',
    4. 'blueGoldPerMin', 'redGoldPerMin'] # 需要舍去的特征列
    5. df = data_df.drop(columns=drop_features) # 舍去特征列
    6. info_names = [c[3:] for c in df.columns if c.startswith('red')] # 取出要作差值的特征名字(除去red前缀)
    7. for info in info_names: # 对于每个特征名字
    8. df['br' + info] = df['blue' + info] - df['red' + info] # 构造一个新的特征,由蓝色特征减去红色特征,前缀为br
    9. # 其中FirstBlood为首次击杀最多有一只队伍能获得,brFirstBlood=1为蓝,0为没有产生,-1为红
    10. df = df.drop(columns=['blueFirstBlood', 'redFirstBlood']) # 原有的FirstBlood可删除

    经过这一步此时变量df里由原来的38个特征-8(不需要的)+15(红蓝差)-2(一血),还剩下43个特征值,外加蓝色方是否获胜,一共44列。

    特征离散化

    决策树ID3算法一般是基于离散特征的,本例中存在很多连续的数值特征,例如队伍金币。直接应用该算法每个值当作一个该特征的一个取值可能造成严重的过拟合,因此需要对特征进行离散化,即将一定范围内的值映射成一个值,例如对用户年龄特征,将0-10映射到0,11-18映射到1,19-25映射到2,25-30映射到3,等等类似,然后在决策树构建时使用映射后的值计算信息增益。

    1. DISCRETE_N = 10
    2. discrete_df = df.copy()
    3. for c in df.columns[1:]:
    4. if len(df[c].unique()) <= DISCRETE_N:
    5. continue
    6. else:
    7. discrete_df[c] = pd.qcut(df[c], DISCRETE_N, precision=0, labels=False, duplicates='drop')

    注: 有些特征本身取值就很少,可以跳过离散化。

    数据集准备

    随机取一部分如20%作测试集,剩下作训练集。sklearn提供了相关工具函数train_test_split。sklearn的输入输出一般为numpy的array矩阵,需要先将pandas的DataFrame取出为numpy的array矩阵。

    1. all_y = discrete_df['blueWins'].values # 所有标签数据
    2. feature_names = discrete_df.columns[1:] # 所有特征的名称
    3. all_x = discrete_df[feature_names].values # 所有原始特征值
    4. # 划分训练集和测试集
    5. x_train, x_test, y_train, y_test = train_test_split(all_x, all_y, test_size=0.2, random_state=RANDOM_SEED)
    6. # ((9879,), (9879, 43), (7903, 43), (1976, 43), (7903,), (1976,))

     

    第三步:决策树模型的实现

    删删改改了很多次,路漫漫其修远~

    1. # 定义决策树类
    2. class DecisionTree(object):
    3. def __init__(self, classes, features,
    4. max_depth=10, min_samples_split=10,
    5. impurity_t='entropy'):
    6. '''
    7. 传入一些可能用到的模型参数,也可能不会用到
    8. classes表示模型分类总共有几类
    9. features是每个特征的名字,也方便查询总的共特征数
    10. max_depth表示构建决策树时的最大深度
    11. min_samples_split表示构建决策树分裂节点时,如果到达该节点的样本数小于该值则不再分裂
    12. impurity_t表示计算混杂度(不纯度)的计算方式,例如entropy或gini
    13. '''
    14. self.classes = classes
    15. self.features = features
    16. self.max_depth = max_depth
    17. self.min_samples_split = min_samples_split
    18. self.impurity_t = impurity_t
    19. self.root = None # 定义根节点,未训练时为空
    20. def impurity(self, data):
    21. '''
    22. 计算某个特征下的信息增益
    23. :param data: ,numpy一维数组
    24. :return: 混杂度
    25. '''
    26. cnt = Counter(data) # 计数每个值出现的次数
    27. probability_lst = [1.0 * cnt[i] / len(data) for i in cnt]
    28. if self.impurity_t == 'entropy': # 如果是信息熵
    29. return -np.sum([p * np.log2(p) for p in probability_lst if p > 0]), cnt # 返回熵 和可能用到的数据次数(方便以后使用)
    30. return 1 - np.sum([p * p for p in probability_lst]), cnt # 否则返回gini系数
    31. def gain(self, feature, label):
    32. '''
    33. 计算某个特征下的信息增益
    34. :param feature: 特征的值,numpy一维数组
    35. :param label: 对应的标签,numpy一维数组
    36. :return: 信息增益
    37. '''
    38. c_impurity, _ = self.impurity(label) # 不考虑特征时标签的混杂度
    39. # 记录特征的每种取值所对应的数组下标
    40. f_index = {}
    41. for idx, v in enumerate(feature):
    42. if v not in f_index:
    43. f_index[v] = []
    44. f_index[v].append(idx)
    45. # 计算根据该特征分裂后的不纯度,根据特征的每种值的数目加权和
    46. f_impurity = 0
    47. for v in f_index:
    48. # 根据该特征取值对应的数组下标 取出对应的标签列表 比如分支1有多少个正负例 分支2有...
    49. f_l = label[f_index[v]]
    50. f_impurity += self.impurity(f_l)[0] * len(f_l) / len(label) # 循环结束得到各分支混杂度的期望
    51. gain = c_impurity - f_impurity # 得到gain
    52. # 有些特征取值很多,天然不纯度高、信息增益高,模型会偏向于取值很多的特征比如日期,但很可能过拟合
    53. # 计算信息增益率可以缓解该问题
    54. splitInformation = self.impurity(feature)[0] # 计算该特征在标签无关时的不纯度
    55. gainRatio = gain / splitInformation if splitInformation > 0 else gain # 除数不为0时为信息增益率
    56. return gainRatio, f_index # 返回信息增益率,以及每个特征取值的数组下标(方便以后使用)
    57. def expand_node(self, feature, label, depth, skip_features=set()):
    58. '''
    59. 递归函数分裂节点
    60. :param feature:二维numpy(n*m)数组,每行表示一个样本,n行,有m个特征
    61. :param label:一维numpy(n)数组,表示每个样本的分类标签
    62. :param depth:当前节点的深度
    63. :param skip_features:表示当前路径已经用到的特征
    64. 在当前ID3算法离散特征的实现下,一条路径上已经用过的特征不会再用(其他实现有可能会选重复特征)
    65. '''
    66. l_cnt = Counter(label) # 计数每个类别的样本出现次数
    67. if len(l_cnt) <= 1: # 如果只有一种类别了,无需分裂,已经是叶节点
    68. return label[0] # 只需记录类别
    69. if len(label) < self.min_samples_split or depth > self.max_depth: # 如果达到了最小分裂的样本数或者最大深度的阈值
    70. return l_cnt.most_common(1)[0][0] # 则只记录当前样本中最多的类别
    71. f_idx, max_gain, f_v_index = -1, -1, None # 准备挑选分裂特征
    72. for idx in range(len(self.features)): # 遍历所有特征
    73. if idx in skip_features: # 如果当前路径已经用到,不用再算
    74. continue
    75. f_gain, fv = self.gain(feature[:, idx], label) # 计算特征的信息增益,fv是特征每个取值的样本下标
    76. # if f_gain <= 0: # 如果信息增益不为正,跳过该特征
    77. # continue
    78. if f_idx < 0 or f_gain > max_gain: # 如果个更好的分裂特征
    79. f_idx, max_gain, f_v_index = idx, f_gain, fv # 则记录该特征
    80. # if f_idx < 0: # 如果没有找到合适的特征,即所有特征都没有信息增益
    81. # return l_cnt.most_common(1)[0][0] # 则只记录当前样本中最多的类别
    82. decision = {} # 用字典记录每个特征取值所对应的子节点,key是特征取值,value是子节点
    83. skip_features = set([f_idx] + [f for f in skip_features]) # 子节点要跳过的特征包括当前选择的特征
    84. for v in f_v_index: # 遍历特征的每种取值
    85. decision[v] = self.expand_node(feature[f_v_index[v], :], label[f_v_index[v]], # 取出该特征取值所对应的样本
    86. depth=depth + 1, skip_features=skip_features) # 深度+1,递归调用节点分裂
    87. # 返回一个元组,有三个元素
    88. # 第一个是选择的特征下标,第二个特征取值和对应的子节点(字典),第三个是到达当前节点的样本中最多的类别
    89. return (f_idx, decision, l_cnt.most_common(1)[0][0])
    90. def traverse_node(self, node, feature):
    91. '''
    92. 预测样本时从根节点开始遍历节点,根据特征路由。
    93. :param node: 当前到达的节点,例如self.root
    94. :param feature: 长度为m的numpy一维数组
    95. '''
    96. assert len(self.features) == len(feature) # 要求输入样本特征数和模型定义时特征数目一致
    97. if type(node) is not tuple: # 如果到达了一个节点是叶节点(不再分裂),则返回该节点类别
    98. return node
    99. fv = feature[node[0]] # 否则取出该节点对应的特征值,node[0]记录了特征的下标
    100. if fv in node[1]: # 根据特征值找到子节点,注意需要判断训练节点分裂时到达该节点的样本是否有该特征值(分支)
    101. return self.traverse_node(node[1][fv], feature) # 如果有,则进入到子节点继续遍历
    102. return node[-1] # 如果没有,返回训练时到达当前节点的样本中最多的类别
    103. def fit(self, feature, label):
    104. '''
    105. 训练模型
    106. :param feature:feature为二维numpy(n*m)数组,每行表示一个样本,有m个特征
    107. :param label:label为一维numpy(n)数组,表示每个样本的分类标签
    108. '''
    109. assert len(self.features) == len(feature[0]) # 输入数据的特征数目应该和模型定义时的特征数目相同
    110. self.root = self.expand_node(feature, label, depth=1) # 从根节点开始分裂,模型记录根节点
    111. def predict(self, feature):
    112. '''
    113. 预测
    114. :param feature:输入feature可以是一个一维numpy数组也可以是一个二维numpy数组
    115. 如果是一维numpy(m)数组则是一个样本,包含m个特征,返回一个类别值
    116. 如果是二维numpy(n*m)数组则表示n个样本,每个样本包含m个特征,返回一个numpy一维数组
    117. '''
    118. assert len(feature.shape) == 1 or len(feature.shape) == 2 # 只能是1维或2维
    119. if len(feature.shape) == 1: # 如果是一个样本
    120. return self.traverse_node(self.root, feature) # 从根节点开始路由
    121. return np.array([self.traverse_node(self.root, f) for f in feature]) # 如果是很多个样本
    122. def get_params(self, deep): # 要调用sklearn的cross_validate需要实现该函数返回所有参数
    123. return {'classes': self.classes, 'features': self.features,
    124. 'max_depth': self.max_depth, 'min_samples_split': self.min_samples_split,
    125. 'impurity_t': self.impurity_t}
    126. def set_params(self, **parameters): # 要调用sklearn的GridSearchCV需要实现该函数给类设定所有参数
    127. for parameter, value in parameters.items():
    128. setattr(self, parameter, value)
    129. return self
    130. # 定义决策树模型,传入算法参数
    131. DT = DecisionTree(classes=[0, 1], features=feature_names, max_depth=5, min_samples_split=10, impurity_t='gini')
    132. DT.fit(x_train, y_train) # 在训练集上训练
    133. p_test = DT.predict(x_test) # 在测试集上预测,获得预测值
    134. print(p_test) # 输出预测值
    135. test_acc = accuracy_score(p_test, y_test) # 将测试预测值与测试集标签对比获得准确率
    136. print('accuracy: {:.4f}'.format(test_acc)) # 输出准确率

    [0 1 0 ... 0 1 1]
    accuracy: 0.6964

    此时的准确率为0.6964,下面我们进行模型调优。

     

    第四步:模型调优

    在测试集上对不同的混杂度计算方式、深度、最小分裂阈值进行五折交叉验证。

    1. %%time
    2. best = None # 记录最佳结果
    3. for impurity_t in ['entropy', 'gini']: # 遍历不纯度的计算方式
    4. for max_depth in range(1, 6): # 遍历最大树深度
    5. for min_samples_split in [50, 100, 200, 500, 1000]: # 遍历节点分裂最小样本数的阈值
    6. DT = DecisionTree(classes=[0,1], features=feature_names, # 定义决策树
    7. max_depth=max_depth, min_samples_split=min_samples_split, impurity_t=impurity_t)
    8. cv_result = cross_validate(DT, x_train, y_train, scoring=('accuracy'), cv=5) # 5折交叉验证
    9. cv_acc = np.mean(cv_result['test_score']) # 5折平均准确率
    10. current = (cv_acc, max_depth, min_samples_split, impurity_t) # 记录参数和结果
    11. if best is None or cv_acc > best[0]: # 如果是比当前最佳更好的结果
    12. best = current # 记录最好结果
    13. print('better cv_accuracy: {:.4f}, max_depth={}, min_samples_split={}, impurity_t={}'.format(*best)) # 输出准确率和参数
    14. else:
    15. print('cv_accuracy: {:.4f}, max_depth={}, min_samples_split={}, impurity_t={}'.format(*current)) # 输出准确率和参数
    16. DT = DecisionTree(classes=[0,1], features=feature_names, max_depth=best[1], min_samples_split=best[2], impurity_t=best[3]) # 取最佳参数
    17. DT.fit(x_train, y_train) # 在训练集上训练
    18. p_test = DT.predict(x_test) # 在测试集上预测,获得预测值
    19. print(p_test) # 输出预测值
    20. test_acc = accuracy_score(p_test, y_test) # 将测试预测值与测试集标签对比获得准确率
    21. print('accuracy: {:.4f}'.format(test_acc)) # 输出准确率
    better cv_accuracy: 0.7257, max_depth=1, min_samples_split=50, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=100, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=200, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=500, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=1000, impurity_t=entropy
    cv_accuracy: 0.7254, max_depth=2, min_samples_split=50, impurity_t=entropy
    cv_accuracy: 0.7254, max_depth=2, min_samples_split=100, impurity_t=entropy
    cv_accuracy: 0.7254, max_depth=2, min_samples_split=200, impurity_t=entropy
    cv_accuracy: 0.7254, max_depth=2, min_samples_split=500, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=2, min_samples_split=1000, impurity_t=entropy
    better cv_accuracy: 0.7267, max_depth=3, min_samples_split=50, impurity_t=entropy
    better cv_accuracy: 0.7272, max_depth=3, min_samples_split=100, impurity_t=entropy
    better cv_accuracy: 0.7281, max_depth=3, min_samples_split=200, impurity_t=entropy
    better cv_accuracy: 0.7286, max_depth=3, min_samples_split=500, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=3, min_samples_split=1000, impurity_t=entropy
    cv_accuracy: 0.7237, max_depth=4, min_samples_split=50, impurity_t=entropy
    cv_accuracy: 0.7252, max_depth=4, min_samples_split=100, impurity_t=entropy
    cv_accuracy: 0.7285, max_depth=4, min_samples_split=200, impurity_t=entropy
    better cv_accuracy: 0.7290, max_depth=4, min_samples_split=500, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=4, min_samples_split=1000, impurity_t=entropy
    cv_accuracy: 0.7149, max_depth=5, min_samples_split=50, impurity_t=entropy
    cv_accuracy: 0.7210, max_depth=5, min_samples_split=100, impurity_t=entropy
    cv_accuracy: 0.7254, max_depth=5, min_samples_split=200, impurity_t=entropy
    cv_accuracy: 0.7290, max_depth=5, min_samples_split=500, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=5, min_samples_split=1000, impurity_t=entropy
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=50, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=100, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=200, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=500, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=1, min_samples_split=1000, impurity_t=gini
    cv_accuracy: 0.7255, max_depth=2, min_samples_split=50, impurity_t=gini
    cv_accuracy: 0.7255, max_depth=2, min_samples_split=100, impurity_t=gini
    cv_accuracy: 0.7255, max_depth=2, min_samples_split=200, impurity_t=gini
    cv_accuracy: 0.7255, max_depth=2, min_samples_split=500, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=2, min_samples_split=1000, impurity_t=gini
    cv_accuracy: 0.7218, max_depth=3, min_samples_split=50, impurity_t=gini
    cv_accuracy: 0.7235, max_depth=3, min_samples_split=100, impurity_t=gini
    cv_accuracy: 0.7250, max_depth=3, min_samples_split=200, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=3, min_samples_split=500, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=3, min_samples_split=1000, impurity_t=gini
    cv_accuracy: 0.7174, max_depth=4, min_samples_split=50, impurity_t=gini
    cv_accuracy: 0.7248, max_depth=4, min_samples_split=100, impurity_t=gini
    cv_accuracy: 0.7261, max_depth=4, min_samples_split=200, impurity_t=gini
    cv_accuracy: 0.7259, max_depth=4, min_samples_split=500, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=4, min_samples_split=1000, impurity_t=gini
    cv_accuracy: 0.7076, max_depth=5, min_samples_split=50, impurity_t=gini
    cv_accuracy: 0.7185, max_depth=5, min_samples_split=100, impurity_t=gini
    cv_accuracy: 0.7207, max_depth=5, min_samples_split=200, impurity_t=gini
    cv_accuracy: 0.7259, max_depth=5, min_samples_split=500, impurity_t=gini
    cv_accuracy: 0.7257, max_depth=5, min_samples_split=1000, impurity_t=gini

    使用max_depth=4, min_samples_split=500, impurity_t=entropy在训练集上进行训练,并在测试集上预测,将测试预测值与测试集标签对比获得准确率:显然提升了

    [0 1 0 ... 0 1 1]

    accuracy: 0.7171

    Wall time: 1min 19s

    也可以调用sklearn的GridSearchCV自动且多线程搜索参数,和上面的流程类似。

    1. %%time
    2. parameters = {'impurity_t':['entropy', 'gini'],
    3. 'max_depth': range(1, 6),
    4. 'min_samples_split': [50, 100, 200, 500, 1000]} # 定义需要遍历的参数
    5. DT = DecisionTree(classes=[0,1], features=feature_names) # 定义决策树,可以不传参数,由GridSearchCV传入构建
    6. grid_search = GridSearchCV(DT, parameters, scoring='accuracy', cv=5, verbose=100, n_jobs=4) # 传入模型和要遍历的参数
    7. grid_search.fit(x_train, y_train) # 在所有数据上搜索参数
    8. print(grid_search.best_score_, grid_search.best_params_) # 输出最佳指标和最佳参数
    9. DT = DecisionTree(classes=[0,1], features=feature_names, **grid_search.best_params_) # 取最佳参数
    10. DT.fit(x_train, y_train) # 在训练集上训练
    11. p_test = DT.predict(x_test) # 在测试集上预测,获得预测值
    12. print(p_test) # 输出预测值
    13. test_acc = accuracy_score(p_test, y_test) # 将测试预测值与测试集标签对比获得准确率
    14. print('accuracy: {:.4f}'.format(test_acc)) # 输出准确率
    Fitting 5 folds for each of 50 candidates, totalling 250 fits
    0.7289642831407777 {'impurity_t': 'entropy', 'max_depth': 4, 'min_samples_split': 500}
    [0 1 0 ... 0 1 1]
    accuracy: 0.7171
    Wall time: 24.6 s

    查看节点的特征

    1. best_dt = grid_search.best_estimator_ # 取出最佳模型
    2. print('root', best_dt.features[best_dt.root[0]]) # 输出根节点特征
    root brTotalGold
    

    可见前10分钟最能影响胜率的是红蓝双方的经济差 

    1. for fv in best_dt.root[1]: # 遍历根节点的每种特征取值
    2. print(fv, '->', best_dt.features[best_dt.root[1][fv][0]], '-> ...') # 输出下一层特征
    9 -> redDragons -> ...
    1 -> blueTowersDestroyed -> ...
    3 -> redEliteMonsters -> ...
    5 -> redTowersDestroyed -> ...
    2 -> blueTowersDestroyed -> ...
    4 -> brTowersDestroyed -> ...
    7 -> redEliteMonsters -> ...
    8 -> brTowersDestroyed -> ...
    0 -> brKills -> ...
    6 -> brTowersDestroyed -> ...

    根节点这个特征对应取值0-9(我们之前对金币进行了离散化)所对应的下一层的特征...

           

    ps:这个其实来自于我们定义的 expand_node 函数返回值,

    return (f_idx, decision, l_cnt.most_common(1)[0][0]) ,

    第一个是选择的特征下标,第二个特征取值和对应的子节点(字典),第三个是到达当前节点的样本中最多的类别。

    它的形状/结果其实是这样的:

    (38,
     {9: (20,
       {0: (23, {1: 1, 2: 1, 4: 1, 0: 1, 3: 1, 5: 1, 6: 1, 7: 1, 8: 1}, 1), 1: 1},
       1),
      1: (8, {0: (7, {0: (20, {1: 0, 0: 0}, 0), 1: 0}, 0), 1: 0}, 0),
      3: (19, {0: 0, 1: 0, 2: 0}, 0),
      5: (22, {0: (19, {0: 1, 2: 0, 1: 0}, 1), 1: 1, 2: 1}, 1),
      2: (8, {0: (22, {0: (6, {0: 0, 1: 0}, 0), 1: 0, 2: 1}, 0), 1: 1}, 0),
      4: (37, {0: (8, {0: (5, {0: 0, 1: 0, 2: 1}, 0), 1: 1}, 0), -1: 0, 1: 0}, 0),
      7: (19, {1: 1, 0: 1, 2: 1}, 1),
      8: (37, {0: (8, {0: (6, {0: 1, 1: 1}, 1), 1: 1}, 1), 1: 1, 2: 1}, 1),
      0: (31, {0: (5, {0: 0, 1: 0, 2: 0}, 0), 1: 0, 2: 0, 4: 0, 3: 0}, 0),
      6: (37, {0: (8, {0: (6, {1: 1, 0: 1}, 1), 1: 1}, 1), 1: 0, 2: 1, -1: 0}, 1)},
     0)
    

     

     

  • 相关阅读:
    uni-app开发微信小程序 vue3写法添加pinia
    【QT】界面布局-登陆窗口
    [Java基础] 设计模式之策略模式
    c++图解内存管理
    【KD】Transformer在各个研究领域的轻量化研究进展
    Word控件Spire.Doc 【图像形状】教程(4) 用 C# 中的文本替换 Word 中的图像
    实验08 软件设计模式及应用
    C++容器效率比较
    如何使用现有工具三分钟之内从无到有设计一款滤波器?
    C++ 【类和对象: 析构函数,拷贝构造函数,运算符重载 --2】
  • 原文地址:https://blog.csdn.net/suic009/article/details/125601372