AI: Deterministic AI

Source: Internet
Author: User

1 usingUnityengine;2 usingSystem.Collections;3 4  Public classAirandmove:monobehaviour5 {6     floatStopTime;7     floatMovetime;8     floatVel_x, vel_y, vel_z;//Speed9     /// <summary>Ten     ///Maximum and minimum flight limits One     /// </summary> A     floatMaxpos_x = -; -     floatMaxpos_y = -; -     floatMinpos_x =- -; the     floatMinpos_y =- -; -     intCurr_frame; -     intTotal_frame; -     floatTimeCounter1; +     floatTimeCounter2; -     //int max_flys = n; +     //Use this for initialization A     voidStart () at     { - Change (); -     } -  -     //Update is called once per frame -     voidUpdate () in     { -TimeCounter1 + =Time.deltatime; to         if(TimeCounter1 <movetime) +         { -Transform. Translate (vel_x, Vel_y,0, space.self); the         } *         Else $         {Panax NotoginsengTimeCounter2 + =Time.deltatime; -             if(TimeCounter2 >stoptime) the             { + Change (); ATimeCounter1 =0; theTimeCounter2 =0; +             } -         } $ Check (); $     } -     voidChange () -     { theStopTime = Random.range (1,5); -Movetime = Random.range (1, -);Wuyivel_x = Random.range (1,Ten); theVel_y = Random.range (1,Ten); -     } Wu     voidCheck () -     { About         //If you reach the preset boundary position value, change the speed direction and let its current coordinate position be equal to the position value of the critical edge. $         if(Transform.localposition.x >maxpos_x) -         { -vel_x =-vel_x; -Transform.localposition =NewVector3 (maxpos_x, TRANSFORM.LOCALPOSITION.Y,0); A         } +         if(Transform.localposition.x <minpos_x) the         { -vel_x =-vel_x; $Transform.localposition =NewVector3 (minpos_x, TRANSFORM.LOCALPOSITION.Y,0); the         } the         if(Transform.localposition.y >maxpos_y) the         { theVel_y =-vel_y; -Transform.localposition =NewVector3 (transform.localposition.x, Maxpos_y,0); in         } the         if(Transform.localposition.y <minpos_y) the         { AboutVel_y =-vel_y; theTransform.localposition =NewVector3 (transform.localposition.x, Minpos_y,0); the         } the     } +}

AI: Deterministic AI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.