ID:154322
 
Trying to think of a turn system is driving me nuts!

All I need is a simple turn system that has two versions, two player, and four player, and goes from one player to the next through a loop.

I've tried a dozen times to get one that works, and turn systems dont seem to come naturally to me since they all end up in a senseless heap of code one way or another.

I need some pointers here! Some tips on how to get a turn system functioning properly.

Needless to say, I wasnt expecting it to be this complicated when I started out, I thought the turn system was going to be the easy part!
There's demo for this somewhere.
In response to Nadrew
The demo is a bit more complicated than I was looking for.
Echelon wrote:
Needless to say, I wasnt expecting it to be this complicated when I started out, I thought the turn system was going to be the easy part!

I sympathize; I'm stuck with this problem myself.
Of course, I didn't do myself the favor of checking out a turn system demo in the first place--but whether it would have helped me, I don't know.

For Incursion, I'm having the awful problem of figuring out how to preserve player status when the player handling a given color on the board logs out--even at inconvenient times. Half the code I need to handle this gracefully simply isn't in place yet. Worse, I have to find some way to handle situations where the player steps away for half an hour at a time and doesn't tell anybody; if the host is idle too, they can't hand off control to another player, so there needs to be some sort of timer system in which the timer can be cancelled.

Lummox JR
Echelon wrote:
Trying to think of a turn system is driving me nuts!

I started on it with Checkers, but got distracted by making progress on Birdland!

I'll try to have something simple together this weekend.
In response to Deadron
Deadron wrote:
I started on it with Checkers, but got distracted by making progress on Birdland!

Yay! Birdland is very cool, I can't wait for you all to see it when it comes out publicly.
In response to Lummox JR
You can't just skip their turn if they don't have a client? :oP
In response to Foomer
Foomer wrote:
You can't just skip their turn if they don't have a client? :oP

I can run through a turn without doing much, but I don't think I can skip it. Anyway the real problem lies in the fact that control of a game "player" is actually control of a color, and as such gameplay can be handed off from person to person. Sometimes it's necessary to do that handoff when the player is idling, etc., so there's a lot of thought that has to go into this as to how interfaces are handled and so on.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Foomer wrote:
You can't just skip their turn if they don't have a client? :oP

I can run through a turn without doing much, but I don't think I can skip it. Anyway the real problem lies in the fact that control of a game "player" is actually control of a color, and as such gameplay can be handed off from person to person. Sometimes it's necessary to do that handoff when the player is idling, etc., so there's a lot of thought that has to go into this as to how interfaces are handled and so on.

Lummox JR

I've worked out something in Murder Most Beautiful that does something similar to what you're looking for, but it requires an AI loop. Actually, mine is not turn-based, but I think it may apply.

Each mob can be controlled by either the computer, or by a player. Players may leave, and the computer retakes control until another player wants that mob.

Since it sounds like a turn is a bit involved in your game, and may take several steps, I would suggest putting in an AI loop that looks to see how far along it is, in case someone steps out partway through. If it's not their turn, or if there is a client attached, just return from the loop. Otherwise, have it evaluate what still needs to be accomplished, then proced with the turn.
In response to Skysaw
Skysaw wrote:
I've worked out something in Murder Most Beautiful that does something similar to what you're looking for, but it requires an AI loop. Actually, mine is not turn-based, but I think it may apply.

Each mob can be controlled by either the computer, or by a player. Players may leave, and the computer retakes control until another player wants that mob.

I thought the way you did that was pretty cool. "The part of ____ is now being played by ____." Definitely enhances the idea of role-playing.

Since it sounds like a turn is a bit involved in your game, and may take several steps, I would suggest putting in an AI loop that looks to see how far along it is, in case someone steps out partway through. If it's not their turn, or if there is a client attached, just return from the loop. Otherwise, have it evaluate what still needs to be accomplished, then proced with the turn.

The problem with AI in Incursion is that designing actual AI for it would be incredibly difficult. I'd essentially have to build parts into the engine whereby a computer player could evaluate how many borders it's defending, what it could be defending instead if it controlled X and Y, how it would end up getting X and Y, and ultimately a strategy to lead it to try to work up to Z which bottlenecks access to that part of the map. This is to say nothing of redeployment, where borders may be fortified or resources moved into stockpiles. Right now all my AI does is deploy army units at random.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
I thought the way you did that was pretty cool. "The part of ____ is now being played by ____." Definitely enhances the idea of role-playing.

