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
神之吹息
windbot
Commits
5fd17c2f
Commit
5fd17c2f
authored
Feb 03, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update SelectSum
parent
f0072db2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
46 deletions
+125
-46
Game/AI/Decks/BlueEyesExecutor.cs
Game/AI/Decks/BlueEyesExecutor.cs
+3
-1
Game/AI/Decks/NekrozExecutor.cs
Game/AI/Decks/NekrozExecutor.cs
+3
-2
Game/AI/Executor.cs
Game/AI/Executor.cs
+1
-1
Game/ClientCard.cs
Game/ClientCard.cs
+2
-0
Game/GameAI.cs
Game/GameAI.cs
+99
-34
Game/GameBehavior.cs
Game/GameBehavior.cs
+17
-8
No files found.
Game/AI/Decks/BlueEyesExecutor.cs
View file @
5fd17c2f
...
@@ -217,9 +217,11 @@ namespace MycardBot.Game.AI.Decks
...
@@ -217,9 +217,11 @@ namespace MycardBot.Game.AI.Decks
return
null
;
return
null
;
}
}
public
override
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
public
override
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
{
Logger
.
DebugWriteLine
(
"OnSelectSum "
+
cards
.
Count
+
" "
+
sum
+
" "
+
min
+
" "
+
max
);
Logger
.
DebugWriteLine
(
"OnSelectSum "
+
cards
.
Count
+
" "
+
sum
+
" "
+
min
+
" "
+
max
);
if
(
sum
>
12
||
!
mode
)
return
null
;
IList
<
ClientCard
>
avail
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
avail
=
new
List
<
ClientCard
>();
foreach
(
ClientCard
card
in
cards
)
foreach
(
ClientCard
card
in
cards
)
{
{
...
...
Game/AI/Decks/NekrozExecutor.cs
View file @
5fd17c2f
...
@@ -86,6 +86,7 @@ namespace WindBot.Game.AI.Decks
...
@@ -86,6 +86,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
千手神
,
千手神效果
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
千手神
,
千手神效果
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
万手神
,
光枪龙之影灵衣
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
万手神
,
光枪龙之影灵衣
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
虹光之宣告者
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
虹光之宣告者
);
AddExecutor
(
ExecutorType
.
Activate
,
(
int
)
CardId
.
影灵衣术士施里特
);
AddExecutor
(
ExecutorType
.
SpSummon
,
(
int
)
CardId
.
三叉龙之影灵衣
);
AddExecutor
(
ExecutorType
.
SpSummon
,
(
int
)
CardId
.
三叉龙之影灵衣
);
AddExecutor
(
ExecutorType
.
SpSummon
,
(
int
)
CardId
.
决战兵器之影灵衣
);
AddExecutor
(
ExecutorType
.
SpSummon
,
(
int
)
CardId
.
决战兵器之影灵衣
);
...
@@ -228,7 +229,7 @@ namespace WindBot.Game.AI.Decks
...
@@ -228,7 +229,7 @@ namespace WindBot.Game.AI.Decks
AI
.
SelectCard
((
int
)
CardId
.
尤尼科之影灵衣
);
AI
.
SelectCard
((
int
)
CardId
.
尤尼科之影灵衣
);
return
true
;
return
true
;
}
}
return
fals
e
;
return
tru
e
;
}
}
private
bool
千手神效果
()
private
bool
千手神效果
()
...
@@ -248,7 +249,7 @@ namespace WindBot.Game.AI.Decks
...
@@ -248,7 +249,7 @@ namespace WindBot.Game.AI.Decks
AI
.
SelectCard
((
int
)
CardId
.
尤尼科之影灵衣
);
AI
.
SelectCard
((
int
)
CardId
.
尤尼科之影灵衣
);
return
true
;
return
true
;
}
}
return
fals
e
;
return
tru
e
;
}
}
private
bool
尤尼科之影灵衣
()
private
bool
尤尼科之影灵衣
()
...
...
Game/AI/Executor.cs
View file @
5fd17c2f
...
@@ -104,7 +104,7 @@ namespace WindBot.Game.AI
...
@@ -104,7 +104,7 @@ namespace WindBot.Game.AI
return
null
;
return
null
;
}
}
public
virtual
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
public
virtual
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
{
return
null
;
return
null
;
}
}
...
...
Game/ClientCard.cs
View file @
5fd17c2f
...
@@ -32,6 +32,8 @@ namespace WindBot.Game
...
@@ -32,6 +32,8 @@ namespace WindBot.Game
public
int
Controller
{
get
;
private
set
;
}
public
int
Controller
{
get
;
private
set
;
}
public
int
Disabled
{
get
;
private
set
;
}
public
int
Disabled
{
get
;
private
set
;
}
public
int
SelectSeq
{
get
;
set
;
}
public
int
SelectSeq
{
get
;
set
;
}
public
int
OpParam1
{
get
;
set
;
}
public
int
OpParam2
{
get
;
set
;
}
public
bool
CanDirectAttack
{
get
;
set
;
}
public
bool
CanDirectAttack
{
get
;
set
;
}
public
bool
ShouldDirectAttack
{
get
;
set
;
}
public
bool
ShouldDirectAttack
{
get
;
set
;
}
public
bool
Attacked
{
get
;
set
;
}
public
bool
Attacked
{
get
;
set
;
}
...
...
Game/GameAI.cs
View file @
5fd17c2f
...
@@ -360,26 +360,46 @@ namespace WindBot.Game
...
@@ -360,26 +360,46 @@ namespace WindBot.Game
/// <param name="sum">Result of the operation.</param>
/// <param name="sum">Result of the operation.</param>
/// <param name="min">Minimum cards.</param>
/// <param name="min">Minimum cards.</param>
/// <param name="max">Maximum cards.</param>
/// <param name="max">Maximum cards.</param>
/// <param name="mode">True for equal.</param>
/// <returns></returns>
/// <returns></returns>
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
{
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
selected
=
Executor
.
OnSelectSum
(
cards
,
sum
,
min
,
max
);
selected
=
Executor
.
OnSelectSum
(
cards
,
sum
,
min
,
max
,
mode
);
if
(
selected
!=
null
)
if
(
selected
!=
null
)
{
{
return
selected
;
return
selected
;
}
}
if
(
mode
)
{
foreach
(
ClientCard
card
in
cards
)
{
//Logger.WriteLine("OpParam1 " + card.OpParam1 + " OpParam2 " + card.OpParam2 + " sum " + sum);
// try special level
if
(
card
.
OpParam2
==
sum
)
{
return
new
[]
{
card
};
}
}
foreach
(
ClientCard
card
in
cards
)
{
// try level equal
if
(
card
.
OpParam1
==
sum
)
{
return
new
[]
{
card
};
}
}
selected
=
new
List
<
ClientCard
>();
selected
=
new
List
<
ClientCard
>();
int
trysum
=
0
;
int
trysum
=
0
;
foreach
(
ClientCard
card
in
cards
)
foreach
(
ClientCard
card
in
cards
)
{
{
// try level add
// try level add
if
(
trysum
+
card
.
Level
>
sum
)
if
(
trysum
+
card
.
OpParam1
>
sum
)
{
{
continue
;
continue
;
}
}
selected
.
Add
(
card
);
selected
.
Add
(
card
);
trysum
+=
card
.
Level
;
trysum
+=
card
.
OpParam1
;
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(trysum + " selected " + sum);
//Logger.DebugWriteLine(trysum + " selected " + sum);
if
(
trysum
==
sum
)
if
(
trysum
==
sum
)
...
@@ -397,7 +417,7 @@ namespace WindBot.Game
...
@@ -397,7 +417,7 @@ namespace WindBot.Game
{
{
// try level sub
// try level sub
selected2
.
Remove
(
card
);
selected2
.
Remove
(
card
);
trysum
-=
card
.
Level
;
trysum
-=
card
.
OpParam1
;
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(trysum + " selected2 " + sum);
//Logger.DebugWriteLine(trysum + " selected2 " + sum);
if
(
trysum
==
sum
)
if
(
trysum
==
sum
)
...
@@ -405,14 +425,59 @@ namespace WindBot.Game
...
@@ -405,14 +425,59 @@ namespace WindBot.Game
return
selected2
;
return
selected2
;
}
}
}
}
}
else
{
foreach
(
ClientCard
card
in
cards
)
{
//Logger.WriteLine("OpParam1 " + card.OpParam1 + " OpParam2 " + card.OpParam2 + " sum " + sum);
// try special level
if
(
card
.
OpParam2
>=
sum
)
{
return
new
[]
{
card
};
}
}
foreach
(
ClientCard
card
in
cards
)
foreach
(
ClientCard
card
in
cards
)
{
{
// try level equal
// try level equal
if
(
card
.
Level
=
=
sum
)
if
(
card
.
OpParam1
>
=
sum
)
{
{
return
new
[]
{
card
};
return
new
[]
{
card
};
}
}
}
}
selected
=
new
List
<
ClientCard
>();
int
trysum
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
// try level add
selected
.
Add
(
card
);
trysum
+=
card
.
OpParam1
;
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(trysum + " selected " + sum);
if
(
trysum
>=
sum
)
{
return
selected
;
}
}
IList
<
ClientCard
>
selected2
=
new
List
<
ClientCard
>();
foreach
(
ClientCard
card
in
selected
)
{
// clone
selected2
.
Add
(
card
);
}
foreach
(
ClientCard
card
in
selected
)
{
// try level sub
selected2
.
Remove
(
card
);
trysum
-=
card
.
OpParam1
;
//Logger.DebugWriteLine(card.Id + "");
//Logger.DebugWriteLine(trysum + " selected2 " + sum);
if
(
trysum
>=
sum
)
{
return
selected2
;
}
}
}
// try all
// try all
return
cards
;
return
cards
;
}
}
...
...
Game/GameBehavior.cs
View file @
5fd17c2f
...
@@ -886,7 +886,7 @@ namespace WindBot.Game
...
@@ -886,7 +886,7 @@ namespace WindBot.Game
private
void
OnSelectSum
(
BinaryReader
packet
)
private
void
OnSelectSum
(
BinaryReader
packet
)
{
{
packet
.
ReadByte
();
// mode
bool
mode
=
packet
.
ReadByte
()
==
0
;
packet
.
ReadByte
();
// player
packet
.
ReadByte
();
// player
int
sumval
=
packet
.
ReadInt32
();
int
sumval
=
packet
.
ReadInt32
();
int
min
=
packet
.
ReadByte
();
int
min
=
packet
.
ReadByte
();
...
@@ -905,26 +905,35 @@ namespace WindBot.Game
...
@@ -905,26 +905,35 @@ namespace WindBot.Game
CardLocation
loc
=
(
CardLocation
)
packet
.
ReadByte
();
CardLocation
loc
=
(
CardLocation
)
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
ClientCard
card
=
_duel
.
GetCard
(
player
,
loc
,
seq
);
ClientCard
card
=
_duel
.
GetCard
(
player
,
loc
,
seq
);
if
(
card
!=
null
)
{
if
(
cardId
!=
0
&&
card
.
Id
!=
cardId
)
if
(
cardId
!=
0
&&
card
.
Id
!=
cardId
)
card
.
SetId
(
cardId
);
card
.
SetId
(
cardId
);
card
.
SelectSeq
=
i
;
card
.
SelectSeq
=
i
;
int
OpParam
=
packet
.
ReadInt32
();
int
OpParam1
=
OpParam
&
0xffff
;
int
OpParam2
=
OpParam
>>
16
;
if
(
OpParam2
>
0
&&
OpParam1
>
OpParam2
)
{
card
.
OpParam1
=
OpParam2
;
card
.
OpParam2
=
OpParam1
;
}
else
{
card
.
OpParam1
=
OpParam1
;
card
.
OpParam2
=
OpParam2
;
}
}
if
(
j
==
0
)
if
(
j
==
0
)
mandatoryCards
.
Add
(
card
);
mandatoryCards
.
Add
(
card
);
else
else
cards
.
Add
(
card
);
cards
.
Add
(
card
);
packet
.
ReadInt32
();
}
}
}
}
for
(
int
k
=
0
;
k
<
mandatoryCards
.
Count
;
++
k
)
for
(
int
k
=
0
;
k
<
mandatoryCards
.
Count
;
++
k
)
{
{
sumval
-=
mandatoryCards
[
k
].
Level
;
sumval
-=
mandatoryCards
[
k
].
OpParam1
;
}
}
IList
<
ClientCard
>
selected
=
_ai
.
OnSelectSum
(
cards
,
sumval
,
min
,
max
);
IList
<
ClientCard
>
selected
=
_ai
.
OnSelectSum
(
cards
,
sumval
,
min
,
max
,
mode
);
byte
[]
result
=
new
byte
[
mandatoryCards
.
Count
+
selected
.
Count
+
1
];
byte
[]
result
=
new
byte
[
mandatoryCards
.
Count
+
selected
.
Count
+
1
];
int
index
=
0
;
int
index
=
0
;
...
...
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