Captain Spazer Posted August 26, 2016 Share Posted August 26, 2016 (edited) A.I is extremely hard I think. Sure, making a predictable A.I that just follows the player around relentlessly like a bloodhound and that guns him down as soon as he is in the line of sight is easy, and boring. But what about an A.I that could do that, and turn tail and run if the situation was not favorable? The closest I've managed is to have a random counter going off once in a while that makes the A.I bob and weave and resume the hunt a moment later. So, any tips would be great =) Here is my generic A.I routine. It may be useful to someone =) rem a.i routine j=j+1 rem every second the a.i does something different if j=60 then i=(rand&7) : j=0 if i=0 && c=0 then player1x=player1x-1 : e=1 if i=1 && c=0 then player1x=player1x+1 : e=0 if i=2 && c=0 then player1y=player1y+1 if i=3 && c=0 then player1y=player1y-1 if i=4 && c=0 && k=0 then k=1 if i=5 && c=0 then player1x=player1x-1 : e=1 if i=6 && c=0 then player1x=player1x+1 : e=0 if i=7 && c=0 then player1y=player1y+1 rem shoot right if i=4 && k=1 && c=0 && e=0 then missile1x=player1x : missile1y=player1y : k=2 if i=4 && k=2 && c=0 then missile1x=missile1x+1 rem shoot left if i=4 && k=1 && c=0 && e=1 then missile1x=player1x : missile1y=player1y : k=3 if i=4 && k=3 && c=0 then missile1x=missile1x-1 if c=0 && player1y>80 then player1y=80 if c=0 && player1y<10 then player1y=10 if missile1x>135 then missile1x=255 : missile1y=255 : k=0 if player1x>135 then player1x=0 if player1x<0 then player1x=135 Edited August 26, 2016 by Captain Spazer 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 26, 2016 Share Posted August 26, 2016 One tip would be to use dim to create variable aliases so other people will know at a glance what the variables stand for. It's also useful for when you go back to you own program months or years later. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted August 27, 2016 Share Posted August 27, 2016 I usually use some constants, variables and on goto statements const ai_mode_sexy = 1 const ai_mode_grumpy = 2 dim ai_mode = a on ai_mode goto move_sexy move_grumpy Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted August 28, 2016 Author Share Posted August 28, 2016 (edited) Good points, I need to learn to dim more =) Edited August 28, 2016 by Captain Spazer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.