This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Rabu, 30 Mei 2018

Finite State Machine (FSM) dan Pseucode


                              Finite State Machine (FSM) dan Pseucode



1. Finite State Machine (FSM)
    Finite State Machine pada dasarnya adalah melakukan pemecahan behaviour dari object/agen berdasarkan statenya. Dan nantinya juga harus didefinisikan aturan-aturan transisi sehingga state dapat berubah dari yg satu ke yang lain



                                                       (Gambar.1 : FSM Game)



2. Pseucode
using UnityEngine;
using System Collections;

public class FSM : MonoBehaviour{
    public enum TurnStates{
    masuk_level,
    diam,
    berjalan,
    huruf_hijaiyah,
    enemy,
    nyawa,
    score,
    next level,
    rewords,
    game_over,
}

public.TurnStates state;
public bool gameInProgress = true;

void Start(){
state = FSM.Mulai.Init;
StartCoroutine ("TurnFSM"){
}
Private IEnumerator TurnFSM(){
While(gameInProgress){
  Switch(state){
     Case TurnStates.masuk_level;
     If(langkah_awal()) (*state = diam;}
     break;
     Case TurnStates.diam;
     If(mulai()) (*state = berjalan;}
     break;
     Case TurnStates.berjalan;
     if(menghindar()) {*state =berjalan;}
     if(mendapatkan()){*state=huruf_hijaiyah;}
     break;
     case TurnStates.huruf_hijaiyah:
     if( mendapatkan()) {* state = score;}
            break;
     case TurnStates.enemy:
     if( mencari koin ()) {* state = box;}
     if(berkurang()) {* state = nyawa;}
            break;
     case TurnStates.nyawa:
     if( nyawa habis ()) {* state = rewords;}
     if(masih ≤ 3()) {*state = masuk_level;}
            break;
     case TurnStates.score:
    if( kurang ()) {* state = berjalan;}
    if(cukup()) {*state = next_level;}
            break;
     case TurnStates.next_level:
     if(level masih ada()) {* state = masuk_level;}
     else (level habis ()) {* state = rewords;}
            break;
     case TurnStates.rewords:
     if( masuk ke()) {*state = game_over;}
           break;
     case TurnState.Next.game_over :
      if (player mati ()) {* state = masuk_level;}
            break;
     }
 yield return null;
    }
}

3. Penjelasan
Ketika player mulai masuk ke level, maka player akan terdiam terlebih dahulu kemudian berjalan. Ketika player berjalan ada dua kemungkinan yaitu dia akan terkena enemy atau menghindar dari enemy. Jika player menghindar dari enemy maka kemungkinan akan mendapatkan huruf hijaiyah dimana huruf hijaiyah tersebut memiliki sebuah score dan bisa melanjutkan ke level selanjutnya. Tetapi ketika player terkena enemy maka nyawa dan score akan berkurang. Jika nyawa kurang dari 3 maka bisa melanjutkan brmain, tetapi jika nyawa habis maka akan mendapatkan rewords sekaligus game over.


Reverensi