Thanks. It wasn't really conceived of as a roleplay game, but some aspects of it definitly feel like it. I actually see it sort of as a one-act play.

The problem with AI in Incursion is that designing actual AI for it would be incredibly difficult. I'd essentially have to build parts into the engine whereby a computer player could evaluate how many borders it's defending, what it could be defending instead if it controlled X and Y, how it would end up getting X and Y, and ultimately a strategy to lead it to try to work up to Z which bottlenecks access to that part of the map. This is to say nothing of redeployment, where borders may be fortified or resources moved into stockpiles. Right now all my AI does is deploy army units at random.

I guess the question then comes down to what the desired behavior is for a missing player. If you don't want computer AI, sounds like you'll have to develop some complex rules for redistribution when someone drops out. Either way, could be a lot of work.

One thing to think about with computer AI... if it's too difficult to make them as smart as a human, make up the difference in other advantages. Dumb but stronger, quicker, or more accurate... whatever makes sense in your game.
In response to Skysaw
Skysaw wrote:
I guess the question then comes down to what the desired behavior is for a missing player. If you don't want computer AI, sounds like you'll have to develop some complex rules for redistribution when someone drops out. Either way, could be a lot of work.

Redistribution isn't so much the problem as dealing with a case when no one's available to take their place.

One thing to think about with computer AI... if it's too difficult to make them as smart as a human, make up the difference in other advantages. Dumb but stronger, quicker, or more accurate... whatever makes sense in your game.

Since it's a strategy game, "dumb" is pretty much it.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
One thing to think about with computer AI... if it's too difficult to make them as smart as a human, make up the difference in other advantages. Dumb but stronger, quicker, or more accurate... whatever makes sense in your game.

Since it's a strategy game, "dumb" is pretty much it.

You got dice rolls? Make 'em lucky! :-)
In response to Skysaw
Skysaw wrote:
You got dice rolls? Make 'em lucky! :-)

Dice rolls only come into play if the AI were to attack anything, which it couldn't do without some kind of strategy sense built into it.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
The problem with AI in Incursion is that designing actual AI for it would be incredibly difficult. I'd essentially have to build parts into the engine whereby a computer player could evaluate how many borders it's defending, what it could be defending instead if it controlled X and Y, how it would end up getting X and Y, and ultimately a strategy to lead it to try to work up to Z which bottlenecks access to that part of the map. This is to say nothing of redeployment, where borders may be fortified or resources moved into stockpiles. Right now all my AI does is deploy army units at random.

Game Programming Gems Volume II discusses "influence mapping", which provides a pretty easy solution to much of this.
In response to Deadron
Deadron wrote:
Game Programming Gems Volume II discusses "influence mapping", which provides a pretty easy solution to much of this.

I may have to pick that up, then. I've seen both books but never bothered to do more than browse through them.

My current concept of such an AI would be to include a procedure capable of taking a list of territories and eliminating every one that's bordered entirely by other territories in the list; this would be the borders. Then I'd have to compare that to a different list, and see how many borders that would have, the first goal being to reduce the number of borders and use redeployment to shore up the new front. I figure there are several broad goals in this sort of AI:

  • Obtain a geographically stable area with few borders (2 or fewer preferable); be willing to sacrifice lesser areas in the middle of nowhere.
  • Seek to expand the stable areas while at the same time reducing the number of borders.
  • Seek to expand the stable areas by other means if militarily feasible.

    Since this isn't Risk, there's little to be gained by a cheap middle-of-nowhere conquest just to pick up a card; cards are aquired by hoarding resources. Conquest actually increases the size of the stockpile needed to get a card on the next turn.
    However, long-term strategy would be tough too. Any Risk player knows that there comes a point in the game when an enemy is so vulnerable that you can take him out in one turn, pick up his cards, and either move on to someone else or fortify your position globally with reinforcements. This is often an endgame strategy, but it depends on the number of players involved.

    Lummox JR
