Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
W
windbot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tang Xinwei
windbot
Commits
82ca5227
Commit
82ca5227
authored
Mar 24, 2021
by
wind2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update PickExecutor
parent
dcd2ad00
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
214 additions
and
11 deletions
+214
-11
Game/AI/Decks/PickExecutor.cs
Game/AI/Decks/PickExecutor.cs
+214
-11
No files found.
Game/AI/Decks/PickExecutor.cs
View file @
82ca5227
...
@@ -18,26 +18,116 @@ namespace WindBot.Game.AI.Decks
...
@@ -18,26 +18,116 @@ namespace WindBot.Game.AI.Decks
public
PickExecutor
(
GameAI
ai
,
Duel
duel
)
public
PickExecutor
(
GameAI
ai
,
Duel
duel
)
:
base
(
ai
,
duel
)
:
base
(
ai
,
duel
)
{
{
AddExecutor
(
ExecutorType
.
SpSummon
);
AddExecutor
(
ExecutorType
.
Activate
,
ImFeelingLucky
);
AddExecutor
(
ExecutorType
.
Activate
,
DefaultDontChainMyself
);
AddExecutor
(
ExecutorType
.
SpSummon
,
ImFeelingLucky
);
AddExecutor
(
ExecutorType
.
SummonOrSet
);
AddExecutor
(
ExecutorType
.
SpSummon
,
ImFeelingUnlucky
);
AddExecutor
(
ExecutorType
.
Activate
,
ImFeelingUnlucky
);
AddExecutor
(
ExecutorType
.
SummonOrSet
,
ImFeelingLazy
);
AddExecutor
(
ExecutorType
.
SpellSet
,
DefaultSpellSet
);
AddExecutor
(
ExecutorType
.
Repos
,
DefaultMonsterRepos
);
AddExecutor
(
ExecutorType
.
Repos
,
DefaultMonsterRepos
);
AddExecutor
(
ExecutorType
.
SpellSet
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
MysticalSpaceTyphoon
,
DefaultMysticalSpaceTyphoon
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
CosmicCyclone
,
DefaultCosmicCyclone
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
GalaxyCyclone
,
DefaultGalaxyCyclone
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
BookOfMoon
,
DefaultBookOfMoon
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
CompulsoryEvacuationDevice
,
DefaultCompulsoryEvacuationDevice
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
CallOfTheHaunted
,
DefaultCallOfTheHaunted
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
Scapegoat
,
DefaultScapegoat
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
MaxxC
,
DefaultMaxxC
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
AshBlossom
,
DefaultAshBlossomAndJoyousSpring
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
GhostOgreAndSnowRabbit
,
DefaultGhostOgreAndSnowRabbit
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
GhostBelle
,
DefaultGhostBelleAndHauntedMansion
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
EffectVeiler
,
DefaultEffectVeiler
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
CalledByTheGrave
,
DefaultCalledByTheGrave
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
InfiniteImpermanence
,
DefaultInfiniteImpermanence
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
BreakthroughSkill
,
DefaultBreakthroughSkill
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
SolemnJudgment
,
DefaultSolemnJudgment
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
SolemnWarning
,
DefaultSolemnWarning
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
SolemnStrike
,
DefaultSolemnStrike
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
TorrentialTribute
,
DefaultTorrentialTribute
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
HeavyStorm
,
DefaultHeavyStorm
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
HarpiesFeatherDuster
,
DefaultHarpiesFeatherDusterFirst
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
HammerShot
,
DefaultHammerShot
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
DarkHole
,
DefaultDarkHole
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
Raigeki
,
DefaultRaigeki
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
SmashingGround
,
DefaultSmashingGround
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
PotOfDesires
,
DefaultPotOfDesires
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
AllureofDarkness
,
DefaultAllureofDarkness
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
DimensionalBarrier
,
DefaultDimensionalBarrier
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
InterruptedKaijuSlumber
,
DefaultInterruptedKaijuSlumber
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
JizukirutheStarDestroyingKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
GadarlatheMysteryDustKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
GamecieltheSeaTurtleKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
RadiantheMultidimensionalKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
KumongoustheStickyStringKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
ThunderKingtheLightningstrikeKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
DogorantheMadFlameKaiju
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
SuperAntiKaijuWarMachineMechaDogoran
,
DefaultKaijuSpsummon
);
AddExecutor
(
ExecutorType
.
SpSummon
,
_CardId
.
EvilswarmExcitonKnight
,
DefaultEvilswarmExcitonKnightSummon
);
AddExecutor
(
ExecutorType
.
Activate
,
_CardId
.
EvilswarmExcitonKnight
,
DefaultEvilswarmExcitonKnightEffect
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
SandaionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
GabrionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
MichionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
ZaphionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
HailonTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
RaphionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
SadionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
MetaionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
KamionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
LazionTheTimelord
,
DefaultTimelordSummon
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
LeftArmofTheForbiddenOne
,
JustDontIt
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
RightLegofTheForbiddenOne
,
JustDontIt
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
LeftLegofTheForbiddenOne
,
JustDontIt
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
RightArmofTheForbiddenOne
,
JustDontIt
);
AddExecutor
(
ExecutorType
.
Summon
,
_CardId
.
ExodiaTheForbiddenOne
,
JustDontIt
);
}
}
private
List
<
int
>
HintMsgForEnemy
=
new
List
<
int
>
{
HintMsg
.
Release
,
HintMsg
.
Destroy
,
HintMsg
.
Remove
,
HintMsg
.
ToGrave
,
HintMsg
.
ReturnToHand
,
HintMsg
.
ToDeck
,
HintMsg
.
FusionMaterial
,
HintMsg
.
SynchroMaterial
,
HintMsg
.
XyzMaterial
,
HintMsg
.
LinkMaterial
,
HintMsg
.
Disable
};
private
List
<
int
>
HintMsgForDeck
=
new
List
<
int
>
{
HintMsg
.
SpSummon
,
HintMsg
.
ToGrave
,
HintMsg
.
Remove
,
HintMsg
.
AddToHand
,
HintMsg
.
FusionMaterial
};
private
List
<
int
>
HintMsgForSelf
=
new
List
<
int
>
{
HintMsg
.
Equip
};
private
List
<
int
>
HintMsgForMaterial
=
new
List
<
int
>
{
HintMsg
.
FusionMaterial
,
HintMsg
.
SynchroMaterial
,
HintMsg
.
XyzMaterial
,
HintMsg
.
LinkMaterial
,
HintMsg
.
Release
};
private
List
<
int
>
HintMsgForMaxSelect
=
new
List
<
int
>
{
HintMsg
.
SpSummon
,
HintMsg
.
ToGrave
,
HintMsg
.
AddToHand
,
HintMsg
.
FusionMaterial
,
HintMsg
.
Destroy
};
IList
<
ClientCard
>
picked
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
picked
=
new
List
<
ClientCard
>();
public
override
IList
<
ClientCard
>
OnSelectCard
(
IList
<
ClientCard
>
cards
,
int
min
,
int
max
,
int
hint
,
bool
cancelable
)
public
override
IList
<
ClientCard
>
OnSelectCard
(
IList
<
ClientCard
>
_
cards
,
int
min
,
int
max
,
int
hint
,
bool
cancelable
)
{
{
if
(
hint
==
507
&&
Duel
.
Turn
==
1
)
// from 2pick
if
(
hint
==
HintMsg
.
ToDeck
&&
Duel
.
Turn
==
1
)
{
{
Logger
.
DebugWriteLine
(
"Call SelectCard with
hint 507
"
);
Logger
.
DebugWriteLine
(
"Call SelectCard with
HintMsg.ToDeck
"
);
if
(
cancelable
)
if
(
cancelable
)
{
{
IList
<
ClientCard
>
submit
=
picked
;
IList
<
ClientCard
>
submit
=
picked
;
picked
.
Clear
();
picked
.
Clear
();
return
submit
;
return
submit
;
}
}
ClientCard
thispick
=
cards
[
Program
.
Rand
.
Next
(
cards
.
Count
)];
ClientCard
thispick
=
_cards
[
Program
.
Rand
.
Next
(
_
cards
.
Count
)];
IList
<
ClientCard
>
group
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
group
=
new
List
<
ClientCard
>();
group
.
Add
(
thispick
);
group
.
Add
(
thispick
);
picked
.
Add
(
thispick
);
picked
.
Add
(
thispick
);
...
@@ -45,11 +135,89 @@ namespace WindBot.Game.AI.Decks
...
@@ -45,11 +135,89 @@ namespace WindBot.Game.AI.Decks
}
}
if
(
Duel
.
Phase
==
DuelPhase
.
BattleStart
)
if
(
Duel
.
Phase
==
DuelPhase
.
BattleStart
)
return
null
;
return
null
;
if
(
AI
.
HaveSelectedCards
())
return
null
;
// from lucky
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
cards
=
new
List
<
ClientCard
>(
_cards
);
if
(
max
>
cards
.
Count
)
max
=
cards
.
Count
;
// select the last cards
if
(
HintMsgForEnemy
.
Contains
(
hint
))
for
(
int
i
=
1
;
i
<=
max
;
++
i
)
{
selected
.
Add
(
cards
[
cards
.
Count
-
i
]);
IList
<
ClientCard
>
enemyCards
=
cards
.
Where
(
card
=>
card
.
Controller
==
1
).
ToList
();
// select enemy's card first
while
(
enemyCards
.
Count
>
0
&&
selected
.
Count
<
max
)
{
ClientCard
card
=
enemyCards
[
Program
.
Rand
.
Next
(
enemyCards
.
Count
)];
selected
.
Add
(
card
);
enemyCards
.
Remove
(
card
);
cards
.
Remove
(
card
);
}
}
if
(
HintMsgForDeck
.
Contains
(
hint
))
{
IList
<
ClientCard
>
deckCards
=
cards
.
Where
(
card
=>
card
.
Location
==
CardLocation
.
Deck
).
ToList
();
// select deck's card first
while
(
deckCards
.
Count
>
0
&&
selected
.
Count
<
max
)
{
ClientCard
card
=
deckCards
[
Program
.
Rand
.
Next
(
deckCards
.
Count
)];
selected
.
Add
(
card
);
deckCards
.
Remove
(
card
);
cards
.
Remove
(
card
);
}
}
if
(
HintMsgForSelf
.
Contains
(
hint
))
{
IList
<
ClientCard
>
botCards
=
cards
.
Where
(
card
=>
card
.
Controller
==
0
).
ToList
();
// select bot's card first
while
(
botCards
.
Count
>
0
&&
selected
.
Count
<
max
)
{
ClientCard
card
=
botCards
[
Program
.
Rand
.
Next
(
botCards
.
Count
)];
selected
.
Add
(
card
);
botCards
.
Remove
(
card
);
cards
.
Remove
(
card
);
}
}
if
(
HintMsgForMaterial
.
Contains
(
hint
))
{
IList
<
ClientCard
>
materials
=
cards
.
OrderBy
(
card
=>
card
.
Attack
).
ToList
();
// select low attack first
while
(
materials
.
Count
>
0
&&
selected
.
Count
<
min
)
{
ClientCard
card
=
materials
[
0
];
selected
.
Add
(
card
);
materials
.
Remove
(
card
);
cards
.
Remove
(
card
);
}
}
// select random cards
while
(
selected
.
Count
<
min
)
{
ClientCard
card
=
cards
[
Program
.
Rand
.
Next
(
cards
.
Count
)];
selected
.
Add
(
card
);
cards
.
Remove
(
card
);
}
if
(
HintMsgForMaxSelect
.
Contains
(
hint
))
{
// select max cards
while
(
selected
.
Count
<
max
)
{
ClientCard
card
=
cards
[
Program
.
Rand
.
Next
(
cards
.
Count
)];
selected
.
Add
(
card
);
cards
.
Remove
(
card
);
}
}
return
selected
;
return
selected
;
}
}
...
@@ -59,5 +227,40 @@ namespace WindBot.Game.AI.Decks
...
@@ -59,5 +227,40 @@ namespace WindBot.Game.AI.Decks
return
Program
.
Rand
.
Next
(
options
.
Count
);
return
Program
.
Rand
.
Next
(
options
.
Count
);
}
}
public
override
CardPosition
OnSelectPosition
(
int
cardId
,
IList
<
CardPosition
>
positions
)
{
YGOSharp
.
OCGWrapper
.
NamedCard
cardData
=
YGOSharp
.
OCGWrapper
.
NamedCard
.
Get
(
cardId
);
if
(
cardData
!=
null
)
{
if
(
cardData
.
Attack
<
0
)
return
CardPosition
.
FaceUpAttack
;
if
(
cardData
.
Attack
<=
1000
)
return
CardPosition
.
FaceUpDefence
;
}
return
0
;
}
private
bool
ImFeelingLucky
()
{
return
Program
.
Rand
.
Next
(
10
)
>=
5
&&
DefaultDontChainMyself
();
}
private
bool
ImFeelingUnlucky
()
{
return
DefaultDontChainMyself
();
}
private
bool
ImFeelingLazy
()
{
if
(
Executors
.
Any
(
exec
=>
(
exec
.
Type
==
ExecutorType
.
SummonOrSet
||
exec
.
Type
==
ExecutorType
.
Summon
||
exec
.
Type
==
ExecutorType
.
MonsterSet
)
&&
exec
.
CardId
==
Card
.
Id
))
return
false
;
return
DefaultMonsterSummon
();
}
private
bool
JustDontIt
()
{
return
false
;
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment