ID:166131
Sep 19 2006, 2:26 am
|
|
I was planning on making battle round's attack sequence based on how high your agility is determining who attacks first out of up to 4 party members and 8 enemies. Does anyone have any suggestions on how to do this in an efficent manner?
|
If the list won't be too big, you can use a simple sorting algorithm like bubblesort or selection sort to sort the players by how high their agility is.
battle ~~> Unknown Person |
In response to DivineO'peanut
|
|
but what if by some off chance the agl changes during the battle?
like say do to a player ability or a monster spell. *just curious mostly for my own info :D* |
In response to Unknown Person
|
|
I'm already sure the list will never be higher than 12, 4 PCs and 8 monsters max but 8 monster parties are rare. How big is big when it comes to bubblesort?
|
In response to Hork
|
|
For 12 things, bubblesort will be plenty fine. I'd suggest selection sort, which is basically bubblesort with intermediate steps removed, but eh.
Bubblesort only starts getting slow when you're talking, say, 100 items. Until then, pretty much all sorting algorithms run in about the same time. And, in fact, the complex ones can often run slower, because of setting-up-time they might require. |
e.g.
And then use the turns[] list for the rest of the battle.