Selasa, 29 Mei 2018

Finite State Machine Pada Game

19.36


FSM (Finite State Machine)

Contoh game : Warcraft 3
Merupakan contoh game dimana player yang berada di arena dengan format 5 vs 5 dengan tujuan menghancurkan rumah dari player lain agar bisa memenangkanya.


 
Pseudocode
Play
Case0:
Jalan ();
If ( don’t have gold () ) {*state1 () }
break;
if ( see enemy ( ); ) {*state 3 ( );}
break;
if (see hard enemy( );) {*state 4 ( ); }
Break ;

Case1 :
Farming () ;
if (have gold ( ) ) {*state 2 ( ); }
break;
if (dont have enought gold ( ) ) {*state 1 ( );}
break;

Case2 :
Shop item() ;
if (dont have enought gold ( ) ) {*state 1 ( );}
break;

case 3 ;
attackenemy();
if ( Youwin ( ); ) {*state 5 ( ) ; }
break;
if ( Youlose ( ); ) {*state 7 ( ) : }
break;

case 4 ;
defended ( );
If (youdied (); ) {*state 6 ( ); }
break;
if (youwin ( ) ; ) {*state  (5); }
break;

case 5 ;
attackhomeenemy();
if ( Youwin ( ); ) {*state 7 ( ) ; }
break;
if ( Youlose ( ); ) {*state 6 ( ) : }
break;

case 6 :
Respawn() ;
If (youdied() ; {*respawn} {*state 1();}

case 7 :
Win ( ) ;
if (home enemy broke (); ) {game end }
{you win }
break;

case 8 :
enemy attack() ;
if (youwondefended() ; ) {*state 5 ( ) ; }
if (your home broke () ;) {*state 9 ( ) ; }

case 9 :
Game Over() ;
if (home broke( ) ; ) {*game over }
{*state play}

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 komentar:

Posting Komentar

 

© 2013 Sekedar Informasi. All rights resevered. Designed by Templateism | Blogger Templates

Back To Top