total_new_auto_states.m

来自「一个matlab的将军模型」· M 代码 · 共 35 行

M
35
字号
function total = total_new_auto_states(from_idx)

% Count the number of states (`initial` and `face` states) in the global
% variable "GLOBAL_NEW_AUTOMATON" starting from the given index.
%
% Syntax:
%   "total = total_auto_states(from_idx)"
%
% Description:
%   Compute the number of `initial` and `face` states in the global variable
%   "GLOBAL_NEW_AUTOMATON" starting from the index "from_idx". 
%
% Note:
%   This function is identical to "total_auto_states()" except that it
%   references the variable "GLOBAL_NEW_AUTOMATON" rather than
%   "GLOBAL_AUTOMATON".
%
% See Also:
%   inc_new_auto_idx,is_valid_new_auto_idx,total_auto_states

global GLOBAL_NEW_AUTOMATON

idx = from_idx;
% if not a valid index, find the next valid index
if ~is_valid_new_auto_idx(idx)
  idx = inc_new_auto_idx(idx);
end
total = 0;
% increment the state index and the totol the number of states until all
% states has been counted
while ~isempty(idx)
  total = total + 1;
  idx = inc_new_auto_idx(idx);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?