Best Ball Methods

BlitzMax Forums/BlitzMax Programming/Best Ball Methods

Rimmsy(Posted 2007) [#1]
Hi guys, I'm writing a mini-game at the moment that utilises some AI. there are balls of various points floating around in a 2d environment that the AI has to choose between.

Now of course they could just go for the highest scoring ball or they could go for the closest. Is there a neat way of creating a sorted array or a melding of the two?

For example, red = 1 point, blue = 2, black = 3. There is a blue ball close to the AI but he chooses to go for black seeing as it's the highest. So he should take into account some kind of value for closeness and pointage. If that's even a word. No, firefox just flagged it. What the hell, I'll keep it.

Anyone got any ideas?

compiledBestBalls()


would complile an array of all the balls, highest being closest and most points, lowest being lowest points and furthest away.


Rimmsy(Posted 2007) [#2]
Hmm, seems the best way to do it would be to sort them in order of points, then in order of distance in two separate lists.

Then create a third, empty list.

Then traverse the first list and look for the same ball in the second. Add their positions, divide by 2 and place them in the third list. then sort this.

Shouldn't that do it? Or is it way too abritary?


GfK(Posted 2007) [#3]
Suppose you're playing against the AI - how would YOU decide which ball to go for? i.e.

Which ball is nearest?
Which ball scores the most points?...and...
...do I need that many points to win?
Which ball is easiest to get to?
Will collecting a certain ball inconvenience my opponent?

...etc.

Draw your entire AI system out on a flow diagram. You can then code it piece by piece. Much easier that way than trying to manage the entire thing in your head.


Rimmsy(Posted 2007) [#4]
Thanks GfK, sometimes you just need to put it down and it comes to you. I'll release what I've got after I've done some more on the gameplay.

Cheers again,
Matt


Rimmsy(Posted 2007) [#5]
Nevermind.