유한 상태 기계 클래스 (FSM)

  • Published on
    05-Jan-2016

  • View
    130

  • Download
    3

Embed Size (px)

DESCRIPTION

(FSM). , . . ? AI . ?. Finite state machine, FSM . AI . . . . . . . . - PowerPoint PPT Presentation

Transcript

<ul><li><p> (FSM), </p></li><li><p>? AI </p></li><li><p>?Finite state machine, FSM</p></li><li><p> AI </p></li><li><p> FSMstate FSMclass FSMstate </p><p> .</p></li><li><p>FSMstate class FSMstate { unsigned m_usNumberOfTransitions; int *mpiInputs; int *mpiOutputState; int miStateID; public: FSMstate(int iStateID, unsigned usTransitions); ~FSMstate(); int GetID() { return miStateID; } void AddTransition(int iInput, int iOutputID); void DeleteTransition(int iOutputID); int GetOutput(int iInput); };</p></li><li><p>FSMstate ()FSMstate::m_usNumberOfTransitions .</p><p>FSMstate::m_piInputs . FSMstate::piOutputState .</p><p>FSMstate::m_iStateID FSMstate ( ) .</p></li><li><p>FSMstate ()FSMstate::GetID() FSMstate .</p><p>FSMstate::AddTransition() FSMstate .</p><p>FSMstate::DeleteTransition() .</p><p>FSMstate::GetOutput() .</p></li><li><p>FSMclass class FSMclass { State_Map m_map;// FSM int m_iCurrentState;// m_iStateID public: FSMclass( int iStateID );// FSM ~FSMclass();// // ID . int GetCurrentState() { return m_iCurrentState; } // . void SetCurrentState( int iStateID ) { m_iCurrentState = iStateID; } // FSMstate . FSMstate *GetState( int iStateID ); // FSMstate . void AddState ( FSMstate *pState ); // FSMstate . void DeleteState( int iStateID ); // . int StateTransition( int iInput ); };</p></li><li><p>FSMclass ()FSMclass::m_map FSMstate , STL . FSMclass::m_iCurrentState FSM FSMstate .</p><p>FSMclass::GetState() FSMstate FSMstate . FSMclass::GetCurrentState() . FSMclass::SetCurrentState() FSMstate .</p></li><li><p>FSMclass ()FSMclass::AddState() FSM FSM . . FSMclass::DeleteState() FSM FSM . . FSMclass::StateTransition() .</p></li><li><p>Key / value (, key )</p><p> key </p></li><li><p>Map () #include</p><p> namespace std namespace std { template&lt; class Key, class T, class Compare = less, class Allocator = allocator &gt; class map; }</p></li><li><p>FSM - 1 </p></li><li><p>FSM - 2 </p></li><li><p>FSM - 3 </p></li><li><p>FSM 0</p><p>6</p><p>12</p><p>18</p><p>24</p><p>30</p><p>1</p><p>7</p><p>13</p><p>19</p><p>25</p><p>31</p><p>2</p><p>8</p><p>14</p><p>20</p><p>26</p><p>32</p><p>3</p><p>9</p><p>15</p><p>21</p><p>27</p><p>33</p><p>4</p><p>10</p><p>16</p><p>22</p><p>28</p><p>34</p><p>5</p><p>11</p><p>17</p><p>23</p><p>29</p><p>35</p><p>Enemy0 ~ 35ID</p></li><li><p>FSM Message </p><p>struct MESSAGEOBJECT{char strMessageName[256]; // char strSender[256]; // char strReceiver[256]; // float fDeliveryTime; // D3DXVECTOR3 vPos; // D3DXVECTOR3 vDir; // bool bAngry; // };</p></li><li><p>FSM CCube(Player)CMessageRouterCFSMclass(Enemy)CFSMstateCFrameView Player Enemy Enemy Enemy Player Enemy </p></li><li><p>FSM CCube+ m_pVB;+ m_pIB;+ m_pd3dDevice;+ m_matWorld;+ m_vOriginTrans;+ m_vTrans;+ m_vTargetTrans;+ m_fVelocity;+ CCube();+ ~Ccube();+ Create();+ SetLocation();+ FrameMove();+ Render();+ Release();CFSMstate+ m_usNumberOfTransitions;+ m_pnInouts;+ m_pnOutoutState;+ m_nStateID;+ CFSMstate();+ ~CFSMstate();+ GetID();+ AddTransition();+ GetOutput();</p></li><li><p>FSM CFSMclass+ m_pd3dDevice;+ m_StateMap;+ m_nCurrentState;+ m_Enemy;+ m_fVelocity;+ CFSMclass();+ ~CFMSclass();+ GetCurrentState();+ SetCurrentState();+ GetState();+ AddState();+ DeleteState();+ StateTransition();+ ReceiveMessage();CMessageRouter+ m_pd3dDevice+ m_nEnemyNum;+ m_nBeforeLotID;+ m_nCurrentLotID;+ CMessageRouter();+ ~CMessageRouter();+ Create();+ FrameMove();+ GetPlayerLocationID();+ Render();+ Release();</p></li><li><p>THE END</p><p> : FSM .*</p></li></ul>