Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 25 Nov 2005
Offline Last Active Yesterday, 08:57 AM

#5161260 Attribute and Formula Help

Posted by LorenzoGatti on 18 June 2014 - 03:24 AM

I think one key information missing is what range of damage you'd like to see (minimum to maximum).

The range of damage values is only a scaling factor, so simple to manage that I forgot it in the example formulas in my post.

The starting points are

  • A set of benchmarks: the fight of unit A vs. weaker unit B should end with A's victory with probability p, often p=1, and its duration of n turns should follow a distribution with a given mean N and a given minimum and maximum, possibly approximate.
  • A range of hit point totals for different units: highly compressed like in Warhammer to make defense and "saving" hit points a big deal, extremely wide like in D&D to make minor damage insignificant, or something in the middle.

Given these constraints, it's obvious that, if unit B has b hit points, A's typical attack should do b/N average damage per turn, independently of how the stats and equipment of A and B determine damage. 

Different ways to do b/N damage per turn are also independent from stats:

  • Fixed and certain damage X every turn: X=b/N. Only an option if hit point ranges are large or N is very small, or the necessary rounding to an integer will distort damage values.
  • Random damage: unit A's damage can be a random variable with an average of b/N. Winning probability p and the distribution of fight duration n can be computed from the distribution of damage.
  • A chance to miss: if unit A hits with probability q, doing X damage, q*X=b/N. Critical hits are a slight generalization to X or Y damage rather than X or nothing: q*X+(1-q)*Y=b/N. With both misses (probability 1-q) and critical hits (probability c conditional on hitting) you simply add three branches for X,Y and 0 damage: q*(c*X+(1-c)*Y) =b/N. And so on; X and Y can, of course, be random variables.
  • Random delay: if unit A attacks (on average) every m turns doing X damage each time,  X/m=b/N. In most games X<b (no 1-hit kills) implying m<N.

#5161003 Attribute and Formula Help

Posted by LorenzoGatti on 17 June 2014 - 02:01 AM

You need to decide how the combat rules should behave, then formulas that fit the requirements will be easy to find.

For example, consider critical hits:

  • Why do you want higher damage variance? How is low variance bad? Barring strange effects, higher variance gives a chance to the weaker party, and every game needs to find the proper balance between confidence and uneasiness (for strong characters) and between despair and gambling (for weak characters).
  • Wouldn't rolling virtual dice for damage, with the possibility of choosing the probability distribution of damage output quite freely for a desired expected value (in particular, larger variance can be obtained by summing fewer larger dice), be more flexible than a mixture of "high" and "low" damage?
  • Are you OK with a bimodal distribution? Would the players notice?

Or consider special (magical) attack and defense:

  • Against a given reference opponent (e.g. Str 50, Def 50, Mg 5), increasing Mg is equivalent to increasing Str and Def. What is the equivalence? Does it depend on your stat values? Or on the opponent's stat values?
  • For example, you might want a very linear system in which a +k Str or Def increase is always as useful as +1 Mg, regardless of your stat values, and against any enemy: expected magical attack damage could be (Str+k*Mg)/(Def+k*Mg).
  • Or you might want a strongly level-based system in which lower Mg values don't stand a chance against higher ones, with Str and Def mattering only in the same Mg tier: expected magical attack damage could be min( (Str-Def)*(attacker Mg - defender Mg), 0)
  • How many points of Str, Def, or Mg should equipment be worth? Should it vary according to stat values?

#5158061 Horror Story Help?

Posted by LorenzoGatti on 04 June 2014 - 04:50 AM