In response to Lummox JR
Lummox JR wrote:
Deadron wrote:
Game Programming Gems Volume II discusses "influence mapping", which provides a pretty easy solution to much of this.

I may have to pick that up, then. I've seen both books but never bothered to do more than browse through them.

Influence mapping is a way to provide a mathematical model of the map that indicates who controls what areas, where there are weak spots on your side and their side, etc.

For what help it might provide, here's a pointer to a demo of influence mapping:

http://www.gameai.com/software.html#ANDRAE

A running java version of that demo:
http://www.ccg.leeds.ac.uk/james/influence/

And here's an archived thread on the subject:
http://www.gameai.com/influ.thread.html

I haven't checked these out in detail yet, but expect to use it soon for Sneak, and later for our strategy game.
In response to Deadron
That Java demo was pretty interesting. Different from what I expected.

Now, I could do something like this in Incursion, but in fact the strategic elements change things somewhat. For one thing, influence depends on the ability to attack; 50 units bordered entirely by friendly territory are worthless. Now of course the algorithm could be altered, but there remain other problems.

Consider: Two heavily fortified borders touch a single country that bottlenecks the entire region. One attacks and wins, moving in its strength. The strength of the other territory is now completely cut off from further attacks; the attacker must continue without it, leaving behind the units to guard the bottleneck when the turn ends, or redeploy immediately to end his turn.
In a single-attack model, this is fine, but each turn may be a campaign that must be planned out in advance. An influence-mapping model might determine wrongly that an attacker can take on 6 territories ahead with 60 units, when in fact the first territory is a bottleneck where at least 24 would be cut off. Thus the algorithm would overestimate an attacker's ability to capture and hold a new region. It would have to consider each possible step at a time and only then come up with a master plan.
This problem is easily illustrated in Risk. Have you ever, without thinking, attacked territories in the wrong order so that you were unable to conquer a territory and still continue your conquest onward?

Still, it's an interesting insight and might be worth applying in some way.

Lummox JR
In response to Lummox JR
Hey, apologies for my long absence
Lummox, you got a tough little problem to deal with. I doubt it makes sense to actually implement a robust and complicated ai, you should probably stick to building a finite automata of sorts (just break down your game into a simple series of actions and events). I did this for a project that always solves the game mastermind. By running a simple series of responses, I could evaluate a situation and come up with four distinct possibilities with easy solutions (I had to correctly guess the sequence of colors chosen by a player for four slots within k + 4 turns where k is the number of colors).
I read this book that suggests something really simple for ai development too. just make the ai do simple things one at a time. deploying units is your first step. then play the game and find the first mistake the ai makes. then all you do is go into the code and fix it. repeat the process until ai plays smart. This is sort of a hacked way to do it, but really I don't think you want to have search trees and planning, considering the ai is not even meant to be playing the game.

In response to Cybergen
Cybergen wrote:
Lummox, you got a tough little problem to deal with. I doubt it makes sense to actually implement a robust and complicated ai, you should probably stick to building a finite automata of sorts (just break down your game into a simple series of actions and events). I did this for a project that always solves the game mastermind. By running a simple series of responses, I could evaluate a situation and come up with four distinct possibilities with easy solutions (I had to correctly guess the sequence of colors chosen by a player for four slots within k + 4 turns where k is the number of colors).

The only real way to do this then would be just to attack at random, or do nothing at all.

I read this book that suggests something really simple for ai development too. just make the ai do simple things one at a time. deploying units is your first step. then play the game and find the first mistake the ai makes. then all you do is go into the code and fix it. repeat the process until ai plays smart. This is sort of a hacked way to do it, but really I don't think you want to have search trees and planning, considering the ai is not even meant to be playing the game.

If the AI does do anything, though, that's where the discussion comes in; it's easy enough to do nothing already.
If there's any realistic (or even close to realistic) decision making done, it will probably have to use the techniques I mentioned and then some. In terms of the AI making mistakes and making it smarter from there, well, deployment is already random and couldn't get much dumber.
This kind of situation really isn't one where a hacky method would work. Certainly some trial and error would be needed to produce a decent AI, but it would require some basic planning just to get the AI to a pathetic starting point.

Lummox JR
Page: 1 2