You have to store heroes into unit variables[array] like: Player 1 gets Hero[1], Player 2 gets Hero[2] ... and so on.
Then I guess your loop must look something like this:
Info:
INT = Integer variable (represents the player number in the loop)
You must run this loop periodicly, to always refresh the orders to current situation. Maybe each 0.5 seconds would be fair enough.
-
For each Integer INT from 1 to 12 do actions:
-

If Player[INT] is Computer == TRUE AND Hero[INT] is alive == TRUE
-


Then - Actions:
-



------------*Your AI-Code*------------
-


Else - Actions:
Sorry but it would be best you write AI-Code yourself (or make a request), because AI is always too map specific.
I just can give you some tips like:
1. You need to check if enemries around (too many --> maybe run away and buy potion)
2. Check current life/mana of hero and then buy/use potions again.
3. Check if there are items around which can be picked up. (if empty slot)
4. Attack weakest unit always, to gain more kills.
5. Using abilities wisely
... and and and
Hope it will help you, Apelli. Good luck with it!