Changeset 60 for trunk/UGame.pas
- Timestamp:
- Sep 26, 2014, 12:27:50 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r59 r60 50 50 function GetColor: TColor; 51 51 function GetAvialPower: Integer; 52 function GetAttackPower: Integer; 52 53 constructor Create; 53 54 destructor Destroy; override; … … 252 253 StayAliveForDefinedTurns: Integer; 253 254 MaxNeutralUnits: Integer; 254 function AttackProbability(AttackCount, DefendCount : Integer): Double;255 function AttackProbability(AttackCount, DefendCount, Depth: Integer): Double; 255 256 procedure SaveConfig(Config: TXmlConfig; Path: string); 256 257 procedure LoadConfig(Config: TXmlConfig; Path: string); … … 899 900 Result := Result - TUnitMove(MovesFrom[I]).CountOnce; 900 901 if Result < 0 then Result := 0; 902 end; 903 904 function TCell.GetAttackPower: Integer; 905 var 906 I: Integer; 907 begin 908 Result := 0; 909 for I := 0 to MovesTo.Count - 1 do 910 Result := Result + TUnitMove(MovesTo[I]).CountOnce; 901 911 end; 902 912 … … 1143 1153 end; 1144 1154 1145 function TGame.AttackProbability(AttackCount, DefendCount : Integer): Double;1155 function TGame.AttackProbability(AttackCount, DefendCount, Depth: Integer): Double; 1146 1156 var 1147 1157 OA, OD: Integer; … … 1152 1162 end else Result := 1; 1153 1163 if DefendCount = 0 then Exit; 1164 if Depth > 5 then Exit; 1154 1165 1155 1166 OA := Min(AttackCount, 3); … … 1157 1168 1158 1169 if (OA = 1) and (OD = 1) then 1159 Result := 0.4167 * AttackProbability(AttackCount, DefendCount - 1 ) +1160 0.5833 * AttackProbability(AttackCount - 1, DefendCount )1170 Result := 0.4167 * AttackProbability(AttackCount, DefendCount - 1, Depth + 1) + 1171 0.5833 * AttackProbability(AttackCount - 1, DefendCount, Depth + 1) 1161 1172 else if (OA = 2) and (OD = 1) then 1162 Result := 0.5787 * AttackProbability(AttackCount, DefendCount - 1 ) +1163 0.4213 * AttackProbability(AttackCount - 1, DefendCount )1173 Result := 0.5787 * AttackProbability(AttackCount, DefendCount - 1, Depth + 1) + 1174 0.4213 * AttackProbability(AttackCount - 1, DefendCount, Depth + 1) 1164 1175 else if (OA = 3) and (OD = 1) then 1165 Result := 0.6597 * AttackProbability(AttackCount, DefendCount - 1 ) +1166 0.3403 * AttackProbability(AttackCount - 1, DefendCount )1176 Result := 0.6597 * AttackProbability(AttackCount, DefendCount - 1, Depth + 1) + 1177 0.3403 * AttackProbability(AttackCount - 1, DefendCount, Depth + 1) 1167 1178 else if (OA = 1) and (OD = 2) then 1168 Result := 0.2546 * AttackProbability(AttackCount, DefendCount - 1 ) +1169 0.7454 * AttackProbability(AttackCount - 1, DefendCount )1179 Result := 0.2546 * AttackProbability(AttackCount, DefendCount - 1, Depth + 1) + 1180 0.7454 * AttackProbability(AttackCount - 1, DefendCount, Depth + 1) 1170 1181 else if (OA = 2) and (OD = 2) then 1171 Result := 0.2276 * AttackProbability(AttackCount, DefendCount - 2 ) +1172 0.4483 * AttackProbability(AttackCount - 2, DefendCount ) +1173 0.3241 * AttackProbability(AttackCount - 1, DefendCount - 1 )1182 Result := 0.2276 * AttackProbability(AttackCount, DefendCount - 2, Depth + 1) + 1183 0.4483 * AttackProbability(AttackCount - 2, DefendCount, Depth + 1) + 1184 0.3241 * AttackProbability(AttackCount - 1, DefendCount - 1, Depth + 1) 1174 1185 else if (OA = 3) and (OD = 2) then 1175 Result := 0.3717 * AttackProbability(AttackCount, DefendCount - 2 ) +1176 0.2926 * AttackProbability(AttackCount - 2, DefendCount ) +1177 0.3358 * AttackProbability(AttackCount - 1, DefendCount - 1 );1186 Result := 0.3717 * AttackProbability(AttackCount, DefendCount - 2, Depth + 1) + 1187 0.2926 * AttackProbability(AttackCount - 2, DefendCount, Depth + 1) + 1188 0.3358 * AttackProbability(AttackCount - 1, DefendCount - 1, Depth + 1); 1178 1189 end; 1179 1190
Note:
See TracChangeset
for help on using the changeset viewer.