Cell and TList

BlitzMax Forums/BlitzMax Beginners Area/Cell and TList

tin(Posted 2008) [#1]
Hi, i want to know something.
the below image show the cell images. Left Image show the RED is attacking the BLACK's cell. the Right image shows after the attacked is completed and the RED taken over the BLACK's cell.

So. here, i want to know how should i handle this kind of game?
note* the human attacking is Ok. but for computer AI, how can i select the object in TList, and how to remove the object taken over from TList? should i simply use array or Tlist or any combination to do AI part?




tonyg(Posted 2008) [#2]
For the AI I would use Minimax or maybe an Influence Map) as it's basically a larger version of Noughts and Crosses. That way you know which 'grid' you want to attack. The grid is as array of objects where a field is 'Object_held'.


tin(Posted 2008) [#3]
so. only array objects can handle? TList is not suitable?


tonyg(Posted 2008) [#4]
I don't believe a TList is suitable as you'll be mapping a grid to a list (possible but not the best imo). What is wrong with using an array of objects?


tin(Posted 2008) [#5]
nothing wrong. At first, i was thinking the processes based on TList and got stuck at how to choose the desire object at one cell and removing of another cell by A.I :)
thanks. now i got what i should do..


Grey Alien(Posted 2008) [#6]
Just to confuse matters, I use a list for easy iteration when drawing and processing and inserting and removing, and I also have a GRID so I can quickly find items via x,y coords. Each Cell is referenced on the grid and in the list and when it's removed, it's removed from both.


tin(Posted 2008) [#7]
thanks for all of your inputs..


tin(Posted 2008) [#8]
Can someone please point out how to calculate Influence Mapping?


tonyg(Posted 2008) [#9]
An example :
Each 'thing' has an influence score (a tank has 5 pts, a jeep has 2 pts). This score halves (or whatever) each grid from the object.
So the tiles surrounding the jeep get a score of 2.5.
The influence of friendly units is added and the influence of enemy units is subtracted. This results in a figure showing how under control a tile in the map is.
It doesn't have to be attack/defence. You can influence maps for lots of things... where to build houses (roads, rivers have +ve, mountains, swamps have -ve.)
This has some good links.


tin(Posted 2008) [#10]
I would like to know whether the following is the correct way to calculate IM map.




tin(Posted 2008) [#11]
I want to know detail explanation about Influence Mapping technique.
if some one with information, please help me.


tonyg(Posted 2008) [#12]
Did none of the links help that I posted?


tin(Posted 2008) [#13]
hi tonyg,
Only one link explained similar to influence map. but not exactly.
the above tables is drawn using the methods they explained. and at the end i dont know what i am doing.. :(

the method said
1) Assign each map location one of three values:
a) If it's empty, assign 0;
b) If it's occupied by a friendly unit, assign a positive value.
c) If it's occupied by an enemy unit, assign a negative value.
2) Make a new copy of the map with each location receiving its old
value modified by the six hexes surrounding it:
a) Increase by one for each adjacent hex containing a positive
value.
b) Decrease by one for each adjacent hex containing a negative
value.
3) Copy the new map back into the old map.
4) Repeat steps 2) and 3) an arbitrary number of times.


tonyg(Posted 2008) [#14]
I can't see your table.
Isn't the method you just listed what you're looking for?
I realise you might be posting in Beginners because you're a Bmax Beginner but AI is quite an advanced topic. Although Influence Maps are good for Strategy games couldn't you use an FSM or Minimax?


tin(Posted 2008) [#15]
here my table image
http://picasaweb.google.com/tinkyawoo/WebImage/photo#5240652598512944946


tonyg(Posted 2008) [#16]
would like to know whether the following is the correct way to calculate IM map.
Your image shows 4 grids of numbers which doesn't help explain how they were calculated. However, the process you listed *IS* how Influence Maps are calculated.


tin(Posted 2008) [#17]
ok here is my latest influence map calculation with color table results.


I look for detail information on the net and i found nothing about how to do it properly. So, i calculate the above tables based on the knowledge from the links that tonyg replied to me above.

calculation.
original table represent the positions of player and enemy.
1 = player, -1= enemy.
0s at the edge represents the border (just to make the calculation easier)

IM Calculation,
1. add all the surrounding cells value + the current cell value then divide by 8 and multiply it with current cell value from original table

repeat 1 for all cells.

Ok now. problem is, how to choose the best cell to attack? please take a look at my table, and suggest me.


tonyg(Posted 2008) [#18]
Your maps look pretty much like influence maps to me.
Areas to attack are those within 'attacking distance' of your units where your attack strength exceeds their defence strength by a certain factor (2-1 or 3-1). If that doesn't happen then you check what you can move for this to be an option for the future (often this can be by using simple minimax algo) If you have reserves there should be an option to commit them.
How your AI engages the enemy is often dependent on your commander. Aggressive commanders attempt to engage as many enemy units as possible but reduces the strength vs defence odds. A defensive commander attempts to make each area as high a defensive strength as possible. A 'neutral' commander will engage only when they have sufficient strength without leaving a weak area. This is also offset against a priority list for which areas MUST be taken. It's easy to get IMs working but not trivial to analyse them into allowing AI to formulate a plan.

Go to the library and get a copy of AI Game Programming Wisdom. Article 'Recognizing Strategic Dispositions: Engaging the Enemy' covers what you're after. Also loan a copy of Game Programming Gems 1 and 2 for articles from Paul Tozour.
There are also some great articles here CGF-AI in particular 'Dynamic Procedural Combat Tactics'
<edit> and while searching I have found this for the first time.