#include
typedef
void
(*pactionfun)
(void);
typedef
enum
curstatus;
typedef
enum
triggerevent;
typedef
enum
nextstatus;
typedef
struct status
logicstruct;
void
act_fun
(void
)logicstruct logic_struct =
;int
main
(int argc,
char
const
*ar**)
#include
typedef
void
(*pactionfun)
(void);
typedef
enum
triggerevent;
typedef
enum
status;
typedef
struct status
logicstruct;
typedef
struct
statusmachine;
void
act_fun132
(void
)void
act_fun142
(void
)void
act_fun213
(void
)void
act_fun242
(void
)void
act_fun321
(void
)void
act_fun332
(void
)void
act_fun353
(void
)void
runsm
(statusmachine* xsm ,triggerevent trigeveid)}}
logicstruct logic_array=
,//初始化為狀態1,當事件3來臨時,切換至狀態2,執行函式act_fun132
,//當狀態為狀態1,當事件4來臨時,切換至狀態2,執行函式act_fun142
,//當狀態為狀態2,當事件1來臨時,切換至狀態3,執行函式act_fun213
,//當狀態為狀態2,當事件4來臨時,切換至狀態2,執行函式act_fun242
,//當狀態為狀態3,當事件2來臨時,切換至狀態1,執行函式act_fun321
,//當狀態為狀態3,當事件3來臨時,切換至狀態2,執行函式act_fun332
,//當狀態為狀態3,當事件5來臨時,切換至狀態3,執行函式act_fun353};
statusmachine gsm =
;int
main
(int argc,
char
const
*ar**)
;for
(int j =
0; j <
15; j++
)printf
("status study!\r\n");
return0;
}
狀態機 狀態機0
近半年都忙於做專案,沒有太多的時間去整理和總結在專案中用過的技術 個人還是覺得技術需要總結提煉和沉澱的,忙到沒時間去總結提公升其實不 是什麼好事,這次講下狀態機,在戰鬥型別的遊戲中角色有多種不同的狀態,而狀態的切換錯綜複雜,23種設計模式中有一種模式叫做狀態模式,不過 這種模式是把狀態切換條件放到各...
python 狀態機 Python 狀態機
class statemachine def init self self.handlers 狀態轉移函式字典 self.startstate none 初始狀態 self.endstate 最終狀態集合 引數name為狀態名,handler為狀態轉移函式,end state表明是否為最終狀態 de...
學習筆記 狀態機
狀態機是有限狀態自動機的簡稱,是現實事物執行規則抽象而成的一種數學模型 將電路的全部工作方式,分成幾個場景,這些場景的工作方式明顯不同,然後將這些場景通過數學模型表示出來 輸出只和狀態有關而與輸入無關 狀態表 輸出不僅和狀態有關而且和輸入有關係 狀態表 人有三個狀態健康,感冒,中。觸發的條件有淋雨 ...