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
alstroemeria-silentlove
windbot
Commits
0e54b3fd
Commit
0e54b3fd
authored
Aug 19, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update OnSelectSum
parent
127cd4e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
15 deletions
+40
-15
Game/GameAI.cs
Game/GameAI.cs
+40
-15
No files found.
Game/GameAI.cs
View file @
0e54b3fd
using
YGOSharp.OCGWrapper.Enums
;
using
System.Linq
;
using
System.Collections.Generic
;
using
WindBot.Game.AI
;
...
...
@@ -369,28 +370,28 @@ namespace WindBot.Game
/// <returns></returns>
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
selected
=
Executor
.
OnSelectSum
(
cards
,
sum
,
min
,
max
,
mode
);
IList
<
ClientCard
>
selected
=
Executor
.
OnSelectSum
(
cards
,
sum
,
min
,
max
,
mode
);
if
(
selected
!=
null
)
{
return
selected
;
}
if
(
mode
)
{
// equal
if
(
min
<=
1
)
{
// try special level first
foreach
(
ClientCard
card
in
cards
)
{
// try special level
if
(
card
.
OpParam2
==
sum
)
{
return
new
[]
{
card
};
}
}
// try level equal
foreach
(
ClientCard
card
in
cards
)
{
// try level equal
if
(
card
.
OpParam1
==
sum
)
{
return
new
[]
{
card
};
...
...
@@ -398,6 +399,19 @@ namespace WindBot.Game
}
}
// try all
int
s1
=
0
,
s2
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
s1
+=
card
.
OpParam1
;
s2
+=
(
card
.
OpParam2
!=
0
)
?
card
.
OpParam2
:
card
.
OpParam1
;
}
if
(
s1
==
sum
||
s2
==
sum
)
{
return
cards
;
}
// try all combinations
int
i
=
(
min
<=
1
)
?
2
:
min
;
while
(
i
<=
max
&&
i
<=
cards
.
Count
)
{
...
...
@@ -406,17 +420,16 @@ namespace WindBot.Game
foreach
(
IEnumerable
<
ClientCard
>
combo
in
combos
)
{
Logger
.
DebugWriteLine
(
"--"
);
int
s1
=
0
,
s2
=
0
;
s
elected
=
new
List
<
ClientCard
>()
;
s1
=
0
;
s
2
=
0
;
foreach
(
ClientCard
card
in
combo
)
{
s1
+=
card
.
OpParam1
;
s2
+=
(
card
.
OpParam2
!=
0
)
?
card
.
OpParam2
:
card
.
OpParam1
;
selected
.
Add
(
card
);
}
if
(
s1
==
sum
||
s2
==
sum
)
{
return
selected
;
return
combo
.
ToList
()
;
}
}
i
++;
...
...
@@ -427,17 +440,17 @@ namespace WindBot.Game
// larger
if
(
min
<=
1
)
{
// try special level first
foreach
(
ClientCard
card
in
cards
)
{
// try special level
if
(
card
.
OpParam2
>=
sum
)
{
return
new
[]
{
card
};
}
}
// try level equal
foreach
(
ClientCard
card
in
cards
)
{
// try level equal
if
(
card
.
OpParam1
>=
sum
)
{
return
new
[]
{
card
};
...
...
@@ -445,6 +458,19 @@ namespace WindBot.Game
}
}
// try all
int
s1
=
0
,
s2
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
s1
+=
card
.
OpParam1
;
s2
+=
(
card
.
OpParam2
!=
0
)
?
card
.
OpParam2
:
card
.
OpParam1
;
}
if
(
s1
>=
sum
||
s2
>=
sum
)
{
return
cards
;
}
// try all combinations
int
i
=
(
min
<=
1
)
?
2
:
min
;
while
(
i
<=
max
&&
i
<=
cards
.
Count
)
{
...
...
@@ -453,17 +479,16 @@ namespace WindBot.Game
foreach
(
IEnumerable
<
ClientCard
>
combo
in
combos
)
{
Logger
.
DebugWriteLine
(
"----"
);
int
s1
=
0
,
s2
=
0
;
s
elected
=
new
List
<
ClientCard
>()
;
s1
=
0
;
s
2
=
0
;
foreach
(
ClientCard
card
in
combo
)
{
s1
+=
card
.
OpParam1
;
s2
+=
(
card
.
OpParam2
!=
0
)
?
card
.
OpParam2
:
card
.
OpParam1
;
selected
.
Add
(
card
);
}
if
(
s1
>=
sum
||
s2
>=
sum
)
{
return
selected
;
return
combo
.
ToList
()
;
}
}
i
++;
...
...
@@ -471,7 +496,7 @@ namespace WindBot.Game
}
Logger
.
WriteErrorLine
(
"Fail to select sum."
);
return
n
ull
;
return
n
ew
List
<
ClientCard
>()
;
}
/// <summary>
...
...
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