Changeset 531 for trunk/AI/StdAI/Barbarina.pas
- Timestamp:
- Mar 27, 2024, 12:31:14 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.