Rituals are only a detail of the plot, and in a game they should be designed according to practical criteria because they are completely arbitrary:

  • What is suitable for depiction? For example, chanting in made-up languages, chalk diagrams and candles might be rather family-friendly, violent human sacrifices in the middle of a disgusting sex ritual probably not. What pretty graphics and special effects are doable? How can they be adapted to be part of a magical ritual?
  • What is suitable for player interaction? Assuming the cult has to be disrupted, means could include sneaking an "impure" person inside a sacred perimeter, damaging an artifact, distracting or attacking cultists at a critical moment, delaying cultist travel, suppressing information, destroying or defiling a place of power, etc. The genre of your game determines the genre of the rituals; if the action is fun, any excuse about how magic works is acceptable..

On the other hand you should reflect on the higher metaphysical level on which your plot is supposed to make sense:

  • What are gods?
  • Are there even higher powers, e.g. generic "good" and "evil"?
  • What does it mean for a god to die, and revive?
  • What sort of magic is possible? (Reviving dead gods is probably one of the smallest niches of magic, probably something that never happened before; there has to be some larger body of tradition and knowledge.)
  • Where does magical power come from?
  • How can mere humans interact with gods?

For example, requiring the death of another (enemy?) god to resurrect the old dead one might range from appropriate because of cosmic balance and limitation mechanisms, to a reasonable plot gimmick to make resurrection difficult, to preposterous because the death of the god was a very special occurrence that has nothing to do with other gods.

#5155181 Roads (connection between villages/cities)

Posted by LorenzoGatti on 22 May 2014 - 02:28 AM

The first idea is to make some "build road" option after clicking on any village/city which would show DESTINATION ("neighbour" slots/villages/cites/nodes only) and by clicking you can build/upgrade a road/railroad. Also, my though is that maybe it should not be allowed to join any village with any village because it would look very messy (crossing of roads), so maybe some "distance limit" for the build road feature?


My suggestion to limit nonsensical road construction is relying on the Delaunay triangulation of village locations: allow roads that are an edge of the Delaunay triangulation, and forbid all others.

It seems that you are able to move, add and delete villages during initial map creation to obtain a nice Delaunay graph (with appropriate numbers of neighbours, sufficiently uniform edge length, etc.)

#5150283 Cars differentials, open, locked and preload

Posted by LorenzoGatti on 29 April 2014 - 03:48 AM

You are completely failing to explain the actual problems you have, apart from being perplexed by a new and unfamiliar subject or mixing up different models of different designs of differential. Are the cars in what I suppose to be a a racing game doing anything inappropriate?  


There is a wide range of useful locking and torque distribution policies you can adopt in your software-simulated differential, without even worrying about actual mechanical implementations.

