신규 AI 구현 준비
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class AutorunGeneralPolicy{
|
||||
|
||||
// 일반장 행동
|
||||
static $일반내정 = '일반내정';
|
||||
static $긴급내정 = '긴급내정'; //민심 ~50
|
||||
static $전쟁내정 = '전쟁내정'; //인구 ~50%, 민심 ~90
|
||||
|
||||
static $금쌀구매 = '금쌀구매';
|
||||
static $상인무시 = '상인무시';
|
||||
|
||||
static $징병 = '징병';
|
||||
static $모병 = '모병';
|
||||
static $한계징병 = '한계징병';
|
||||
static $고급병종 = '고급병종';
|
||||
static $전투준비 = '전투준비';
|
||||
public $소집해제 = '소집해제';
|
||||
|
||||
static $출병 = '출병';
|
||||
|
||||
static $NPC증여 = 'NPC증여';
|
||||
static $NPC헌납 = 'NPC헌납';
|
||||
|
||||
static $후방워프 = '후방워프';
|
||||
static $전방워프 = '전방워프';
|
||||
static $내정워프 = '내정워프';
|
||||
|
||||
static $귀환 = '귀환';
|
||||
//static $전투이동 = '전투이동';
|
||||
//static $내정이동 = '내정이동';
|
||||
|
||||
static $임관 = '임관';
|
||||
static $집합 = '집합';
|
||||
static $건국 = '건국';
|
||||
static $선양 = '선양';
|
||||
|
||||
|
||||
static public $priority = [
|
||||
'귀환',
|
||||
'금쌀구매',
|
||||
'출병',
|
||||
'긴급내정',
|
||||
'전투준비',
|
||||
'전방워프',
|
||||
'NPC증여',
|
||||
'NPC헌납',
|
||||
'징병',
|
||||
'후방워프',
|
||||
'전쟁내정',
|
||||
'소집해제',
|
||||
'일반내정',
|
||||
'내정워프'
|
||||
];
|
||||
|
||||
|
||||
public $can일반내정 = true;
|
||||
public $can긴급내정 = true;
|
||||
public $can전쟁내정 = true;
|
||||
|
||||
public $can금쌀구매 = true;
|
||||
public $can상인무시 = true;
|
||||
|
||||
public $can징병 = true;
|
||||
public $can모병 = true;
|
||||
public $can한계징병 = true;
|
||||
public $can고급병종 = true;
|
||||
public $can전투준비 = true;
|
||||
public $can소집해제 = true;
|
||||
|
||||
public $can출병 = true;
|
||||
|
||||
public $canNPC증여 = true;
|
||||
public $canNPC헌납 = true;
|
||||
|
||||
public $can후방워프 = true;
|
||||
public $can전방워프 = true;
|
||||
public $can내정워프 = true;
|
||||
|
||||
public $can귀환 = true;
|
||||
|
||||
public $can임관 = true;
|
||||
public $can집합 = false;
|
||||
public $can건국 = true;
|
||||
public $can선양 = false;
|
||||
|
||||
function doNPCState(General $general){
|
||||
$npc = $general->getVar('npc');
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
if($npc==5){
|
||||
$this->can선양 = true;
|
||||
$this->can집합 = true;
|
||||
$this->can임관 = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if($nationID != 0){
|
||||
$this->can임관 = false;
|
||||
$this->can건국 = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function __construct(General $general, $aiOptions){
|
||||
|
||||
|
||||
if($general->getVar('npc') >= 2){
|
||||
$this->doNPCState($general);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->can일반내정 = false;
|
||||
$this->can긴급내정 = false;
|
||||
$this->can전쟁내정 = false;
|
||||
|
||||
$this->can금쌀구매 = false;
|
||||
$this->can상인무시 = false;
|
||||
|
||||
$this->can징병 = false;
|
||||
$this->can모병 = false;
|
||||
$this->can한계징병 = true;
|
||||
$this->can고급병종 = true;
|
||||
$this->can전투준비 = false;
|
||||
|
||||
$this->can출병 = false;
|
||||
|
||||
$this->canNPC증여 = false;
|
||||
$this->canNPC헌납 = false;
|
||||
|
||||
$this->can후방워프 = false;
|
||||
$this->can전방워프 = false;
|
||||
$this->can내정워프 = false;
|
||||
|
||||
$this->can임관 = false;
|
||||
$this->can집합 = false;
|
||||
$this->can건국 = false;
|
||||
$this->can선양 = false;
|
||||
|
||||
foreach($aiOptions as $key=>$value){
|
||||
assert($value);
|
||||
switch($key){
|
||||
case 'develop':
|
||||
$this->can일반내정 = true;
|
||||
//유저장은 '긴급'을 하지 않음
|
||||
$this->can전쟁내정 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
break;
|
||||
case 'warp':
|
||||
$this->can후방워프 = true;
|
||||
$this->can전방워프 = true;
|
||||
$this->can내정워프 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
$this->can상인무시 = true;
|
||||
break;
|
||||
case 'recruit_high':
|
||||
$this->can모병 = true;
|
||||
case 'recruit':
|
||||
$this->can징병 = true;
|
||||
$this->can소집해제 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
break;
|
||||
case 'train':
|
||||
$this->can전투준비 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
break;
|
||||
case 'battle':
|
||||
$this->can출병 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class AutorunNationPolicy {
|
||||
|
||||
// 수뇌 행동
|
||||
static $부대전방발령 = '부대전방발령';
|
||||
static $부대후방발령 = '부대후방발령';
|
||||
|
||||
static $부대유저장후방발령 = '부대유저장후방발령';
|
||||
static $유저장후방발령 = '유저장후방발령';
|
||||
static $유저장전방발령 = '유저장전방발령';
|
||||
|
||||
static $NPC후방발령 = 'NPC후방발령';
|
||||
static $NPC전방발령 = 'NPC전방발령';
|
||||
|
||||
static $유저장긴급포상 = '유저장긴급포상';
|
||||
static $유저장포상 = '유저장포상';
|
||||
static $유저장몰수 = '유저장몰수';
|
||||
|
||||
static $NPC긴급포상 = 'NPC긴급포상';
|
||||
static $NPC포상 = 'NPC포상';
|
||||
static $NPC몰수 = 'NPC몰수';
|
||||
|
||||
// 군주 행동
|
||||
static $선포 = '선포';
|
||||
static $천도 = '천도';
|
||||
|
||||
//실제 행동
|
||||
static public $defaultPriority = [
|
||||
'선포',
|
||||
'천도',
|
||||
|
||||
'유저장긴급포상',
|
||||
'부대전방발령',
|
||||
|
||||
'유저장후방발령',
|
||||
'부대유저장후방발령',
|
||||
|
||||
'유저장전방발령',
|
||||
'유저장포상',
|
||||
|
||||
'유저장몰수',
|
||||
'부대후방발령',
|
||||
|
||||
'NPC긴급포상',
|
||||
|
||||
'NPC후방발령',
|
||||
|
||||
'NPC포상',
|
||||
'NPC몰수',
|
||||
|
||||
'NPC전방발령',
|
||||
];
|
||||
|
||||
public $priority = [];
|
||||
|
||||
public $can부대전방발령 = true;
|
||||
public $can부대후방발령 = true;
|
||||
|
||||
public $can부대유저장후방발령 = true;
|
||||
public $can유저장후방발령 = true;
|
||||
public $can유저장전방발령 = true;
|
||||
|
||||
public $canNPC후방발령 = true;
|
||||
public $canNPC전방발령 = true;
|
||||
|
||||
public $can유저장긴급포상 = true;
|
||||
public $can유저장포상 = true;
|
||||
public $can유저장몰수 = true;
|
||||
|
||||
public $canNPC긴급포상 = true;
|
||||
public $canNPC포상 = true;
|
||||
public $canNPC몰수 = true;
|
||||
|
||||
public $can선포 = false;
|
||||
public $can천도 = false;
|
||||
|
||||
//Policy Variables
|
||||
public $reqNationGold = 10000;
|
||||
public $reqNationRice = 10000;
|
||||
public $CombatForce = [
|
||||
[200, 10, 24],//troopLeader, fromCity, toCity
|
||||
[242, 10, 24]
|
||||
];
|
||||
public $SupportForce = [
|
||||
211
|
||||
];
|
||||
public $DevelopForce = [
|
||||
123
|
||||
];
|
||||
public $reqHumanWarGold = [10000, 30000];
|
||||
public $reqHumanWarRice = [10000, 30000];
|
||||
public $reqHumanDevelGold = 10000;
|
||||
public $reqHumanDevelRice = 10000;
|
||||
public $reqNPCWarGold = 5000;
|
||||
public $reqNPCWarRice = 5000;
|
||||
public $reqNPCDevelGold = 1000;
|
||||
public $reqNPCDevelRice = 0;
|
||||
|
||||
|
||||
|
||||
public $allowNpcAttackCity = true;
|
||||
public $minNPCRecruitCityPopulation = 50000;
|
||||
public $safeRecruitCityPopulation = 50000;
|
||||
|
||||
|
||||
function __construct(General $general, array $nationPolicy, array $serverPolicy)
|
||||
{
|
||||
foreach($serverPolicy as $policy=>$value){
|
||||
if(!property_exists($this, $policy)){
|
||||
throw new \InvalidArgumentException($policy);
|
||||
}
|
||||
$this->$policy = $value;
|
||||
}
|
||||
|
||||
foreach($nationPolicy as $policy){
|
||||
if(!property_exists($this, $policy)){
|
||||
throw new \InvalidArgumentException($policy);
|
||||
}
|
||||
$this->$policy = $value;
|
||||
}
|
||||
|
||||
if(!$this->priority){
|
||||
$this->priority = $this::$defaultPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@ class GeneralAI{
|
||||
protected $nation;
|
||||
protected $genType;
|
||||
|
||||
/** @var AutorunGeneralPolicy */
|
||||
protected $generalPolicy;
|
||||
/** @var AutorunNationPolicy */
|
||||
protected $nationPolicy;
|
||||
|
||||
protected $env;
|
||||
protected $baseDevelCost;
|
||||
|
||||
@@ -264,7 +269,7 @@ class GeneralAI{
|
||||
if($develRate['trust'] < 1){
|
||||
$commandObj = buildGeneralCommandClass('che_주민선정', $general, $env);
|
||||
if($commandObj->isRunnable()){
|
||||
$commandList['che_주민선정'] = power($leadership * 2, 1 / ($develRate['trust'] + 0.001));
|
||||
$commandList['che_주민선정'] = pow($leadership * 2, 1 / ($develRate['trust'] + 0.001));
|
||||
}
|
||||
}
|
||||
if($develRate['pop'] < 0.99){
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ CREATE TABLE `city` (
|
||||
`officer3set` INT(1) NOT NULL DEFAULT '0',
|
||||
`officer2set` INT(1) NOT NULL DEFAULT '0',
|
||||
`state` INT(2) NOT NULL DEFAULT '0',
|
||||
`region` INT(2) NOT NULL COMMENT 'TODO:Delete',
|
||||
`region` INT(2) NOT NULL,
|
||||
`term` INT(1) NOT NULL DEFAULT '0',
|
||||
`conflict` VARCHAR(500) NOT NULL DEFAULT '{}',
|
||||
PRIMARY KEY (`city`),
|
||||
|
||||
Reference in New Issue
Block a user