16、hive_3
<pre><code class="language-python">import pandas as pd</code></pre>
<pre><code class="language-python"># city1总共记录 31570 = 1435 rows * 22 columns
jun_bian_dui_city1.size
# GREEN 681
# BLUE 494
# RED 260
jun_bian_dui_city1['UserFlag'].value_counts()
# 查看红方记录总数 5720 = 260 * 22
UserFlag_RED_pd.size
# 蓝方记录总数 10868 = 494 * 22
UserFlag_BLUE_pd.size
# 查看列的名称
jun_bian_dui_city1.columns
# Index(['ID', 'Room', 'UserID', 'UserFlag', 'CityIco', 'Flag', 'CityName',
# 'CityRot', 'MapID', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'C0', 'C1',
# 'C2', 'C3', 'Mark', 'Army', 'WARID'],
# dtype='object')
# 统计每个值出现多少次 Name: WARID, Length: 204,
jun_bian_dui_city1.WARID.value_counts()
# 1435 = 205 * 7 其中 2018620223323 14
jun_bian_dui_city1['WARID'].size
# 统计每个值出现多少次
jun_bian_dui_city1['WARID'].value_counts()
# 2018620223323 14
# 201862117352 7
# 2018623162654 7
# 20186309228 7
# .......</code></pre>
<pre><code>31570</code></pre>
<p>比赛ID(warID字段)</p>
<p>红方夺控点得分:city1表中对于每一个warID,查看UserFlag字段为RED的行,将C1字段的值相加</p>
<pre><code class="language-python"># 筛选 UserFlag字段为RED的行
UserFlag_RED_pd = jun_bian_dui_city1.loc[jun_bian_dui_city1['UserFlag'] == 'RED']
# 筛选 UserFlag字段为BLUE的行
UserFlag_BLUE_pd = jun_bian_dui_city1.loc[jun_bian_dui_city1['UserFlag'] == 'BLUE']</code></pre>
<pre><code class="language-python"># 将红方C1字段值相加 16000
UserFlag_RED_pd['C1'].sum()
# 将蓝方C1字段值相加 31330
UserFlag_BLUE_pd['C1'].sum()</code></pre>
<pre><code>31330</code></pre>
<pre><code class="language-python"># size 78 ObjSonName 和object2不一样
jun_bian_dui_object1.columns
# 1110642 = 78 * 14239
jun_bian_dui_object1.size/78</code></pre>
<pre><code>Index(['ID', 'Room', 'UserID', 'GameName', 'GameColor', 'Army', 'ObjName',
'ObjDataID', 'ObjSup', 'ObjSon', 'ObjSonNum', 'ObjSonName', 'ObjSpace',
'ObjFlag', 'ObjPos', 'ObjIco', 'ObjIcon', 'ObjType', 'ObjRot',
'ObjStep', 'ObjStepMax', 'ObjPass', 'ObjBlood', 'ObjBlood2', 'ObjKeep',
'ObjSee', 'ObjHide', 'ObjAim', 'ObjValue', 'ObjValue2', 'ObjMoney',
'ObjRound', 'ObjAttack', 'ObjDate', 'ObjRadar', 'ObjRes', 'ObjRes2',
'Slope', 'A0', 'B0', 'A1', 'A2', 'A3', 'A4', 'A5', 'B1', 'B2', 'B3',
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'D0', 'D1', 'D2', 'D3', 'E0', 'E1',
'E2', 'F0', 'F1', 'F2', 'F3', 'R1', 'R2', 'R3', 'R4', 'R5', 'S1', 'S2',
'S3', 'S4', 'S5', 'Wz', 'Title', 'WARID'],
dtype='object')</code></pre>
<pre><code class="language-python"># 去掉obj1中 比obj2多余的一列 inplace=False 不修改源数据
jun_bian_dui_object1_pd = jun_bian_dui_object1.drop(['ObjSonName'],axis=1,inplace=False)
# 去掉obj2中 比obj1多余的三列 inplace=False 不修改源数据
jun_bian_dui_object2_pd = jun_bian_dui_object2.drop(['ObjID','CityID','ObjTime'],axis=1,inplace=False)
# ob1_pd 后面拼接 ob2_pd
jun_bian_dui_object_pds = jun_bian_dui_object1_pd.append(jun_bian_dui_object2_pd, sort=False)
# 1136520 = 77 * 14760
jun_bian_dui_object_pds.size/77
jun_bian_dui_object_pds.columns
# 查看是否有重复数据,如果重复,则去除重复,这里没有重复数据
#jun_bian_dui_object_pds.duplicated()
jun_bian_dui_object_pds.drop_duplicates()</code></pre>
<pre><code>Index(['ID', 'Room', 'UserID', 'GameName', 'GameColor', 'Army', 'ObjName',
'ObjDataID', 'ObjSup', 'ObjSon', 'ObjSonNum', 'ObjSonName', 'ObjSpace',
'ObjFlag', 'ObjPos', 'ObjIco', 'ObjIcon', 'ObjType', 'ObjRot',
'ObjStep', 'ObjStepMax', 'ObjPass', 'ObjBlood', 'ObjBlood2', 'ObjKeep',
'ObjSee', 'ObjHide', 'ObjAim', 'ObjValue', 'ObjValue2', 'ObjMoney',
'ObjRound', 'ObjAttack', 'ObjDate', 'ObjRadar', 'ObjRes', 'ObjRes2',
'Slope', 'A0', 'B0', 'A1', 'A2', 'A3', 'A4', 'A5', 'B1', 'B2', 'B3',
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'D0', 'D1', 'D2', 'D3', 'E0', 'E1',
'E2', 'F0', 'F1', 'F2', 'F3', 'R1', 'R2', 'R3', 'R4', 'R5', 'S1', 'S2',
'S3', 'S4', 'S5', 'Wz', 'Title', 'WARID', 'ObjTime'],
dtype='object')</code></pre>
<pre><code class="language-python"># 41680 = 80 * 521
jun_bian_dui_object2.size/80
# ObjID CityID ObjTime 和obj1不一样
# size 80
jun_bian_dui_object2.columns</code></pre>
<pre><code>Index(['ID', 'Room', 'UserID', 'GameName', 'GameColor', 'ObjID', 'CityID',
'Army', 'ObjName', 'ObjDataID', 'ObjSup', 'ObjSon', 'ObjSonNum',
'ObjSpace', 'ObjFlag', 'ObjPos', 'ObjIco', 'ObjIcon', 'ObjType',
'ObjRot', 'ObjStep', 'ObjStepMax', 'ObjPass', 'ObjBlood', 'ObjBlood2',
'ObjKeep', 'ObjSee', 'ObjHide', 'ObjAim', 'ObjValue', 'ObjValue2',
'ObjTime', 'ObjDate', 'ObjMoney', 'ObjRound', 'ObjAttack', 'ObjRadar',
'ObjRes', 'ObjRes2', 'Slope', 'A0', 'B0', 'A1', 'A2', 'A3', 'A4', 'A5',
'B1', 'B2', 'B3', 'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'D0', 'D1', 'D2',
'D3', 'E0', 'E1', 'E2', 'F0', 'F1', 'F2', 'F3', 'R1', 'R2', 'R3', 'R4',
'R5', 'S1', 'S2', 'S3', 'S4', 'S5', 'Wz', 'Title', 'WARID'],
dtype='object')</code></pre>
<p>红方歼灭对手得分:对于每一个warID,对于每一个字段gamecolor为BLUE的行
根据object1以及object2中每一个棋子的ObjBlood和ObjBlood1字段(之差)
查看ObjName字段所示的棋子的兵力减少值。</p>
<pre><code class="language-python">type(df1_city1)</code></pre>
<pre><code>pandas.core.frame.DataFrame</code></pre>
<pre><code class="language-python">type(jun_bian_dui_object_pds['WARID'].value_counts())</code></pre>
<pre><code>pandas.core.series.Series</code></pre>
<pre><code class="language-python">jun_bian_dui_object_pds['WARID'].value_counts().keys()[0]</code></pre>
<pre><code>2018620223323</code></pre>
<pre><code class="language-python">jun_bian_dui_object_pds['ObjName'].value_counts()</code></pre>
<pre><code>炮兵 4920
步兵小队 3280
重型坦克 1640
坦克 1640
战车 1640
中型战车 1448
重型战车 192
Name: ObjName, dtype: int64</code></pre>
<pre><code class="language-python"># BLUE 36
# RED 36
df1['GameColor'].value_counts()</code></pre>
<pre><code>BLUE 36
RED 36
Name: GameColor, dtype: int64</code></pre>
<p>红方剩余兵力得分 每一行ObjBlood字段值 * ObjName字段(对应的分数的值)
然后求和</p>
<pre><code class="language-python">df1_red = df1.loc[df1['GameColor'] == 'RED']
df1_red['ObjBlood']</code></pre>
<p>炮兵 4920
步兵小队 3280
重型坦克 1640
坦克 1640
战车 1640
中型战车 1448
重型战车 192
Name: ObjName, dtype: int64
没有人夺的时候插绿色小旗子</p>
<pre><code class="language-python">WARID = 20186910654
df1_city1 = jun_bian_dui_city1.loc[jun_bian_dui_city1['WARID'] == WARID]
df1 = jun_bian_dui_object_pds.loc[jun_bian_dui_object_pds['WARID'] == WARID]
# 红方夺控分
red_duo_kong_source = 0
for index,row in df1_city1.iterrows():
if row['UserFlag'] == 'RED':
red_duo_kong_source = red_duo_kong_source + row['C1']
print(red_duo_kong_source)
# 红方剩余兵力得分 251
red_source = 0
for index,row in df1_red.iterrows():
# print(row['ObjBlood'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
red_source = red_source + row['ObjBlood'] * ObjName_value
print(red_source)
# 红方歼灭对手得分
red_source_win = 0
for index,row in df1_red.iterrows():
# print(row['ObjBlood2'] - row['ObjBlood2'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
red_source_win = red_source_win + (row['ObjBlood2'] - row['ObjBlood2']) * ObjName_value
print(red_source_win)
red_get_source = red_duo_kong_source + red_source + red_source_win
print('红方最终得分 : ',red_get_source)</code></pre>
<pre><code>0
251
0
红方最终得分 : 251</code></pre>
<pre><code class="language-python">WARID = 20186910654
df1_city1 = jun_bian_dui_city1.loc[jun_bian_dui_city1['WARID'] == WARID]
df1 = jun_bian_dui_object_pds.loc[jun_bian_dui_object_pds['WARID'] == WARID]
df1_blue = df1.loc[df1['GameColor'] == 'BLUE']
# 蓝方夺控分
blue_duo_kong_source = 0
for index,row in df1_city1.iterrows():
if row['UserFlag'] == 'RED':
blue_duo_kong_source = blue_duo_kong_source + row['C1']
print(blue_duo_kong_source)
# 蓝方剩余兵力得分 251
blue_source = 0
for index,row in df1_blue.iterrows():
# print(row['ObjBlood'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 10
elif '战车' in row['ObjName']:
ObjName_value = 8
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 4
else:
print('ObjName : 有异常')
blue_source = blue_source + row['ObjBlood'] * ObjName_value
print(blue_source)
# 蓝方歼灭对手得分
blue_source_win = 0
for index,row in df1_blue.iterrows():
# print(row['ObjBlood2'] - row['ObjBlood2'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
blue_source_win = blue_source_win + (row['ObjBlood2'] - row['ObjBlood2']) * ObjName_value
print(blue_source_win)
blue_get_source = blue_duo_kong_source + blue_source + blue_source_win
print('蓝方最终得分 : ',blue_get_source)</code></pre>
<pre><code>0
210
0
蓝方最终得分 : 210</code></pre>
<pre><code class="language-python">WARID = 20186910654
df1_city1 = jun_bian_dui_city1.loc[jun_bian_dui_city1['WARID'] == WARID]
df1 = jun_bian_dui_object_pds.loc[jun_bian_dui_object_pds['WARID'] == WARID]
df1_blue = df1.loc[df1['GameColor'] == 'BLUE']</code></pre>
<p>红方歼灭对手得分
= 每一行(ObjBlood2 - ObjBlood)* ObjName字段所示的棋子的兵力减少值
最后求和</p>
<p>红方歼灭对手得分:对于每一个warID,对于每一个字段gamecolor为BLUE的行 根据object1以及object2中每一个棋子的ObjBlood和ObjBlood1字段(之差) 查看ObjName字段所示的棋子的兵力减少值。</p>
<pre><code class="language-python">df1.loc[df1['GameColor'] == 'BLUE']['ObjName']</code></pre>
<pre><code>968 坦克
969 坦克
970 战车
971 战车
972 坦克
973 坦克
974 战车
975 战车
976 坦克
977 坦克
978 战车
979 战车
980 坦克
981 坦克
982 战车
999 战车
1012 炮兵
1013 炮兵
1014 炮兵
1015 炮兵
1016 炮兵
1017 炮兵
1018 炮兵
1019 炮兵
1020 炮兵
1021 炮兵
1022 炮兵
1023 炮兵
1027 步兵小队
1028 步兵小队
1031 步兵小队
1032 步兵小队
1033 步兵小队
1036 步兵小队
1037 步兵小队
1038 步兵小队
Name: ObjName, dtype: object</code></pre>
<pre><code class="language-python">df1.loc[df1['GameColor'] == 'BLUE']['ObjBlood']</code></pre>
<pre><code>968 0
969 0
970 0
971 0
972 1
973 0
974 0
975 0
976 0
977 0
978 3
979 0
980 0
981 0
982 0
999 0
1012 3
1013 3
1014 3
1015 3
1016 3
1017 3
1018 3
1019 3
1020 3
1021 3
1022 3
1023 3
1027 2
1028 0
1031 3
1032 3
1033 0
1036 0
1037 0
1038 0
Name: ObjBlood, dtype: int64</code></pre>
<pre><code class="language-python">df1.loc[df1['GameColor'] == 'BLUE']['ObjBlood2']</code></pre>
<pre><code>968 3
969 3
970 3
971 3
972 3
973 3
974 3
975 3
976 3
977 3
978 3
979 3
980 3
981 3
982 3
999 3
1012 3
1013 3
1014 3
1015 3
1016 3
1017 3
1018 3
1019 3
1020 3
1021 3
1022 3
1023 3
1027 3
1028 3
1031 3
1032 3
1033 3
1036 3
1037 3
1038 3
Name: ObjBlood2, dtype: int64</code></pre>
<pre><code class="language-python"># 去掉obj1中 比obj2多余的一列 inplace=False 不修改源数据
jun_bian_dui_object1_pd = jun_bian_dui_object1.drop(['ObjSonName'],axis=1,inplace=False)
# 去掉obj2中 比obj1多余的三列 inplace=False 不修改源数据
jun_bian_dui_object2_pd = jun_bian_dui_object2.drop(['ObjID','CityID','ObjTime'],axis=1,inplace=False)
# ob1_pd 后面拼接 ob2_pd
jun_bian_dui_object_pds = jun_bian_dui_object1_pd.append(jun_bian_dui_object2_pd, sort=False)</code></pre>
<pre><code class="language-python">from pandas.core.frame import DataFrame
data = DataFrame(result_list)</code></pre>
<pre><code class="language-python">data['win_player'].value_counts()</code></pre>
<pre><code>BLUE 169
RED 35
Name: win_player, dtype: int64</code></pre>
<pre><code class="language-python">data = DataFrame(result_list)
data.to_csv('./jun_bian_dui.csv',index=False)</code></pre>
<pre><code class="language-python">jun_bian_dui_caijue = pd.read_csv('./jun_bian_dui/caijue.csv')
jun_bian_dui_city1 = pd.read_csv('./jun_bian_dui/city1.csv')
jun_bian_dui_object = pd.read_csv('./jun_bian_dui/object.csv')
jun_bian_dui_object1 = pd.read_csv('./jun_bian_dui/object1.csv')
jun_bian_dui_object2 = pd.read_csv('./jun_bian_dui/object2.csv')
jun_bian_dui_room = pd.read_csv('./jun_bian_dui/room.csv')
jun_bian_dui_roomrecordnew = pd.read_csv('./jun_bian_dui/roomrecordnew.csv')</code></pre>
<pre><code class="language-python">city1 = jun_single_city1
object1 = jun_single_object1
object2 = jun_single_object2
# 去掉obj1中 比obj2多余的一列 inplace=False 不修改源数据
object1_pd = object1.drop(['ObjSonName'],axis=1,inplace=False)
# 去掉obj2中 比obj1多余的三列 inplace=False 不修改源数据
object2_pd = object2.drop(['ObjID','CityID','ObjTime'],axis=1,inplace=False)
# ob1_pd 后面拼接 ob2_pd
object_pds = object1_pd.append(object2_pd, sort=False)</code></pre>
<pre><code class="language-python">data['win_player'].value_counts()</code></pre>
<pre><code>BLUE 913
RED 361
GREEN 8
Name: win_player, dtype: int64</code></pre>
<pre><code class="language-python">jun_single_city1 = pd.read_csv('./jun_single/city1.csv')
jun_single_object1 = pd.read_csv('./jun_single/object1.csv')
jun_single_object2 = pd.read_csv('./jun_single/object2.csv')
# jun_single_caijue = pd.read_csv('./jun_single/caijue.csv')
# jun_single_object = pd.read_csv('./jun_single/object.csv')
# jun_single_room = pd.read_csv('./jun_single/room.csv')
# jun_single_roomrecordnew = pd.read_csv('./jun_single/roomrecordnew.csv')</code></pre>
<pre><code class="language-python">local_bian_dui_city1 = pd.read_excel('./local_bian_dui/city1.xls')
local_bian_dui_object1 = pd.read_excel('./local_bian_dui/object1.xls')
local_bian_dui_object2 = pd.read_excel('./local_bian_dui/object2.xls')
# local_bian_dui_caijue = pd.read_excel('./local_bian_dui/caijue.xls')
# local_bian_dui_object = pd.read_excel('./local_bian_dui/object.xls')
# local_bian_dui_room = pd.read_excel('./local_bian_dui/room.xls')
# local_bian_dui_roomrecordnew = pd.read_csv('./local_bian_dui/roomrecordnew.csv')</code></pre>
<pre><code>WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero</code></pre>
<pre><code class="language-python">local_single1_city1 = pd.read_excel('./local_single1/city1.xls')
local_single1_object1 = pd.read_excel('./local_single1/object1.xls')
local_single1_object2 = pd.read_excel('./local_single1/object2.xls')
# local_single1_object = pd.read_excel('./local_single1/object.xls')
# local_single1_caijue = pd.read_excel('./local_single1/caijue.xls')
# local_single1_room = pd.read_excel('./local_single1/room.xls')
# local_single1_roomrecordnew = pd.read_csv('./local_single1/roomrecordnew.csv')</code></pre>
<pre><code>WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero</code></pre>
<pre><code class="language-python">local_single2_city1 = pd.read_excel('./local_single2/city1.xls')
local_single2_object1 = pd.read_excel('./local_single2/object1.xls')
local_single2_object2 = pd.read_excel('./local_single2/object2.xls')
# local_single2_caijue = pd.read_excel('./local_single2/caijue.xls')
# local_single2_object = pd.read_excel('./local_single2/object.xls')
# local_single2_room = pd.read_excel('./local_single2/room.xls')
# local_single2_roomrecordnew = pd.read_excel('./local_single2/roomrecordnew.xls')</code></pre>
<pre><code>WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero</code></pre>
<pre><code class="language-python">def get_result_list(type):
# get_type
if 1:
city1 = jun_bian_dui_city1
object1 = jun_bian_dui_object1
object2 = jun_bian_dui_object2
if type == 'jun_bian_dui':
city1 = jun_bian_dui_city1
object1 = jun_bian_dui_object1
object2 = jun_bian_dui_object2
elif type == 'jun_single':
city1 = jun_single_city1
object1 = jun_single_object1
object2 = jun_single_object2
elif type == 'local_bian_dui':
city1 = local_bian_dui_city1
object1 = local_bian_dui_object1
object2 = local_bian_dui_object2
elif type == 'local_single1':
city1 = local_single1_city1
object1 = local_single1_object1
object2 = local_single1_object2
elif type == 'local_single2':
city1 = local_single2_city1
object1 = local_single2_object1
object2 = local_single2_object2
else:
print('type error')
# get 合并后的object
if 1:
# 去掉obj1中 比obj2多余的一列 inplace=False 不修改源数据
object1_pd = object1.drop(['ObjSonName'], axis=1, inplace=False)
# 去掉obj2中 比obj1多余的三列 inplace=False 不修改源数据
object2_pd = object2.drop(['ObjID', 'CityID', 'ObjTime'], axis=1, inplace=False)
# ob1_pd 后面拼接 ob2_pd
object_pds = object1_pd.append(object2_pd, sort=False)
result_list = []
for WARID in object_pds['WARID'].value_counts().keys():
result_dict = {}
# 红方
if 1:
df1_city1 = city1.loc[city1['WARID'] == WARID]
df1 = object_pds.loc[object_pds['WARID'] == WARID]
df1_red = df1.loc[df1['GameColor'] == 'RED']
# 红方夺控分
red_duo_kong_source = 0
for index,row in df1_city1.iterrows():
if row['UserFlag'] == 'RED':
red_duo_kong_source = red_duo_kong_source + row['C1']
# print(red_duo_kong_source)
# 红方剩余兵力得分 251
red_source = 0
for index,row in df1_red.iterrows():
# print(row['ObjBlood'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
red_source = red_source + row['ObjBlood'] * ObjName_value
# print(red_source)
# 红方歼灭对手得分
red_source_win = 0
for index,row in df1_red.iterrows():
# print(row['ObjBlood2'] - row['ObjBlood2'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
red_source_win = red_source_win + (row['ObjBlood2'] - row['ObjBlood']) * ObjName_value
# print(red_source_win)
red_get_source = red_duo_kong_source + red_source + red_source_win
# print('红方最终得分 : ',red_get_source)
# 蓝方
if 2:
df1_city1 = city1.loc[city1['WARID'] == WARID]
df1 = object_pds.loc[object_pds['WARID'] == WARID]
df1_blue = df1.loc[df1['GameColor'] == 'BLUE']
# 蓝方夺控分
blue_duo_kong_source = 0
for index,row in df1_city1.iterrows():
if row['UserFlag'] == 'BLUE':
blue_duo_kong_source = blue_duo_kong_source + row['C1']
# print(blue_duo_kong_source)
# 蓝方剩余兵力得分 251
blue_source = 0
for index,row in df1_blue.iterrows():
# print(row['ObjBlood'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 10
elif '战车' in row['ObjName']:
ObjName_value = 8
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 4
else:
print('ObjName : 有异常')
blue_source = blue_source + row['ObjBlood'] * ObjName_value
# print(blue_source)
# 蓝方歼灭对手得分
blue_source_win = 0
for index,row in df1_blue.iterrows():
# print(row['ObjBlood2'] - row['ObjBlood2'])
ObjName_value = 0
if '坦克' in row['ObjName']:
ObjName_value = 8
elif '战车' in row['ObjName']:
ObjName_value = 6
elif row['ObjName'] == '炮兵':
ObjName_value = 4
elif row['ObjName'] == '步兵小队':
ObjName_value = 3
else:
print('ObjName : 有异常')
blue_source_win = blue_source_win + (row['ObjBlood2'] - row['ObjBlood']) * ObjName_value
# print(blue_source_win)
blue_get_source = blue_duo_kong_source + blue_source + blue_source_win
# print('蓝方最终得分 : ',blue_get_source)
# get win_player
if 3:
jingsheng = 0
win_player = 'GREEN'
if red_get_source > blue_get_source:
win_player = 'RED'
jingsheng = red_get_source - blue_get_source
elif red_get_source < blue_get_source:
win_player = 'BLUE'
jingsheng = blue_get_source - red_get_source
# get result
if 4:
result_dict['red_duo_kong_source'] = red_duo_kong_source
result_dict['red_source'] = red_source
result_dict['red_source_win'] = red_source_win
result_dict['red_get_source'] = red_get_source
result_dict['blueblue_duo_kong_source'] = blue_duo_kong_source
result_dict['blue_source'] = blue_source
result_dict['blue_source_win'] = blue_source_win
result_dict['blue_get_source'] = blue_get_source
result_dict['warID'] = WARID
# result_dict['ID'] = jun_bian_dui_object_pds['ID']
result_dict['win_player'] = win_player
result_dict['jingsheng'] = jingsheng
result_list.append(result_dict)
data = DataFrame(result_list)
print(type)
print(data['win_player'].value_counts())
print('**********************************')
data.to_csv('./' + type + '.csv', index=False)
return result_list</code></pre>
<pre><code class="language-python">type_list = ['jun_bian_dui', 'jun_single', 'local_bian_dui', 'local_single1', 'local_single2']</code></pre>
<pre><code class="language-python">for item in type_list:
get_result_list(item)</code></pre>
<pre><code>jun_bian_dui
BLUE 165
RED 38
GREEN 1
Name: win_player, dtype: int64
**********************************
jun_single
BLUE 807
RED 468
GREEN 7
Name: win_player, dtype: int64
**********************************
local_bian_dui
BLUE 134
RED 37
GREEN 2
Name: win_player, dtype: int64
**********************************
local_single1
BLUE 584
RED 286
GREEN 9
Name: win_player, dtype: int64
**********************************
local_single2
BLUE 90
RED 61
GREEN 2
Name: win_player, dtype: int64
**********************************</code></pre>