Tag Archives: games

The Other Factions

I am converging on a working RTS engine whose architecture I’m quite happy with. The AI system still needs a little work, probably involving a simple C++ superset language to handle the bullshit necessary for the setup I’m seeing, but since I value readability/learnability nowadays, I’ll see if I can come up with one that doesn’t require such mangling. Anyway, the only supported bit of the engine right now is the standard RTS unit-based style, but the time will soon come that I’ll want to implement the other factions. Before I do that, I have to figure out what they are.

The first alternative faction that Namaste and I have discussed is a “plant” faction which has only buildings and spreads its influence using the wind, roots, and other implicit methods. The play style of that faction will probably end up being something more discrete-feeling. There could be plants which are very lethal and very hard to destroy, but since they are immobile it may not be unbalanced. Instead, the game would be about trapping your enemy and closing on them, rather than organizing an army for a tactical strike. The challenging thing would be using the wind to spread: you would have to wait for the right wind direction, and even then you would only have a vague idea where the building would grow. More generally, a building’s power could be inversely proportional to the control you have in placing it.

Another faction that we’ve talked about is one inspired by nanomachines. This faction’s units would behave normally, except at any time they could convert themselves into something of equal resource value. That is, your entire base could just be a field of resource collectors, and when there was an attack you could convert them into a big army of infantry. I would like to balance this faction in some other way than just making them weaker to compensate; instead I would like to manifest a different play style like there is for the plants. Nothing is immediately coming to mind.

I just had two more ideas as I was watching Star Trek TNG today. The first is a faction that can only communicate by contact, which would involve that kind of long-term planning strategy that i wanted with my relativistic strategy game (which I abandoned due to the complexity of programming with a frame-of-reference-centric world). The second is a faction that could project non-reality onto its opponents, not necessarily chaning the play style for that faction, but changing it for its opponents (which is especially good to challenge those who get really good at just one strategy). The game for the opponents would be about decoding the difference between reality and fantasy; it would be about recon and checking for information consistency. I’m quite excited by this one, even though it would be a challenge to balance.

That’s all for now. I just wanted to jot these down.

Factions in a strategy game

I haven’t played starcraft in years, and when I did it was minimal. A few months ago, Namaste got back into playing it. I remember walking in his room to see Terran soldiers firing their machine guns, running on top of purple slime from which spikes were emerging and killing them. Later I learned that the purple slime just designates the area where Zerg can build, and the spikes were just a defensive building. However, the image had a strong effect on me.

I want to see a strategy game with (at least) three factions which are fundamentally different. Namaste put it well: “one side has units, another side doesn’t have units”. For example, you’d have the typical RTS faction with buildings that produce units that have guns. But another faction could be plants that only have biological weapons; they couldn’t chop anybody’s head off, but they could cause disease, metal corrosion, suffication, etc. Plants of course cannot move, but can spread their seeds. Perhaps a third faction would be a small tribe of people who could control animals, or something like that.

UPDATE: Namaste and I talked about it a bit. An interesting idea is a faction who only have “energy concentration” in areas, and that energy could take whatever form it likes. That is, you could have an oversized watch tower that could convert into an army when it needed to.

Parallel logic

An idea that Namaste and I had for the linguistic magic system was to have the spells that are cast alter the laws of the universe. Clearly this is a hard problem. But I like hard problems (see, for example, Minesweeper Infinity and Flamethrowerflies :-p). My current plan is to lay out a grid where each space may have any number of several properties. These properties interact with the players in predefined ways, but the way that they interact with each other will be defined by the user during the game.

Let’s say that two of these properties are fire(p,t) and water(p,t) (where p is position and t is time) One of the rules that a sorcerer could define would be: forall p t. !(fire(p,t) and water(p,t)), i.e. fire and water cannot be at the same place at the same time. Then the rendering phase would iterate over each position in the world and ask whether fire(p,t) is true, and if so, draw some fire there, and do the same for water.

This requires a logic engine almost, but not quite, entirely unlike Prolog. This logic engine must have the following property: if a formula’s truth value can be derived in a finite amount of time, then the engine must derive it in a finite amount of time (crossing my fingers that the construction of such an algorithm is even possible). Prolog most certainly does not have this property. Doing this for any logical form would be ideal, but I am okay with restricting the types of formulas that can be constructed. For example, universal quantification may be disallowed in queries and rules must be universal implication (the rule “fire exists” would be disallowed).

Thanks to Gödel, we know that there will either be a formula that can be proven both true and false or a formula which cannot be proven either. If fire(p,t) happens to be one of these formulas, I’m not sure what to do. We can’t just let the engine diverge (infinite loop).

The first step in my process would usually be to define a normal form that the formulae take. For example, Prolog defines rules as Horn clauses. However, when you ask Prolog a question, it either returns “yes this is true” (and gives you assignments to your variables) or “I cannot prove this”. My engine must return “yes this is true”, “no this is not true”, or “I cannot prove this either way” (and of course, “I’m still trying to prove this, but I’ve taken too long”). For example, if you have a rule “p(x) ⇒ q(x)”, the engine can either use p(x) to prove q(x) or use not q(x) to prove not p(x). It is not clear that Horn clauses have a property that makes this easy.

Hmm, actually Horn clauses have a property that makes this quite easy. Let’s say you have the formula: ∀x (∃y p(x,y) and q(x,y)) ⇒ r(x). Note that this is a Horn clause. We can apply the contrapositive and do some massaging to obtain the formula: ∀x ∀y ¬r(x) and p(x,y) ⇒ ¬q(x,y). Note that this is also a Horn clause. If there are variables that do not appear in the right side of the implication, they will be existentially quantified on the left, as the Horn clause requires. So basically, you can naively transform the Horn clause A,B⇒C to ¬C,A⇒¬B and also to ¬C,B⇒¬A. You can derive negation rules for every predicate you depend on.

With a breadth-first evaluation strategy (which is necessary for the “derivability” constraint above), you can attempt to derive multiple things at once, and stop at the first one you get to. So to ask for the truth of a statement P, you simply try to derive P and ¬P at the same time. You go with whichever one comes up first, and you cross your fingers and hope that it’s not possible to prove its negation (If it isn’t, then you’ll spin your wheels forever trying to prove it. If it is possible, then you will eventually prove it and show inconsistency. I.e. you can show that you are inconsistent, but you can never show that you are consistent.).

Transactional Game

I’m reading about transactional memory at the moment. I’m doing a presentation on it on Tuesday, so I don’t have much time to talk. I just wanted to write down this game idea before I forget:

I’m picturing a turn-based board game, but the idea could be generalized to many different strategy genres. Picture Chess or Go. You and your opponent take turns making moves as usual. However, you have “transactional control”. That is, you may start a transaction in which you can make a series of moves without your opponent knowing what you are doing. Differently from usual transactions, you can see what your opponent does in the mean time (unless he is also in a transaction, of course). You may commit any time you like and make your moves visible to your opponent. Here’s the kicker: if your opponent commits before you do, and his moves interfere with yours, your whole transaction gets rolled back, and it is as if you never did any of it. So it is good to use transactions to hide information, but if they get too long, then you are putting your position in the game at risk. It also encourages you to predict your opponent’s moves more, so that you can try to interfere with them.

That is all for now.

Strategy Jot

I’m pretty tired, but I thought I would jot down the ideas I created today while walking to school. This is for the relativistic, AI-based strategy game.

The tactical fighting style is playbook-based, like football. Each time you come across a unique situation, you grind it out, micromanagelike. Then you can watch a replay and encode your tactic into a play in your playbook if it was effective. At the beginning of the game, you have no plays at all in your playbook, and you don’t even have guidance about what a good play looks like. This encourages (even forces) users to come up with their own unique style without even realizing it.

Units have “wake units”. You can store up three wake units; that is, you can be awake for three “days” without sleeping. Then you must sleep, and you must have a good night’s sleep (you can’t sleep for ten minutes every hour and be rested). You get 3/2 of a day of wake for every day of sleep. This allows “fatigue battles”, where you just keep tormenting a defending army, keeping them from sleeping. Then when they are forced to sleep, you just roll over them (but you have to figure out how to get your own armies rested in the process).

Unit-to-unit battles are determined by a weighted random walk. When one unit engages another, the two units may not disengage until one of them is wounded. At the beginning of the fight, a counter is set to zero. Then every unit time it is incremented by 1 (say, with 70% probability), or decremented by 1 (with 30% probability). The first unit to reach an absolute value of 4 wins. This means that equally matched units take a long time to fight, so you can use them as a blockade. Say, for example, that you are fighting a line of swordsmen with a line of pikemen behind them. You don’t want to send in your cavalry, which will own the swordsmen, because your cavalry will just get owned by the pikemen. Instead, you should send in a line of swordsmen to stall the other swordsmen while you reposition to the back of the pikemen, or something.

