mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	ai fixes for android
This commit is contained in:
		
				
					committed by
					
						 Andrii Danylchenko
						Andrii Danylchenko
					
				
			
			
				
	
			
			
			
						parent
						
							14adf1d108
						
					
				
				
					commit
					531d0af95b
				
			| @@ -205,14 +205,7 @@ bool isSafeToVisit(HeroPtr h, const CCreatureSet * heroArmy, uint64_t dangerStre | ||||
|  | ||||
| 	if(dangerStrength) | ||||
| 	{ | ||||
| 		if(heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 		return heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength; | ||||
| 	} | ||||
|  | ||||
| 	return true; //there's no danger | ||||
| @@ -319,8 +312,6 @@ bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2 | ||||
|  | ||||
| 	if(art1->price == art2->price) | ||||
| 		return art1->valOfBonuses(Bonus::PRIMARY_SKILL) > art2->valOfBonuses(Bonus::PRIMARY_SKILL); | ||||
| 	else if(art1->price > art2->price) | ||||
| 		return true; | ||||
| 	else | ||||
| 		return false; | ||||
| 		return art1->price > art2->price; | ||||
| } | ||||
|   | ||||
| @@ -47,7 +47,7 @@ std::vector<SlotInfo> ArmyManager::getSortedSlots(const CCreatureSet * target, c | ||||
| 	for(auto pair : creToPower) | ||||
| 		resultingArmy.push_back(pair.second); | ||||
|  | ||||
| 	boost::sort(resultingArmy, [](SlotInfo & left, SlotInfo & right) -> bool | ||||
| 	boost::sort(resultingArmy, [](const SlotInfo & left, const SlotInfo & right) -> bool | ||||
| 	{ | ||||
| 		return left.power > right.power; | ||||
| 	}); | ||||
| @@ -57,7 +57,7 @@ std::vector<SlotInfo> ArmyManager::getSortedSlots(const CCreatureSet * target, c | ||||
|  | ||||
| std::vector<SlotInfo>::iterator ArmyManager::getWeakestCreature(std::vector<SlotInfo> & army) const | ||||
| { | ||||
| 	auto weakest = boost::min_element(army, [](SlotInfo & left, SlotInfo & right) -> bool | ||||
| 	auto weakest = boost::min_element(army, [](const SlotInfo & left, const SlotInfo & right) -> bool | ||||
| 	{ | ||||
| 		if(left.creature->level != right.creature->level) | ||||
| 			return left.creature->level < right.creature->level; | ||||
|   | ||||
| @@ -225,10 +225,7 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) | ||||
| 		if (buildingInfo.first > 43) | ||||
| 			extraBuildings.push_back(buildingInfo.first); | ||||
| 	} | ||||
| 	if (tryBuildAnyStructure(t, extraBuildings)) | ||||
| 		return true; | ||||
|  | ||||
| 	return false; | ||||
| 	return tryBuildAnyStructure(t, extraBuildings); | ||||
| } | ||||
|  | ||||
| BuildingID BuildingManager::getMaxPossibleGoldBuilding(const CGTownInstance * t) | ||||
|   | ||||
| @@ -1,10 +1,3 @@ | ||||
| if(FL_FOUND) | ||||
| 	include_directories(${FL_INCLUDE_DIRS}) | ||||
| else() | ||||
| 	include_directories(${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite) | ||||
| endif() | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) | ||||
|  | ||||
| set(VCAI_SRCS | ||||
| 		StdInc.cpp | ||||
|  | ||||
| @@ -135,10 +128,18 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l | ||||
| endif() | ||||
|  | ||||
| add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS}) | ||||
|  | ||||
| if(FL_FOUND) | ||||
| 	target_link_libraries(VCAI ${FL_LIBRARIES} vcmi) | ||||
| 	target_include_directories(VCAI PUBLIC ${FL_INCLUDE_DIRS}) | ||||
| else() | ||||
| 	target_link_libraries(VCAI fl-static vcmi) | ||||
| 	target_include_directories(VCAI PUBLIC ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite) | ||||
| endif() | ||||
| target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||||
|  | ||||
| if(FL_FOUND) | ||||
| 	target_link_libraries(VCAI PRIVATE ${FL_LIBRARIES} vcmi) | ||||
| else() | ||||
| 	target_link_libraries(VCAI PRIVATE fl-static vcmi) | ||||
| endif() | ||||
|  | ||||
| vcmi_set_output_dir(VCAI "AI") | ||||
|   | ||||
| @@ -1307,10 +1307,7 @@ bool VCAI::isGoodForVisit(const CGObjectInstance * obj, HeroPtr h, const AIPath | ||||
| 	const CGObjectInstance * topObj = cb->getVisitableObjs(obj->visitablePos()).back(); //it may be hero visiting this obj | ||||
| 																						//we don't try visiting object on which allied or owned hero stands | ||||
| 																						// -> it will just trigger exchange windows and AI will be confused that obj behind doesn't get visited | ||||
| 	if (topObj->ID == Obj::HERO && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != PlayerRelations::ENEMIES) | ||||
| 		return false; | ||||
| 	else | ||||
| 		return true; //all of the following is met | ||||
| 	return !(topObj->ID == Obj::HERO && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != PlayerRelations::ENEMIES); //all of the following is met | ||||
| } | ||||
|  | ||||
| bool VCAI::isTileNotReserved(const CGHeroInstance * h, int3 t) const | ||||
|   | ||||
| @@ -141,6 +141,7 @@ | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="AIhelper.cpp" /> | ||||
|     <ClCompile Include="AIUtility.cpp" /> | ||||
|     <ClCompile Include="ArmyManager.cpp" /> | ||||
|     <ClCompile Include="BuildingManager.cpp" /> | ||||
|     <ClCompile Include="FuzzyEngines.cpp" /> | ||||
|     <ClCompile Include="FuzzyHelper.cpp" /> | ||||
| @@ -168,6 +169,7 @@ | ||||
|     <ClCompile Include="Goals\Win.cpp" /> | ||||
|     <ClCompile Include="main.cpp" /> | ||||
|     <ClCompile Include="MapObjectsEvaluator.cpp" /> | ||||
|     <ClInclude Include="ArmyManager.h" /> | ||||
|     <ClInclude Include="Pathfinding\Actions\BattleAction.h" /> | ||||
|     <ClInclude Include="Pathfinding\Actions\TownPortalAction.h" /> | ||||
|     <ClCompile Include="Pathfinding\Actions\BattleAction.cpp" /> | ||||
|   | ||||
| @@ -111,6 +111,7 @@ | ||||
|     <ClCompile Include="Pathfinding\Rules\AIPreviousNodeRule.cpp"> | ||||
|       <Filter>Pathfinding\Rules</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="ArmyManager.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="AIhelper.h" /> | ||||
| @@ -234,6 +235,7 @@ | ||||
|     <ClInclude Include="Pathfinding\Rules\AIPreviousNodeRule.h"> | ||||
|       <Filter>Pathfinding\Rules</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="ArmyManager.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="Pathfinding"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user