Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
a47ee7f8
"...svn:/svn.code.sf.net/p/irrlicht/code/trunk@5147" did not exist on "c7c5f166fe2a42e942400283b6db6667a400dd71"
Commit
a47ee7f8
authored
Jul 11, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor ai predict
parent
e0e5c7a6
Pipeline
#28317
passed with stages
in 11 minutes and 4 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
+22
-15
src/api/ygoAgent/schema.ts
src/api/ygoAgent/schema.ts
+17
-13
src/service/duel/agent.ts
src/service/duel/agent.ts
+4
-2
src/stores/matStore/types.ts
src/stores/matStore/types.ts
+1
-0
No files found.
src/api/ygoAgent/schema.ts
View file @
a47ee7f8
// TODO: 需要将 Schema 和 Convert 逻辑分开成两个文件
import
{
CardMeta
,
ygopro
}
from
"
@/api
"
;
import
{
extraCardTypes
}
from
"
@/common
"
;
import
{
CardType
}
from
"
@/stores/cardStore
"
;
...
...
@@ -422,22 +423,25 @@ export function convertDeckCard(meta: CardMeta): Card {
export
function
convertCard
(
card
:
CardType
,
player
:
number
):
Card
{
// TODO (ygo-agent): opponent's visible facedown cards (confirm_cards)
const
{
code
,
location
,
meta
,
counters
}
=
card
;
return
{
code
:
card
.
code
,
location
:
cardZoneToLocation
(
card
.
location
.
zone
),
sequence
:
card
.
location
.
sequence
,
controller
:
convertController
(
card
.
location
.
controller
,
player
),
position
:
convertPosition
(
card
.
location
.
position
),
overlay_sequence
:
convertOverlaySequence
(
card
.
location
),
attribute
:
numberToAttribute
(
card
.
meta
.
data
.
attribute
??
0
),
race
:
numberToRace
(
card
.
meta
.
data
.
race
??
0
),
level
:
card
.
meta
.
data
.
level
??
0
,
counter
:
getCounter
(
c
ard
.
c
ounters
),
code
,
location
:
cardZoneToLocation
(
location
.
zone
),
sequence
:
location
.
sequence
,
controller
:
convertController
(
location
.
controller
,
player
),
position
:
convertPosition
(
location
.
position
),
overlay_sequence
:
convertOverlaySequence
(
location
),
attribute
:
numberToAttribute
(
meta
.
data
.
attribute
??
0
),
race
:
numberToRace
(
meta
.
data
.
race
??
0
),
level
:
meta
.
data
.
level
??
0
,
counter
:
getCounter
(
counters
),
// TODO (ygo-agent): add negated
negated
:
false
,
attack
:
card
.
meta
.
data
.
atk
??
0
,
defense
:
card
.
meta
.
data
.
def
??
0
,
types
:
extraCardTypes
(
card
.
meta
.
data
.
type
??
0
).
map
(
numberToType
),
attack
:
meta
.
data
.
atk
??
0
,
defense
:
meta
.
data
.
def
??
0
,
types
:
extraCardTypes
(
meta
.
data
.
type
??
0
).
map
(
numberToType
),
};
}
...
...
src/service/duel/agent.ts
View file @
a47ee7f8
...
...
@@ -50,7 +50,7 @@ function computeSetDifference(a1: number[], a2: number[]): number[] {
return
difference
;
}
export
function
genInput
(
msg
:
ygopro
.
StocGameMessage
):
Input
{
export
function
gen
Agent
Input
(
msg
:
ygopro
.
StocGameMessage
):
Input
{
// 全局信息可以从 `matStore` 里面拿
const
mat
=
matStore
;
// 卡片信息可以从 `cardStore` 里面拿
...
...
@@ -125,6 +125,7 @@ async function sendRequest(req: PredictReq) {
throw
new
Error
(
"
Failed to get predict response
"
);
}
// TODO: 下面这些逻辑不应该在这个函数里面,应该在UI组件里面实现
const
preds
=
resp
.
predict_results
.
action_preds
;
const
actionIdx
=
argmax
(
preds
,
(
r
)
=>
r
.
prob
);
matStore
.
prevActionIndex
=
actionIdx
;
...
...
@@ -132,8 +133,9 @@ async function sendRequest(req: PredictReq) {
return
pred
;
}
// TODO: 这个函数的逻辑也需要拆分下
export
async
function
sendAIPredictAsResponse
(
msg
:
ygopro
.
StocGameMessage
)
{
const
input
=
genInput
(
msg
);
const
input
=
gen
Agent
Input
(
msg
);
const
msgName
=
input
.
action_msg
.
data
.
msg_type
;
const
multiSelectMsgs
=
[
"
select_card
"
,
"
select_tribute
"
,
"
select_sum
"
];
...
...
src/stores/matStore/types.ts
View file @
a47ee7f8
...
...
@@ -50,6 +50,7 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
isMe
:
(
player
:
number
)
=>
boolean
;
// 下面其中一些貌似可以封装成为`AgentInfo`
turnCount
:
number
;
duelId
:
string
;
agentIndex
:
number
;
...
...
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