Skip to content

Commit

Permalink
Updated docs. Fixed ML module API definitions. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Nov 5, 2024
1 parent bf87c71 commit e7e2638
Show file tree
Hide file tree
Showing 17 changed files with 5,826 additions and 492 deletions.
9 changes: 5 additions & 4 deletions Assets/Script/Lib/Dora/en/Dora.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6475,15 +6475,15 @@ class QLearner extends Object {
/**
* Update Q-value for a state-action pair based on received reward.
* @param state Representing the state.
* @param action Representing the action.
* @param action Representing the action. Must be greater than 0.
* @param reward Representing the reward received for the action in the state.
*/
update(state: number, action: number, reward: number): void;

/**
* Returns the best action for a given state based on the current Q-values.
* @param state The current state.
* @returns The action with the highest Q-value for the given state.
* @returns The action with the highest Q-value for the given state. Returns 0 if no action is available.
*/
getBestAction(state: number): number;

Expand All @@ -6504,15 +6504,15 @@ export namespace QLearner {
interface QLearnerClass {
/**
* Construct a state from given hints and condition values.
* @param hints Representing the byte length of provided values.
* @param hints Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}.
* @param values The condition values as discrete values.
* @returns The packed state value.
*/
pack(hints: number[], values: number[]): number;

/**
* Deconstruct a state from given hints to get condition values.
* @param hints Representing the byte length of provided values.
* @param hints Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}.
* @param state The state integer to unpack.
* @returns The condition values as discrete values.
*/
Expand Down Expand Up @@ -6551,6 +6551,7 @@ class ML {
* @returns The accuracy of the decision tree on the training data. And an error message if an error occurred during building of the decision tree.
*/
BuildDecisionTreeAsync(
this: void,
csvData: string,
maxDepth: number,
handler: (
Expand Down
8 changes: 4 additions & 4 deletions Assets/Script/Lib/Dora/en/ML.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ local record QLearner

-- Update Q-value for a state-action pair based on received reward.
-- @param state (integer) Representing the state.
-- @param action (integer) Representing the action.
-- @param action (integer) Representing the action. Must be greater than 0.
-- @param reward (number) Representing the reward received for the action in the state.
update: function(self: QLearner, state: integer, action: integer, reward: number)

-- Returns the best action for a given state based on the current Q-values.
-- @param state (integer) The current state.
-- @return (integer) The action with the highest Q-value for the given state.
-- @return (integer) The action with the highest Q-value for the given state. Returns 0 if no action is available.
getBestAction: function(self: QLearner, state: integer): integer

-- Load Q-values from a matrix of state-action pairs.
Expand All @@ -41,13 +41,13 @@ local record QLearnerClass
type Type = QLearner

-- Construct a state from given hints and condition values.
-- @param hints ({integer}) Representing the byte length of provided values.
-- @param hints ({integer}) Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}.
-- @param values ({integer}) The condition values as discrete values.
-- @return (integer) The packed state value.
pack: function(self: QLearnerClass, hints: {integer}, values: {integer}): --[[state]] integer

-- Deconstruct a state from given hints to get condition values.
-- @param hints ({integer}) Representing the byte length of provided values.
-- @param hints ({integer}) Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}.
-- @param state (integer) The state integer to unpack.
-- @return ({integer}) The condition values as discrete values.
unpack: function(self: QLearnerClass, hints: {integer}, state: integer): {integer}
Expand Down
9 changes: 5 additions & 4 deletions Assets/Script/Lib/Dora/zh-Hans/Dora.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6474,15 +6474,15 @@ class QLearner extends Object {
/**
* 根据接收到的奖励更新状态-动作对的 Q 值。
* @param state 表示状态的值。
* @param action 表示动作的值。
* @param action 表示动作的值。必须为大于0的整数。
* @param reward 表示在状态中执行动作所获得的奖励。
*/
update(state: number, action: number, reward: number): void;

/**
* 根据当前的 Q 值返回特定状态的最佳动作。
* @param state 当前状态。
* @returns 特定状态下具有最高 Q 值的动作。
* @returns 特定状态下具有最高 Q 值的动作。返回0表示没有动作。
*/
getBestAction(state: number): number;

Expand All @@ -6503,15 +6503,15 @@ export namespace QLearner {
interface QLearnerClass {
/**
* 根据特定的提示和条件值构造状态。
* @param hints 提供的值的字节长度
* @param hints 表示离散条件有多少种可能的提示。假设有两组条件,取值范围均为0, 1, 2,则提示数组为{3, 3}
* @param values 离散值的条件值。
* @returns 打包后的状态值。
*/
pack(hints: number[], values: number[]): number;

/**
* 解包函数,将状态整数解包为离散值。
* @param hints 提供的值的字节长度
* @param hints 表示离散条件有多少种可能的提示。假设有两组条件,取值范围均为0, 1, 2,则提示数组为{3, 3}
* @param state 要解包的状态整数。
* @returns 离散值的条件值。
*/
Expand Down Expand Up @@ -6550,6 +6550,7 @@ class ML {
* @returns 决策树在训练数据上的准确度。如果在构建决策树过程中发生错误,则返回错误消息。
*/
BuildDecisionTreeAsync(
this: void,
csvData: string,
maxDepth: number,
handler: (
Expand Down
12 changes: 6 additions & 6 deletions Assets/Script/Lib/Dora/zh-Hans/ML.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ local record QLearner

-- 根据收到的奖励值更新一对状态和动作下的Q值。
-- @param state (integer) 表示状态的整数。
-- @param action (integer) 表示动作的整数。
-- @param action (integer) 表示动作的整数。必须为大于0的整数。
-- @param reward (number) 表示在状态中采取行动获得的奖励值。
update: function(self: QLearner, state: integer, action: integer, reward: number)

-- 基于当前Q值返回给定状态的最佳动作。
-- @param state (integer) 当前状态。
-- @return (integer) 给定状态下具有最高Q值的动作。
-- @return (integer) 给定状态下具有最高Q值的动作。返回0表示没有动作。
getBestAction: function(self: QLearner, state: integer): integer

-- 从状态-动作对的矩阵中加载Q值。
Expand All @@ -41,14 +41,14 @@ end
local record QLearnerClass
type Type = QLearner

-- 根据给定的数值的字节长度的提示和条件数值构造状态值
-- @param hints ({integer}) 表示条件数值的字节长度
-- 根据给定的离散条件有多少种可能的提示和当前的条件数值构造状态值
-- @param hints ({integer}) 表示离散条件有多少种可能的提示。假设有两组条件,取值范围均为0, 1, 2,则提示数组为{3, 3}
-- @param values ({integer}) 离散值形式的条件值。
-- @return (integer) 生成的状态值。
pack: function(self: QLearnerClass, hints: {integer}, values: {integer}): --[[state]] integer

-- 通过给定的字节长度的提示解析状态值以获取条件值
-- @param hints ({integer}) 表示条件数值的字节长度
-- 通过给定的离散条件有多少种可能的提示,解析状态值以获取条件值
-- @param hints ({integer}) 表示离散条件有多少种可能的提示。假设有两组条件,取值范围均为0, 1, 2,则提示数组为{3, 3}
-- @param state (integer) 要解析的状态整数。
-- @return ({integer}) 包含离散值形式的条件值列表。
unpack: function(self: QLearnerClass, hints: {integer}, state: integer): {integer}
Expand Down
Loading

0 comments on commit e7e2638

Please sign in to comment.