- Timestamp:
- Mar 27, 2024, 12:31:14 PM (9 months ago)
- Location:
- trunk/AI/StdAI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AI/StdAI/AI.pas
r522 r531 93 93 TPersistentData = record 94 94 LastResearchTech, BehaviorFlags, TheologyPartner: Integer; 95 RejectTurn: array[Suggestion, 0..15] of smallint;95 RejectTurn: array[Suggestion, 0..15] of SmallInt; 96 96 RequestedTechs: array[0..nRequestedTechs - 1] of Integer; 97 97 // ad + p shl 8 + Turn shl 16 … … 196 196 else 197 197 BehaviorFlags := bMale; 198 DebugMessage(1, 'Gender:=' + char(48 + BehaviorFlags and bGender));198 DebugMessage(1, 'Gender:=' + Char(48 + BehaviorFlags and bGender)); 199 199 TheologyPartner := -1; 200 200 FillChar(RejectTurn, SizeOf(RejectTurn), $FF); 201 Fill char(RequestedTechs, SizeOf(RequestedTechs), $FF);201 FillChar(RequestedTechs, SizeOf(RequestedTechs), $FF); 202 202 end; 203 203 end; … … 324 324 mi: TModelInfo; 325 325 Entry: array[0..nAdv - 1] of Boolean; 326 ok: Boolean;326 Ok: Boolean; 327 327 328 328 function MarkEntry(ad: Integer): Boolean; … … 540 540 ((EarliestNeeded < 0) or (Advancedness[ad] < Advancedness[EarliestNeeded])) then 541 541 begin 542 ok := False;542 Ok := False; 543 543 for iad := 0 to nResearchOrder - 1 do 544 544 if ResearchOrder[Data.BehaviorFlags and bGender, iad] = ad then 545 545 begin 546 ok := True;546 Ok := True; 547 547 Break; 548 548 end; 549 if not ok then549 if not Ok then 550 550 begin 551 551 EarliestNeeded := ad; … … 1406 1406 begin 1407 1407 Data.BehaviorFlags := Data.BehaviorFlags and not bGender or NewGender; 1408 DebugMessage(1, 'Gender:=' + char(48 + NewGender));1408 DebugMessage(1, 'Gender:=' + Char(48 + NewGender)); 1409 1409 end; 1410 1410 end; … … 2427 2427 Total := Total + CityResult[cix]; 2428 2428 if Total = 0 then 2429 continue; // district does not exist2429 Continue; // district does not exist 2430 2430 2431 2431 Share := 0; -
trunk/AI/StdAI/Barbarina.pas
r522 r531 34 34 TBarbarina = class(TToolAI) 35 35 constructor Create(Nation: Integer); override; 36 37 36 protected 38 37 ColonyShipPlan: TColonyShipPlan; … … 47 46 procedure Barbarina_DoNegotiation; 48 47 procedure MakeColonyShipPlan; 49 50 48 private 51 49 TurnOfMapAnalysis, Neighbours: Integer; … … 173 171 Moved: array[0..numax - 1] of Boolean; 174 172 UnitPresence: array[0..lxmax * lymax - 1] of Byte; 175 euixMap: array[0..lxmax * lymax - 1] of smallint;176 uixAttack: array[0..neumax - 1] of smallint;173 euixMap: array[0..lxmax * lymax - 1] of SmallInt; 174 uixAttack: array[0..neumax - 1] of SmallInt; 177 175 AttackScore: array[0..neumax - 1] of Integer; 178 176 … … 1599 1597 end; 1600 1598 if (City_CurrentImprovementProject(cix) = imCourt) and 1601 (Built[imTownHall] > 0) and ( prod >= imp[imCourt].cost *1599 (Built[imTownHall] > 0) and (Prod >= imp[imCourt].Cost * 1602 1600 BuildCostMod[G.Difficulty[Me]] div 12 - 1603 ( imp[imTownHall].cost * BuildCostMod[G.Difficulty[Me]] div 12) *1601 (Imp[imTownHall].Cost * BuildCostMod[G.Difficulty[Me]] div 12) * 1604 1602 2 div 3) then 1605 1603 City_RebuildImprovement(cix, imTownHall) … … 1622 1620 var 1623 1621 nPreq, rmix, rmixChosen, I, MaxWeight, MaxDefense, ChosenPreq: Integer; 1624 NeedSeaUnits, ready: Boolean;1622 NeedSeaUnits, Ready: Boolean; 1625 1623 ModelExists: set of 0..nModelCategory - 1; 1626 known: array[0..nAdv - 1] of Integer;1624 Known: array[0..nAdv - 1] of Integer; 1627 1625 1628 1626 procedure ChoosePreq(ad: Integer); … … 1632 1630 begin 1633 1631 Assert(RO.Tech[ad] < tsApplicable); 1634 if known[ad] = 0 then1632 if Known[ad] = 0 then 1635 1633 begin 1636 known[ad] := 1;1634 Known[ad] := 1; 1637 1635 PreqOk := True; 1638 1636 if not (ad in [adScience, adMassProduction]) and (RO.Tech[ad] < tsSeen) then … … 1695 1693 if IsResearched(adSteel) then 1696 1694 Inc(MaxDefense); 1697 ready := (MaxWeight >= Weight) and (MaxDefense >= Cap[mcDefense]);1698 if ready then1695 Ready := (MaxWeight >= Weight) and (MaxDefense >= Cap[mcDefense]); 1696 if Ready then 1699 1697 for I := 0 to nFeature - 1 do 1700 1698 if (Cap[I] > 0) and (Feature[I].Preq <> preNone) and 1701 1699 ((Feature[I].Preq < 0) or not IsResearched(Feature[I].Preq)) then 1702 ready := False;1703 if ready then1700 Ready := False; 1701 if Ready then 1704 1702 begin 1705 1703 for I := 0 to nUpgrade - 1 do 1706 1704 if (Upgrades and (1 shl I) <> 0) and not 1707 1705 IsResearched(Upgrade[Domain, I].Preq) then 1708 ready := False;1709 end; 1710 if ready then1706 Ready := False; 1707 end; 1708 if Ready then 1711 1709 begin 1712 1710 Include(ModelExists, Category); … … 1736 1734 I := 0; 1737 1735 while (I < nResearchOrder) and (not NeedSeaUnits and (ResearchOrder[I] < 0) or 1738 1739 Inc(I);1736 IsResearched(Abs(ResearchOrder[I]))) do 1737 Inc(I); 1740 1738 if I >= nResearchOrder then // list done, continue with future tech 1741 1739 begin … … 1747 1745 else 1748 1746 begin 1749 FillChar( known, SizeOf(known), 0);1747 FillChar(Known, SizeOf(Known), 0); 1750 1748 nPreq := 0; 1751 1749 ChosenPreq := -1; … … 1835 1833 (MyModel[mix].Domain <> dSea)) then 1836 1834 begin 1837 DebugMessage(1, 'Declare war on P' + char(48 + Nation));1835 DebugMessage(1, 'Declare war on P' + Char(48 + Nation)); 1838 1836 NegoCause := CancelTreaty; 1839 1837 Result := True; … … 1858 1856 procedure TBarbarina.MakeColonyShipPlan; 1859 1857 var 1860 I, V21, V21C, CityLoc, Loc1, part, cix, BestValue, TestValue, FoodCount,1858 I, V21, V21C, CityLoc, Loc1, Part, cix, BestValue, TestValue, FoodCount, 1861 1859 ProdCount, ProdExtra, Score, BestScore: Integer; 1862 1860 Tile: Cardinal; 1863 ok, check: Boolean;1861 Ok, Check: Boolean; 1864 1862 Radius, RadiusC: TVicinity21Loc; 1865 1863 begin 1866 for part := 0 to nShipPart - 1 do1864 for Part := 0 to nShipPart - 1 do 1867 1865 begin 1868 ColonyShipPlan[ part].cixProducing := -1;1869 ColonyShipPlan[ part].nLocResource := 0;1870 ColonyShipPlan[ part].nLocFoundCity := 0;1866 ColonyShipPlan[Part].cixProducing := -1; 1867 ColonyShipPlan[Part].nLocResource := 0; 1868 ColonyShipPlan[Part].nLocFoundCity := 0; 1871 1869 end; 1872 1870 if RO.Tech[adMassProduction] >= tsApplicable then // able to recognize ressources yet 1873 1871 begin 1874 // check already existing cities1872 // Check already existing cities 1875 1873 for cix := 0 to RO.nCity - 1 do 1876 1874 with MyCity[cix] do … … 1886 1884 if Tile and fModern <> 0 then 1887 1885 begin 1888 part := (Tile and fModern) shr 25 - 1;1889 if RO.Ship[Me].Parts[ part] < ShipNeed[part] then1886 Part := (Tile and fModern) shr 25 - 1; 1887 if RO.Ship[Me].Parts[Part] < ShipNeed[Part] then 1890 1888 // not enough of this kind already 1891 1889 begin 1892 ok := True;1893 if ColonyShipPlan[ part].cixProducing >= 0 then1890 Ok := True; 1891 if ColonyShipPlan[Part].cixProducing >= 0 then 1894 1892 begin // another city is already assigned to this ship part, choose one of the two 1895 1893 TestValue := (ID and $FFF) shl 4 + ((ID shr 12) + 15 - Me) and $F; 1896 1894 BestValue := 1897 (MyCity[ColonyShipPlan[ part].cixProducing].ID and $FFF) shl1898 4 + ((MyCity[ColonyShipPlan[ part].cixProducing].ID shr 12) +1895 (MyCity[ColonyShipPlan[Part].cixProducing].ID and $FFF) shl 1896 4 + ((MyCity[ColonyShipPlan[Part].cixProducing].ID shr 12) + 1899 1897 15 - Me) and $F; 1900 1898 if TestValue <= BestValue then 1901 ok := False;1899 Ok := False; 1902 1900 end; 1903 if ok then1901 if Ok then 1904 1902 ColonyShipPlan[part].cixProducing := cix; 1905 1903 end; … … 1910 1908 1911 1909 // for parts without existing city, look for location of city to found 1912 check := False;1913 for part := 0 to nShipPart - 1 do1914 if (RO.Ship[Me].Parts[ part] < ShipNeed[part]) // not enough of this kind already1915 and (ColonyShipPlan[ part].cixProducing < 0) then // no city to produce1916 check := True;1917 if check then1910 Check := False; 1911 for Part := 0 to nShipPart - 1 do 1912 if (RO.Ship[Me].Parts[Part] < ShipNeed[Part]) // not enough of this kind already 1913 and (ColonyShipPlan[Part].cixProducing < 0) then // no city to produce 1914 Check := True; 1915 if Check then 1918 1916 begin 1919 1917 for Loc1 := 0 to MapSize - 1 do … … 1922 1920 if Tile and fModern <> 0 then 1923 1921 begin 1924 part := (Tile and fModern) shr 25 - 1;1925 if ColonyShipPlan[ part].nLocResource < maxModern then1926 begin 1927 ColonyShipPlan[ part].LocResource[ColonyShipPlan[part].nLocResource] := Loc1;1928 Inc(ColonyShipPlan[ part].nLocResource);1929 end; 1930 end; 1931 end; 1932 for part := 0 to nShipPart - 1 do1933 if (RO.Ship[Me].Parts[ part] < ShipNeed[part]) // not enough of this kind already1934 and (ColonyShipPlan[ part].cixProducing < 0) // no city to produce1935 and (ColonyShipPlan[ part].nLocResource > 0) then // resource is known1936 begin 1937 for I := 0 to ColonyShipPlan[ part].nLocResource - 1 do1922 Part := (Tile and fModern) shr 25 - 1; 1923 if ColonyShipPlan[Part].nLocResource < maxModern then 1924 begin 1925 ColonyShipPlan[Part].LocResource[ColonyShipPlan[Part].nLocResource] := Loc1; 1926 Inc(ColonyShipPlan[Part].nLocResource); 1927 end; 1928 end; 1929 end; 1930 for Part := 0 to nShipPart - 1 do 1931 if (RO.Ship[Me].Parts[Part] < ShipNeed[Part]) // not enough of this kind already 1932 and (ColonyShipPlan[Part].cixProducing < 0) // no city to produce 1933 and (ColonyShipPlan[Part].nLocResource > 0) then // resource is known 1934 begin 1935 for I := 0 to ColonyShipPlan[Part].nLocResource - 1 do 1938 1936 begin 1939 1937 BestScore := 0; 1940 V21_to_Loc(ColonyShipPlan[ part].LocResource[I], Radius);1938 V21_to_Loc(ColonyShipPlan[Part].LocResource[I], Radius); 1941 1939 for V21 := 1 to 26 do 1942 begin // check all potential cities in range1940 begin // Check all potential cities in range 1943 1941 CityLoc := Radius[V21]; 1944 1942 if CityLoc >= 0 then … … 1990 1988 begin 1991 1989 BestScore := Score; 1992 ColonyShipPlan[ part].LocFoundCity[1993 ColonyShipPlan[ part].nLocFoundCity] :=1990 ColonyShipPlan[Part].LocFoundCity[ 1991 ColonyShipPlan[Part].nLocFoundCity] := 1994 1992 CityLoc; 1995 1993 end; … … 1998 1996 end; 1999 1997 if BestScore > 0 then 2000 Inc(ColonyShipPlan[ part].nLocFoundCity);1998 Inc(ColonyShipPlan[Part].nLocFoundCity); 2001 1999 end; 2002 2000 end; -
trunk/AI/StdAI/CustomAI.pas
r522 r531 682 682 function TCustomAI.DebugMessage(Level: Integer; Text: string): Boolean; 683 683 begin 684 Text := Copy('P' + char(48 + Me) + ' ' + Text, 1, 254);684 Text := Copy('P' + Char(48 + Me) + ' ' + Text, 1, 254); 685 685 Server(sMessage, Me, Level, PChar(Text)^); 686 686 -
trunk/AI/StdAI/CustomAI_Reload.pas
r522 r531 639 639 function TCustomAI.DebugMessage(Level: Integer; Text: string): Boolean; 640 640 begin 641 Text := Copy('P' + char(48 + Me) + ' ' + Text, 1, 254);641 Text := Copy('P' + Char(48 + Me) + ' ' + Text, 1, 254); 642 642 Server(sMessage, Me, Level, PChar(Text)^); 643 643 -
trunk/AI/StdAI/ToolAI.pas
r522 r531 355 355 UnitsToAssign: Boolean; 356 356 Adjacent: TVicinity8Loc; 357 SettlerOfJobLoc, DistToLoc: array[0..lxmax * lymax - 1] of smallint;357 SettlerOfJobLoc, DistToLoc: array[0..lxmax * lymax - 1] of SmallInt; 358 358 // DistToLoc is only defined where SettlerOfJobLoc>=0 359 359 TileChecked: array[0..lxmax * lymax - 1] of Boolean; … … 471 471 I, J, Loc, Loc1, V8, Count, Kind, MostIndex: Integer; 472 472 Adjacent: TVicinity8Loc; 473 IndexOfID: array[0..lxmax * lymax - 1] of smallint;474 IDOfIndex: array[0..lxmax * lymax div 2 - 1] of smallint;473 IndexOfID: array[0..lxmax * lymax - 1] of SmallInt; 474 IDOfIndex: array[0..lxmax * lymax div 2 - 1] of SmallInt; 475 475 begin 476 476 FillChar(District, MapSize * 4, $FF); … … 1107 1107 nSelectedLoad, F, OriginContinent, A, B: Integer; 1108 1108 CompleteFlag, NotReachedFlag, ContinueUnit: Cardinal; 1109 IsComplete, ok, IsFirstLoc: Boolean;1109 IsComplete, Ok, IsFirstLoc: Boolean; 1110 1110 StartLocPtr, ArrivedEnd: pinteger; 1111 1111 Adjacent: TVicinity8Loc; … … 1113 1113 tuixSelectedLoad: array[0..15] of Integer; 1114 1114 Arrived: array[0..lxmax * lymax] of Cardinal; 1115 ResponsibleTransport: array[0..lxmax * lymax - 1] of smallint;1115 ResponsibleTransport: array[0..lxmax * lymax - 1] of SmallInt; 1116 1116 TurnsBeforeLoad: array[0..lxmax * lymax - 1] of ShortInt; 1117 1117 GroupComplete: array[0..lxmax * lymax - 1] of Boolean; … … 1191 1191 FillChar(ResponsibleTransport, MapSize * 2, $FF); // -1 1192 1192 FillChar(TurnsBeforeLoad, MapSize, $FF); // -1 1193 ok := False;1193 Ok := False; 1194 1194 for uix := 0 to RO.nUn - 1 do 1195 1195 if TransportAvailable[uix] > 0 then 1196 1196 begin 1197 ok := True;1197 Ok := True; 1198 1198 Pile.Put(MyUnit[uix].Loc, ($800 - MyUnit[uix].Movement) shl 12 + uix); 1199 1199 end; 1200 if not ok then // no transports1200 if not Ok then // no transports 1201 1201 begin 1202 1202 TransportPlan.LoadLoc := -1; … … 1392 1392 begin 1393 1393 Arrived[Loc0] := (Arrived[Loc0] or CompleteFlag) and not NotReachedFlag; 1394 continue;1394 Continue; 1395 1395 end; 1396 1396 IsComplete := True; … … 1400 1400 if Loc1 >= 0 then 1401 1401 begin 1402 ok := False;1402 Ok := False; 1403 1403 case CheckStep(MoveStyle, Time0, V8 and 1, ArriveTime, 1404 1404 RecoverTurns, Map[Loc0], Map[Loc1], False) of 1405 csOk: ok := True;1405 csOk: Ok := True; 1406 1406 csForbiddenTile: 1407 1407 ;// !!! don't check moving there again 1408 1408 csCheckTerritory: 1409 ok := RO.Territory[Loc1] = RO.Territory[Loc0];1409 Ok := RO.Territory[Loc1] = RO.Territory[Loc0]; 1410 1410 end; 1411 if ok and Pile.TestPut(Loc1, ArriveTime) then1411 if Ok and Pile.TestPut(Loc1, ArriveTime) then 1412 1412 if ArriveTime < $2000 then 1413 1413 Pile.Put(Loc1, ArriveTime)
Note:
See TracChangeset
for help on using the changeset viewer.