As long as the behaviour of your differential is physically sound (e.g. you don't drive wheels with friction in the clutch, with preload springs, or with torques out of thin air) and it conforms to some basic principles (unlocked for small wheel velocity differences, locked when one wheel appears to be slipping) you can do anything you want with parameters such as a "preload torque": unlike actual physical quantities such as wheel angular velocities they are only an abstract description of what the differential does.

#5149881 Magic advancement system

Posted by LorenzoGatti on 27 April 2014 - 09:50 AM

Don't confuse different aspects of the magic system that are actually rather independent, particularly strategic improvement (acquiring new spells or improved variants of old spells), tactical spellcasting (e.g. gathering energy, performing rituals, hitting targets, etc.) and intermediate time scales (e.g. "preparing" spells in advance, D&D style, or keeping magical objects ready).

What is it that should feel more "magical" than learning from a trainer? What do you really need in your game?

Making study a boring activity that is left off screen and skipped over, but actual spellcasting player-skill-intensive, cool and complex, is as legitimate as making learning spells a varied collection of mystical revelations and discoveries, themselves an important part of the plot, but casting spells simple and dependable like mundane melee or ranged combat.

#5149868 DSP. Reverb

Posted by LorenzoGatti on 27 April 2014 - 08:33 AM

 The reverberation chapterof a a great textbook by Stanford professor Julius Orion Smith, "Physical Audio Signal Processing", is particularly comprehensive (feedback delay networks appear to be one of his research interests).

#5147837 Understanding and implementing "Immediate Stream Compaction"

Posted by LorenzoGatti on 18 April 2014 - 02:11 AM

Comparing the last diagram and your code, I don't see the "auxiliary array" of "block sums", nor the separate multithreaded processing steps that write it from collected per-block data (no locking, every thread writes only to one block's specific location of the array) and that read it to update the blocks (no locking, it's read only).

#5147064 Strange graphics file format

Posted by LorenzoGatti on 15 April 2014 - 03:19 AM

I was wrong about the modes, mode 1 means it's the difference from the pixel at (x - 1, y), mode 2 means it's the difference from the pixel at (x, y - 1). Still no clue about the other modes.

Edit: mode 3 is the difference from (pixel[x - 1, y] + pixel[x, y - 1]) / 2 or something like that

These appear to be the PNG filters. 1,2,3 correspond; other possible values include 0 (unaltered pixel) and 4 (Paeth predictor, see the PNG spec). Filter type 3 has a floor operation: the reference value is floor((pixel[x - 1, y] + pixel[x, y - 1]) / 2) in your notation.

#5146184 Need some pointers on a diplomatic AI

Posted by LorenzoGatti on 11 April 2014 - 02:20 AM

The different factions have the following tools to interact:

Declaring war for a specific neighboring sector
Giving gifts / send diplomatic ship to improve relations
Insult to lower relations
Trade agreements (allowing ships to buy/sell from other factions assets)
Passage agreements (using jumpgates from other factions to get to their sectors)
Military/Alliance agreements (both factions using military ships as one)
Give/sell/ask for a sector to improve relation or get money or remove a threat

Each faction has values that can be used: diplomatic power (how persuasive is a faction), xenophobia (how resistant is a faction to offers from another (to balance diplomatic power), how warlike or "tradelike" is the faction and so on. Most of it heavily influenced by 4X games.

Going to war is easy, but for the rest, like making alliances, allowing ship passage / trading and so on in a believable way, I am kinda lost. I don't really see a sort of generic algorithm that would make AI controlled factions using diplomacy without relying on a nightmarish mess of nested If/else/if/else. While I am fairly used to FSM logics which i used (to an extend) for individual units I don't really see that working on a faction level.

The major problem I see in this description of diplomacy is that most of it consists of arbitrary abstractions and ritual behaviour and it doesn't lend itself to translation into rules and game theory (which you need to have an AI that reasons in meaningful ways). 

If factions are interested in their own prosperity (as opposed to hurting themselves to hurt others more, e.g. going to war) they can simply be friendly with everybody: reciprocal trade and passage agreements, occasional fair exchanges of territories for good reasons, massive military alliances (marking the few rogue factions outside the alliance as a potential threat), no wars, no gifts, no insults, no bad relationships, no persuasion, no xenophobia. Strategy would consist of being ready to go to war with neighbours that aren't in the alliance in case they do something funny.

This style of AI would have to evaluate the economical benefit from trade and passage agreements (maybe a Monte Carlo simulation of commerce and travel with and without the agreement) and the best selection and deployment of military forces (maybe more suitable for thorough searching over move trees containing fleet movements, battles etc.).

#5145604 Pirate RPG class design

Posted by LorenzoGatti on 09 April 2014 - 02:23 AM

Almost any kind of spell would be highly useful for piracy as a job: illusions to mislead ships, fireballs etc. to threaten a whole crew, mind-affecting spells to make defenders ineffective, portals into the storage areas to loot without the hassle of a proper battle, offensive and defensive buffing to prevail in combat, etc. Magical countermeasures against piracy would be equally varied.

Your pirate class, on the other hand, isn't focused around piracy, it is focused on the sort of ship-to-ship personal combat required by a specific mundane style of piracy that would simply not exist in a world where magic is common and is a better way to fight at sea. 

You need a compromise between swashbuckling and magic: magic should be carefully limited so that it doesn't affect piracy enough to make combat useless.


For example, if almost any seaman could shoot decent antipersonnel magical attacks beyond cannon range, artillery would be obsolete (not a great loss) and engagements would begin with a possibly brutal shootout (not unlike the airship battles in the Last Exile anime); assuming magical energy runs out and there are no other common spells the engagement would proceed normally to boarding and evasion, with less ship damage and likely more wounded people than in real-life piracy (not affecting combat style too much).

If the same kind of magical shooting were a rare ability, high level pirate crews would hire a sniper and the sniper would pick off officers unopposed (or, rather, threaten to do so: what captain wants to order an attack knowing that he's going to be incinerated before seeing the outcome?).

Many targets would try to run faster than pirates or surrender because they can't, while rare and privileged targets would bring their own wizard sniper to put up a fight (usually causing pirates to retreat).

#5144042 Looping a sound with reverb causes a "pop" at loop

Posted by LorenzoGatti on 03 April 2014 - 02:25 AM

If you have the melody w/o the reverb, make a loop of it 3 times, run it through the reverb, cut the middle one and use that. It will have the end of the reverb of the first melody, which should be enough.

Even better, play the original clip once before repeating the variant with added reverb: the beginning of the music shouldn't have a reverb tail out of nowhere.


Also, verify that reverb tails are shorter than your music clip; you might need more than one repeat to reach a steady state that allows looping.

In the editing technique suggested by TheChubu, the second and third repeat in the output should be identical; alternatively, if you process with reverb one copy of the music followed by silence you can directly measure how long does the reverberated output take to decay to silence.

#5143407 Thesis Advice: Narrative Game with Imported OTHER Player Character

Posted by LorenzoGatti on 31 March 2014 - 01:34 AM

You need a suitable premise and character relationship structure in which:

  • An arbitrary number of characters can be added without great consequences (up to the expected number of "new game plus" iterations, but degrading gracefully beyond that).
  • The additional characters are substantially similar to the player character. More precisely, the player character of the previous iteration: if players can choose between different playable characters there could be different classes of "reincarnated" characters.
  • The additional characters have a "personality" that the player can perceive and understand. This probably requires the cast of fixed characters to be based on similarly complex emotional/cognitive models. What important and meaningful actions can such characters use to express their personality?
  • Character personalities can be inferred from player actions. You need to guarantee that the player performs enough measurable actions to gather the necessary data over the course of a game (including short and/or unsuccessful playthroughs).

I suggest a setting with a socially uniform large mass of somewhat varied characters, from which the player character and the "ghosts" are selected: the fraction of important characters with a role in the story can increase (but remains small) in successive playthroughs without actually adding people.

For example, recruits in military training, pupils at a boarding school, construction workers on a half-finished space station, convicts in a prison, etc.

#5142536 90´s Platformer Collisions

Posted by LorenzoGatti on 27 March 2014 - 05:41 AM

Regarding the specific questions:

Should SAT be overkill for this?

It might or might not be a good choice of clever algorithm for "phase 2".

Should I represent the characters as circles, and check if they hit a line segment?

A convex polygon or (if the character isn't convex) a simple polygon is going to be much more suitable for a character than an ellipse; rounded corners can cause the character to stand in a wrong position, something quite unacceptable in a platformer. Ellipses are popular collision shapes for bullets, which are actually round and tolerate some approximation because they explode on contact.

#5142512 90´s Platformer Collisions

Posted by LorenzoGatti on 27 March 2014 - 02:40 AM

I suggest starting from the rules, and optimizing geometric acceleration structures later.

You can implement a generic query (e.g. what platform segments, at what time, and from which side intersect this object if it moves between these two positions) in a simple, inefficient and obviously correct way, use it as the foundation of a complete collision detection system that does what you want (e.g. one-sided barriers, sliding on slippery surfaces, etc.), and when you have refined your requirements try optimized, more complex and less general algorithms.