默认页面
<pre><code>import pandas as pd
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')
# 去掉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)
result_list = []
for WARID in jun_bian_dui_object_pds['WARID'].value_counts().keys():
result_dict = {}
# 红方
if 1:
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_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['ObjBlood2']) * 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 = 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)
# 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 = red_get_source - blue_get_source
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)
</code></pre>