Eliteness changes the value of 4 above. An elite swordsman versus a novice swordsman still has a 50% random walk, but the novice swordsman gets a higher threshold. It’s kind of like giving elite units more local-scale endurance. Here are some concequences of this battle system:

The probability that your unit will eventually win, assuming both units are level 1, and you have a p to (1-p) matchup against your opponent:

The expected time that the battle will take, assuming the same:

The probability that your unit, who has a 40% to 60% disadvantage, will win battle against a level 1 unit as a function of his level:

(Not very dramatic, but here’s the interesting one:) The expected time of the battle assuming the same:

The probability that your unit, who has a 60% to 40% advantage, will win the battle against a level 1 unit as a function of his level:

The expected time of the battle assuming the same:

Games

Namaste and I were talking about game ideas tonight. Here’s my priority list (which is different from his):

  1. Strategy game
  2. Music and Rhythm game
  3. Psychedelic action game
  4. Linguistic magic game

I’ve mentioned these all briefly before on this blog. I’ll run through them, then talk about no. 1 some more.

The main idea for the Music and Rhythm game is that you have a keyboard (computer or music) on which you make beats and riffs. The game would have a certain tempo, but the only thing that the tempo does is make what you’ve already played come around again at regular intervals. Each line would gradually fade out, but you’d get points for keeping lines you’ve already made going… for a certain amount of time, until the points you get for that line are insignificant. Plus support for solo sections, perhaps existing songs, multiplayer (hey, why not just get a jam club together?), etc.

I’m under an informal NDA about the psychedelic action game.

My main idea for the linguistic magic game (which must be attributed to a fellow named Chris who used to come to GameDev) is that it will be a ballistic shooter à la Scorched Earth or Warheads. But instead of aim-fire, you’d have to concoct sentences (in an artificial, completely foreign language) describing what you want your spell to do and who you want it to target. This mirrors what you see in fantasy stories; Harry Potter doesn’t have a list of commonly used spells that he hits numbers to use: he says words and waves his wand to cast a spell.

Continue reading

Logically Backwards and Forwards

I tried to ask Ovid (the author of AI::Prolog) about forward-chaining logic, but I realized that I didn’t really know what I was asking. Let this post serve as a brainstorming session to find that.

A smart game AI would like to be able to make inferences based on what any particular NPC knows. For instance, if I own a house, and it contains a couch, it would be reasonable to assume that I own that couch. That’s easy using backward chaining logic in Prolog:

    owns(X,Y) :- owns(X,Z), contains(Z,Y).

But there’s also the idea that knowledge changes. For instance, I’d like to specify something like (pseudo-syntax):

    owns(me,X) --> !owns(me,X)  { GET MAD! }

That is, if a piece of knowledge enters the database that causes owns(me,X) to go from true to false for a particular X, obviously it has been stolen. I’ll say that the new knowledge invokes a predicate transition. So one way to do this would be, for every transition hook, to poll once every certain while and check whether it has changed. That sucks though. The way it should work is the opposite way from general backward-chaining logic. It much more like dataflow.

Hmm… that defines the problem pretty well. I’m just wondering if that’s the way I want to do it. Is it transitions that I am really interested in? I think it is. If it weren’t, then I suppose I would just query the expression and bind the value out.

So in order to define such a transition, I need to tell owns/2 that when it changes, I need to update and possibly act. Huh, that’s interesting. It seems to be a knowledge base problem more than a combinator problem. The only thing I suppose I’m wondering is if there’s a better way to update knowledge than to re-run the rule.

Well, that defined the problem. How’s that for unstructured prose?

Pure Psychology

The other day, I came across the description of a game on Wikipedia known as Cooper Young (not a very catchy name, I know). It is the essence of psychological games: it removes the concept of game mechanics altogether. It is now one of my favorite games.

It is played on a checkerboard of any size, or a simulated one on pencil and paper, which is how I usually play. It is a two-and-a-half player game (the game is for two players, but you need three people). Player 1 picks a row of the board, player 2 picks a column. Then players alternate placing pieces (or writing their initials) on the board until someone picks the intersection of the chosen row and column. The third person, the referee, is necessary to tell the players when the game has been won.

My next programming project is to write an AI for this game.