• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Plethora

Deceptively complex problem...

5 posts in this topic

I'm working on an SRPG with a tactical map and a turn based battle system.  However, rather than having each "side" get a turn during which they move all their units, I'm going with an initiative based system where each unit on the battlefield gets an individual turn based on an individual initiative score.  Each unit gets an initiative score from 1-10 with 10 being the fastest unit.  That score is subtracted from 20 with the result being n.  The unit the gets a turn every nth round.

 

I just started implementing code to determine (and eventually display) the turn order.  I had planned to keep a container of references which would be sorted and could simply be iterated over as turns were taken.  The front end of this is fine.  For a unit with a score of 8 you insert a reference every 12th round.  But obviously I'm not going to keep references all the way out to infinity.  I'm going to have to store the turn order to some point, say 50 rounds from current, and as turns are take I'm going to have to go back in and extend it further.  How to I, then, accurately track the "remainders" between a units last turn and next when they go over the "line", so to speak.  If a unit is going to have a turn every 15 rounds, and I'm keeping track up to 50, then where do I store those 10 rounds between 45 and 60 that will be left off?  I could have each unit maintain a "remainder" variable, but that seems potentially messy...

 

Thus, I'm starting to think that's not the best implementation.  My next thought was just have each unit maintain a list of when it will take its next N turns, then iterate over the units and store the order.  This seems like it would work quite well, except that I predict I'll have to do a lot of extra searching and sorting this way.  Of course, I probably won't do enough searching and sorting to impact performance even in the worst case...

 

I think in typing this I've convinced myself of implementation number two... but I think I'm going to post this anyway, as I would love to hear some different thoughts if anyone has any.  This just seemed like such a trivial problem but I've extended quite a bit of thought energy on it...

0

Share this post


Link to post
Share on other sites

Why do you need to keep track of the turn order for multiple turns ahead? If the initiative of a unit doesn't change dynamically, then the turn order to infinity is perfectly predictable given a unit's next move. However, if the initiative change dynamically (for example; special item to boost initiative by X for Y rounds), then it would be a bad idea to store multiple moves ahead to begin with.

 

My initial idea: Store all units and their next move in a priority queue sorted by the time for the next move. Items will be popped in order of the time of next move. When you pop a unit from the queue at time T, put it back into the priority queue again with time T+20-initiative. You can find out the complete sequence of times to move a unit by adding multiples of 20-initiative to the unit's time.

2

Share this post


Link to post
Share on other sites

Well, I'd like the player to be able to see the turn order for some period of time into the future, and the specifics of my implementation mean there will be situations where one unit may get multiple turns before another unit gets one (which is by design), so there would need to be two entries shown for unit A before one for unit B.  Though, I think a priority queue of sorts would likely work but I'll have to play with the details a little bit.

 

I don't really need to extend things out that far, but I think its reasonable for a player to want to see at least when any given unit will get their turn next.  I do intend to allow dynamic changes as well (though clearly I'm not at that stage yet), but I feel like it would just be a matter of recalculating the list with a new value.

0

Share this post


Link to post
Share on other sites

You could also actually keep an infinite list, and use laziness. In Haskell, the solution would be quite simple:

 

generate :: a -> Int -> [[a]]
-----------------------------
generate x n = concat $ repeat $ replicate (n - 1) [] ++ [[x]]


combine :: [[a]] -> [[a]] -> [[a]]
----------------------------------
combine xs ys = map (uncurry (++)) (zip xs ys)


a = generate "a" 5      - "a" is repeated every 5th turn
b = generate "b" 3      - "b" is repeated every 3rd turn
c = generate "c" 7      - ...

result = a `combine` b `combine` c
--> [[],[],["b"],[],["a"],["b"],["c"],[],["b"],["a"],[],["b"],[],["c"],["a","b"],[],[],["b"],[],["a"], ...]

 

 

Depending on the language you use, it can be easy to simulate this, or it can boil down to solving the same problem you are tackling now.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0