-
Notifications
You must be signed in to change notification settings - Fork 1
/
simulate.py
51 lines (45 loc) · 1.71 KB
/
simulate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import eneSta
import asses
import help
def simMove(node,x1,y1,x2,y2,isEne):
cMap = help.copy2DList(node.cMap)
posList = help.copy2DList(node.posList)
if(cMap[y2][x2]==0):
if isEne:
enemyChess=eneSta.findChess(x1,y1,posList)
posList[enemyChess] = [y2,x2]
cMap[y2][x2]=cMap[y1][x1]
cMap[y1][x1]=0
return cMap, True, posList
else:
if isEne==False:
result=asses.ChessComparisons(cMap[y1][x1],eneSta.findChess(x2,y2,posList),node)
else:
result=asses.ChessComparisons(cMap[y2][x2],eneSta.findChess(x1,y1,posList),node)
if result==0: # 实际的敌方胜
if isEne:
enemyChess=eneSta.findChess(x1,y1,posList)
posList[enemyChess] = [y2,x2]
cMap[y2][x2]=cMap[y1][x1]
cMap[y1][x1]=0
else:
cMap[y1][x1]=0
elif result==1: # 实际的我方胜
if not isEne:
enemyChess=eneSta.findChess(x2,y2,posList)
eneSta.setDie(enemyChess,posList)
cMap[y2][x2]=cMap[y1][x1]
cMap[y1][x1]=0
else: # 老位置是实际的敌方,前进失败
enemyChess=eneSta.findChess(x1,y1,posList)
eneSta.setDie(enemyChess,posList)
cMap[y1][x1]=0
elif result==2: # 对死
if isEne:
enemyChess=eneSta.findChess(x1,y1,posList)
else:
enemyChess=eneSta.findChess(x2,y2,posList)
eneSta.setDie(enemyChess,posList)
cMap[y2][x2]=0
cMap[y1][x1]=0
return cMap,False,posList