forked from DigitalMars/Empire-for-PDP-10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13.FOR
197 lines (175 loc) · 4.97 KB
/
13.FOR
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
C SUBROUTINE 13
SUBROUTINE ENEMYM
&(OWN1,HITMAX,CRAHIT,CRALOC,NUM)
INCLUDE 'COMMON.EMP/NOLIST'
DIMENSION OK(5),NSHPRF(4,6)
DATA OK/'.',' ','O','*','X'/
* NSHPRF IS AN ARRAY WHICH IS REFERENCED TO DETERMINE
* WHETHER A CERTAIN SHIP (D=1,S=2,R=3,B=4) WANTS TO ATTACK
* ANOTHER CERTAIN TYPE OF SHIP. 1 MEANS YES, 0 MEANS NO.
* SECOND VARIABLE: 1=D,2=S,3=T,4=R,5=C,6=B
DATA (NSHPRF(1,J),J=1,6)/1,1,1,0,0,0/ !DESTROYER
DATA (NSHPRF(2,J),J=1,6)/1,1,1,0,0,0/ !SUBMARINE
DATA (NSHPRF(3,J),J=1,6)/1,1,1,1,1,0/ !CRUISER
DATA (NSHPRF(4,J),J=1,6)/1,1,1,1,1,1/ !BATTLESHIP
*THE FOLLOWING NUMBERS ARE IFO VARIABLES RELATING TO
* CERTAIN TYPES OF MOVEMENT (CODES)
C 7: RANDOM DIRECTION
C 3: CITY TARGET LOC.
C 4: TT# ESCORT
C 5: TARGET
C 8: DAMAGED
C 10: LOOK AT UNEXPLORED TERRITORY
IF(NUM==3) NUMSHP=1
IF(NUM==4) NUMSHP=2
IF(NUM==6) NUMSHP=3
IF(NUM==8) NUMSHP=4
NUMBER(NUM)=0
IF(INT(CODER)==NUM) TYPE 100,OWN1
100 FORMAT(1X,A1,' CODES')
MONKEY=0
DO 1000 Y=1,LIMIT(NUM+8)
Z6=S(Y+CRALOC)
IF(Z6==0) GOTO 1000
DIR=MOD(Y,2)*2-1
H1=H(Y+CRAHIT)
AB=A(1,Z6)
IF(AB=='X') H1=H1+1
IF(H1>HITMAX) H1=HITMAX
DO 2500 ITURN=1,2
P='NSENS'
IF((ITURN==2).AND.(H1<=HITMAX/2)) GOTO 1000
Z7=Z6
C MOVE SELECTION
IFO=IFORM(CODE(Y+CRALOC-1500))
ILA=ILATT(CODE(Y+CRALOC-1500))
* DOES A NEW CODE NEED TO BE SELECTED? 804:YES, 800:NO
IF((IFO==8).AND.(H1==HITMAX)) IFO=0
IF(IFO==8) GOTO 800
IF(H1==HITMAX) GOTO 801
IFO=8
ILA=IPORT(Z6)
GOTO 800
801 GOTO (804,2,3,4,5,804,804,804,804,10) IFO
GOTO 804
2 GOTO 804
3 IF(A(1,ILA)=='X') GOTO 804
IF(IDIST(Z6,ILA)==1) 804,800
4 IF(S(2600+ILA)==0) GOTO 804
IF(CODE(1100+ILA)<70000) 804,800
5 IF(ILA#Z6) GOTO 800
DO 52 I1=1,6
DO 52 I2=1,5
IF(TROOPT(I1,I2)#ILA) GOTO 52
TROOPT(I1,I2)=0
52 CONTINUE
GOTO 804
10 IF(A(0,ILA)#' ') 804,800
C NEW CODE SELECTION
* 5:TARGET
804 ID=500
DO 900 N=1,6
IF(NSHPRF(NUMSHP,N)==0) GOTO 900
DO 900 N2=1,5
IF(TROOPT(N,N2)==0) GOTO 900
IF(IDIST(Z6,TROOPT(N,N2))>=ID) GOTO 900
ID=IDIST(Z6,TROOPT(N,N2))
ILA=TROOPT(N,N2)
IFO=5
900 CONTINUE
IF(ID#500) GOTO 800
803 IF(RAN(C1)>.40) GOTO 808
C 3:CITY TARGET LOC.
IA=INT(RAN(C1)*20.+1.)
IB=IA+70
DO 809 IC=IA,IB
I=IC
IF(I>70) I=IC-70
IF(TARGET(I)==0) GOTO 809
IF(A(1,TARGET(I))#'O') GOTO 809
IF(EDGER(TARGET(I))==0.) GOTO 809
IFO=3
ILA=TARGET(I)
GOTO 800
809 CONTINUE
C 4:TT# ESCORT
808 IA=INT(RAN(C1)*FLOAT(LIMIT(13))+1.)
IB=ILA+LIMIT(13)
DO 811 IC=IA,IB
I=IC
IF(I>LIMIT(13)) I=IC-LIMIT(13)
IF(S(2600+I)==0) GOTO 811
IF(CODE(1100+I)<90000) GOTO 811
IFO=4
ILA=I
GOTO 800
811 CONTINUE
* 10: EXPLORE
814 I1=EXPL(DUMMY)
IF(I1==0) GOTO 813
ILA=I1
IFO=10
GOTO 800
* 1: RANDOM DIRECTION
813 IF(IFO==7) GOTO 800
ILA=INT(RAN(C1)*8.+1.)
IFO=7
* MOVE CORRECTION
800 IF(IFO==7) MOOV=ILA
FLAG=1
IF((IFO==8).OR.(IFO==3).OR.(IFO==5))
& MOOV=PATH(Z6,ILA,DIR,OK,FLAG)
IF(IFO==4) MOOV=PATH(Z6,S(ITT2+ILA),DIR,OK,FLAG)
IF(FLAG==0) GOTO 814
IF(IFO==10) MOOV=PATH(Z6,ILA,DIR,OK,FLAG)
IF(FLAG==0) GOTO 813
IF(IFO#2) GOTO 812
MOOV=0
IF(IDIST(Z6,ILA)>4) MOOV=MOV(Z6,ILA)
IF(IDIST(Z6,ILA)<4) MOOV=ICORR(MOV(Z6,ILA)-4)
812 AGGR=0
IS1=1
IF(OWN1=='4') IS1=2
MOOV=MOOV*DIR
MOOV=MOVCOR(IFO,ITURN,Z6,MOOV,H1,IS1,AGGR,OWN1,1.,DIR)
IF((H1<HITMAX).AND.(A(1,Z6)=='X')) MOOV=0
IF(IFO==7) ILA=IABS(MOOV)
CODE(Y+CRALOC-1500)=10000*IFO+ILA
MOOV=IABS(MOOV)
IB=CODE(Y+CRALOC-1500)
IF(INT(CODER)==NUM) TYPE 101,IB
101 FORMAT(G)
C MOVE EVALUATION
Z6=Z6+IARROW(MOOV)
IF(D1(Z7)#'*') CALL CHANGE(Z7,D1(Z7),1)
A1=A(1,Z6)
IF(A1=='.') GOTO 500
IF(A1=='X') GOTO 501
IF((A1>='A').AND.(A1<='T')) GOTO 503
TYPE 502,OWN1,Z6,A1
502 FORMAT(' ENEMY ',A1,' AT ',I4,' RAN AGROUND ON ',A1)
GOTO 600
503 H2=30
P='SENSE'
OWN2=A1
CALL FIND(OWN2,Z6,Z8,H2)
CALL FGHT(Z6,H1,H2,OWN1,OWN2)
CALL FIND(OWN2,Z6,Z8,H2)
IF(H1<=0) GOTO 600
500 CALL CHANGE(Z6,OWN1,1)
501 CALL CHAS(Y+CRALOC,Z6)
CALL CHITS(Y+CRAHIT,H1)
IF(ITURN==1) NUMBER(NUM)=NUMBER(NUM)+1
MONKEY=Y
GOTO 999
600 CALL CHAS(Y+CRALOC,0)
CODE(Y+CRALOC-1500)=0
CALL CHITS(Y+CRAHIT,0)
999 CALL SONAR(Z6)
IF(P=='SENSE') CALL SENSOR(Z6)
2500 CONTINUE
1000 CONTINUE
LIMIT(NUM+8)=MONKEY
RETURN
END
.