Dark Bit Factory &  Gravity

Dark Bit Factory & Gravity

  • September 10, 2010 *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Pages: [1]   Go Down

Author Topic: AI State Machine  (Read 280 times)

0 Members and 1 Guest are viewing this topic.

Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Karma: 15
  • Offline Offline
  • Posts: 333
  • kiss that sound that pounds your senses
    • View Profile
    • WWW
AI State Machine
« on: April 27, 2007 »
I am having some trouble with making the units CALL... I tried a method yesterday, but it didn't work.
I added another state: HELP which means that the unit has been called and will go and help the calling unit.

I just can't get it working lol!

--edit--

I made some changes... and I have it so that the finding unit attacks the target. I haven't been able to get the target attacking back... eee!
But, the retreat is done. I just need to sus out how to make it so their speed gos to default when its safe.

I've attatched the newest code.
« Last Edit: April 27, 2007 by CLANKY »
Logged
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

rdc

  • Sliderules Rule!
  • MOD
  • Pentium
  • *******
  • Karma: 132
  • Offline Offline
  • Posts: 1439
  • Clark Productions
    • View Profile
    • WWW
Re: AI State Machine
« Reply #1 on: April 27, 2007 »
The way I have done this in the past is to set up a message queue for units. A unit can broadcast a message to other units that will be placed into their message queue. The receiving unit can then examine the messages and take the appropriate action. Using a message queue allows you to set up priorities for the unit so that they can perform an action based either on a message it received or what is currently happening.

For example, Unit X is in a battle and needs help. It broadcasts a help message to the other units. Unit A is in a battle and can't respond, but unit B is idle and can respond. Unit B heads for the battle but uncovers a hidden patrol and can't respond. The calling unit is now without help, so it decides to retreat. Unit B finished off the patrol and is again available, so messages Unit X that it is available. Unit X can now regroup wait for Unit B and re-attack the position.

This is fairly simple to implement. The message queue would contain a list of messages and priority values. The Help message would have a fairly high priority so it would go to the top of the message queue until either the unit got help, or the calling unit canceled the help message. Using this scheme you can send multiple orders to units and have them work on the orders based on priority and availability and current events.

Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Karma: 15
  • Offline Offline
  • Posts: 333
  • kiss that sound that pounds your senses
    • View Profile
    • WWW
Re: AI State Machine
« Reply #2 on: May 02, 2007 »
Ok ok!

I fixed all the states - except CALL and HELP! I'll work on them.

Hmmm!
I decided to make it visually nice - and I guess I got a bit carried away!

I've attatched it. And, the code is really, really messy! Like - mega messy.
I tried to make this program from scratch, and came up with a nice movement code... *this bit is very basic - not the actual code I did...*
Code: [Select]
  if x < x_target xd = 1
  if x > x_target xd = -1
  if y < y_target yd = 1
  if y > y_target yd = -1

  x = x + xd:y = y + yd
but didn't like it much for the program - so it was scrapped.

I hope you guys like the way I made the teams as 1 or 2! I made that equation (don't know if someone else has the same) in year 7 when I was mucking around with my calculator... very nice! All it does is make it so that - say A - changes from 1 to 2 to 1 to 2... etc. much the same as:
Code: [Select]
A = 1 - AHere's mine:
Code: [Select]
A = A + A - (A ^ 2) + 1
I also made it so the original program now has teams. I will work on making it so it works nicely with unit types etc.

Hope you's enjoy! I would consider this a demo!?

*Press left at the scroll screen to make the scroll scroll faster.*
Logged
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

rain_storm

  • Here comes the Rain
  • Senior Member
  • ******
  • Karma: 157
  • Offline Offline
  • Posts: 2871
  • Rain never hurt nobody
    • View Profile
    • WWW
Re: AI State Machine
« Reply #3 on: May 02, 2007 »
 :D fantastic work Clanky seems to be really coming along. You got the makings of a really cool strategy game there. K+ for all the hard work you put in
Pages: [1]   Go Up
 

 

B l a c k R a i n V.2 by C r i p

Page created in 0.303 seconds with 20 queries.