Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Nov 2005
Offline Last Active Today, 08:07 AM

#5290384 What does the "Most Constrained" heuristic mean?

Posted by LorenzoGatti on Today, 02:13 AM

It should be noted that it is an heuristic, and a cheap and dangerous one. There is no guarantee it approximates the optimal course of action, because it doesn't account for action utility.


In the example, if Mr Armor is a minor threat (e.g. he needs a free hand to fiddle with his phased force-field device and therefore he's armed with a little knife) Mr Rifle should shoot (like everyone else) the most dangerous enemies instead. After successively switching to generic enemies of decreasing priority, Mr Rifle should start shooting Mr Armor when it becomes more useful than contributing to killing another enemy faster. Meanwhile, the rest of the team switches from the last enemy they could attack to protecting and supporting Mr Rifle, since it's the most useful action they can perform.

On the other hand, if Mr Armor has a very high priority (e.g. he throws phased force-field grenades) everyone should target him; of course Mr Rifle figures out he can do it, while the rest of the team, knowing that they cannot attack Mr Armor, can either protect and support Mr Rifle if it's useful enough or attack generic targets; no need for a premature heuristic decision.

#5289854 Procedural Universe: The illusion of infinity

Posted by LorenzoGatti on 03 May 2016 - 02:16 AM

Rendering a whole universe of randomly generated stars amounts to a skybox. Whatever the player does in the game, it will be at a negligibly small scale compared to the displacement that's needed to notice any parallax error in the skybox. Only a few objects are close enough to require less cheap rendering.

I would prerender various skybox layers as much as possible: assuming we are around Earth, Moon, Sun and of course Earth and close space stations might need true realtime rendering; but Solar system planets could be a skybox layer (valid for a few minutes because they are moving); then individual visible stars and other small objects, valid for a large central region of the Solar system; Milky Way background, valid for a vast region of the Milky Way that probably exceeds the scope of a reasonable game; and finally close enough other galaxies. When the player goes to Mars, redraw satellites and planets and constellations as a luxury.

Quantitatively, bright objects are likely to be more expensive to generate according to fancy distributions than to render without storing them permanently; and if you have enough memory to display one skybox set and render future skyboxes to offscreen buffers you can easily brute-force billions of randomly generated stars over the course of a few minutes instead of doing something complex and approximate to draw a boring starfield in real time.

#5288758 OOP and DOD

Posted by LorenzoGatti on 26 April 2016 - 09:30 AM

One of the reasons that DOD is still relatively unknown outside of certain areas (game programming, high-performance computing) is because it solves a very specific problem: memory access bound performance.


But for the vast majority (IMHO) of software written today, CPU/memory bound performance is an order of magnitude less important than the much lower bandwidth issues (data access, network access, etc).


Most "typical" business software spends its time waiting for database queries or REST APIs to complete. If DOD improves your algorithm even by 1000%, that's not going to help much if the total time spent waiting for process x to complete is 90% dependent on a high latency process.  


I'm not arguing against DOD; it's very good for it's intended purpose. I'm simply attempting to explain why it's not more widely known.


But IO-bound software struggling between external systems and memory requires the same optimization techniques and principles as software struggling between memory and CPU: read data sequentially or at least in large pages, read data only once (if possible, never), organize data so you don't waste bandwidth reading unneeded data because it's interspersed with data you need, don't waste time and/or space storing redundant information that can be recomputed inexpensively from a small working set of data, and so on.

Apparently different techniques, like normalizing the structure of a relational database and organizing data structures in memory as "structures of arrays" actually serve the same purpose in the same way.

#5285229 Polymorphic uninvolved parenting?

Posted by LorenzoGatti on 05 April 2016 - 04:25 AM

Typically, UI widgets have a dual access (with base and derived types), in clearly separate places, and any casting is a very serious code smell.


Parent widgets and general functions like redrawing and event processing own and process received widgets through a base or intermediate widget type, call virtual methods and never cast widgets to derived types because they should never care about the difference.

For example, hierarchical layout of child widgets is usually managed in some intermediate "widget with children" class, which can be abstract, and which queries child widgets about what size they want to be through functions in the base widget class.


On the other hand code that creates widgets knows their types exactly, allowing the use of any constructor of any widget type (a large part of code that needs a specific type), and allowing specific types in calls to some special function. No casting needed; on the contrary, you normally pass widgets from variables of the most derived types to functions that demand a less constrained type, gradually or completely forgetting the concrete types where they are irrelevant.

#5284999 Hierarchical pathfinding. What does it mean to me/us?

Posted by LorenzoGatti on 04 April 2016 - 04:43 AM

What do you mean by portals, clusters, "abstract" paths and "on rails"? Are you asking about theory, about some library with an uncertain name, or about something in your application?

A better effort to express yourself in English appears necessary.

#5282292 My design idea - contains many elements

Posted by LorenzoGatti on 21 March 2016 - 02:22 AM

For example, game design issues include zoological issues. A "realistic-looking" bat character doesn't seem suitable for "standing on two feet" (bats ordinarily hang from above, mostly head down), or "moving as fast as Mario" (it might cautiously crawl on all fours), and it certainly can't "punch, kick and butt-stomp" effectively with its light frame and delicate little claws

But above all, why would a bat accept to confront a platformer game on its own terms, walking, jumping and exchanging blows, instead of flying and attacking in flight?

#5281641 conservative advancement help

Posted by LorenzoGatti on 17 March 2016 - 05:51 AM

It seems that the purpose of your function is to "move" c1 and c2 from their state at time t0 (by altering their pos members) returning true if they have a collision, and in that case advance them only until they touch.

At first sight it's reasonable, but you discard the most important piece of information: when do c1 and c2 collide? Instead, you should return t, how long c1 and c2 were able to move without colliding.

Given the maximum advancement time step T (it can be a constant, or a relatively read-only global variable, rather than an argument of your function, but hardcoding T=1.0 like you do is quite messy) the calling code knows that If t = T the circles can advance without colliding; while if t < T they collide after moving for a time t. 


The other great misunderstanding is that there are more than two objects. Conservative advancement is advancing the simulation from an initial state to when the next collision happens or by the target time step T, whichever happens first; then resolving the collision (causing some objects to change velocity, cease to exist, etc.) and repeating until the sum of the conservative advancements reaches T and you can draw the next frame. Clearly the t values you use need to be the minimum of all pairwise collision times, and you cannot commit an advancement until you know no collisions precede its end time: if c2 hits c3 before when it would hit c1 if c3 didn't exist, the collision time between c1 and c2 is invalid.



Other logical errors, like having a while loop, not initializing vel_bound, using distances between circles rather than between capsules, moving only c1 but not c2, using relative velocity rather than the actual velocities of c1 and c2, while serious, are quite irrelevant.


Suggested changes, assuming pointLineDistance() takes three Vec2 arguments, the single point P and the endpoints A, B of the segment, and returns the distance between P and AB and p such that the closest point to P on the segment is A+p*(B-A); 0.0<=p<=1.0.

//add const and constexpr to taste
double possibleAdvancement(Circle *c1, Circle *c2, double T){ 
    Vec2 rel_vel=c2->vel-c1->vel;//c1 remains still
    std::pair<double,double> distance=pointLineDistance(c1->pos,c2->pos,c1->pos+T*rel_vel);
    if (distance.first<(c1->radius+c2->radius)){
        return distance.second*T;
        return T;

#5277852 Interstellar trade at a relativistic timescale?

Posted by LorenzoGatti on 24 February 2016 - 03:39 AM

Using relativistic speed space travel only for a single point to point 1/12 year trade route between Sol and Tau Ceti is an unnatural constraint on the use of technology.

Instead, I would expect spaceship owners and spaceship crews to find something useful to do with their vehicles.

  • Extra worthwhile stops at less terrible distances. Destinations could include other colonies on less habitable planets, completely automated operations (e.g. asteroid mining), and maybe some kinds of major artificial space stations (e.g. deep space military shipyards, with lots of people and large deliveries of various resources). Reduced travel times (e.g. 1/12 months) mitigate all problems, allowing flexibility and stability without creating an obstacle to those who can accept, or desire, the "time travel" of a long trip.
  • Exploration, including SF staples like prospecting for minerals and contact with alien races, at all scales of time, cost and organizational complexity: a casual detour of a few days to investigate a mysterious sensor reading, fanatics or amateurs who go "out there" with their own means, systematic public initiatives.
  • Living on ships permanently as a nomadic lifestyle for whole families and tribes, with little interest for the landlubbers they leave behind in fast time. It could be the lifestyle of the vast majority of mankind, stabilizing society from the bottom up because everyone is away and any change or initiative needs years to spread.

#5277571 Free painter program with transperent color

Posted by LorenzoGatti on 23 February 2016 - 03:04 AM

Depending on what you need to do:

  • Krita for painting, particularly with a tablet; very good with layers. 
  • Inkscape for vector art (including rendering images at any resolution you need for use as sprites and further editing) 
  • Gimp for low-resolution pixel art.
  • Gimp and Paint.Net for generic less creative editing tasks. The main difference lies in plugins: both have plenty (ranging from half-assed experiments, to simple and practical, to refined workhorses), but Gimp also has G'MIC, which should be enough for everyone, while Paint.Net has a significantly advantage if you want to write custom plugins (.Net, and the Codelabplugin development environment, rather than Scheme or Python or C with an irksome API).
  • Shoeboxfor various specific tasks.

#5275935 Parameters for pricing upgrades

Posted by LorenzoGatti on 16 February 2016 - 09:13 AM

If you have a time limit, it can be used to calibrate the price of an upgrade: at an higher price, the upgrade is bought later and it provides less value because it is active for a shorter time. Increasing the price shifts the upgrade from overpowered to good to unimportant to counterproductive; make it competitive with other ways to spend money. You can also make the upgrade cheaper and weaker, or stronger and more expensive, to assign it an early game vs. late game role.


For example, if the factory upgrade lets you create a widget worth $10 every 8 seconds rather than the normal 10 seconds, it's worth $10 of additional income (one more widget made) every 40 seconds of production. If it costs $200, it costs 20 widgets, i.e. all income from the first 200 seconds of the game, and it will be amortized to a net value of 0 after 800 more seconds when it yields the 20th extra widget. If, as plausible, the game lasts less than 1000s, $200 is too much. On the other hand at $100 the upgrade would be bought 100s into the game and amortized at 500s; with a longer time limit it would be slightly useful (e.g. a maximum net value of $20 with a time limit of 10 minutes).

#5275543 Polynomial Forms of SH Basis

Posted by LorenzoGatti on 13 February 2016 - 08:06 AM

Spherical harmonics are used in linear combinations: any arbitrary sign choice for the basis functions simply flips the sign of the corresponding coefficients with no practical or theoretical consequence. Different authors might prefer different sign choices.


By the way, if you ask people to discuss specific papers rather than a general topic, you should cite your references properly with the exact title and authors and/or a download URL.

#5275109 Level Design in 3D Space Shooter

Posted by LorenzoGatti on 10 February 2016 - 05:05 AM

I would expect the game to consist of

  • basic dogfighting in empty space
  • dogfighting with obstacles and cover
  • strafing or bombing, approaching large objectives from specific directions
  • chasing enemies, or being chased, through challenging obstacles (the better pilot increases difficulty and the worse pilot crashes, Star Wars style)
  • racing towards some objective, with undesirable delays such as obstacles and enemy fire

While a surface setting is a rich source of landmarks and varied objects for these applications, as suliman suggests, you can extract a lot of value from realistic and easy to make deep space stuff:

  • spaceship formations, to ensure variation in battle situations even in empty space
  • large spaceships, good as obstacles, objectives, landmarks, and enemies in their own right
  • fields of rocks, usually huge ones that cannot be exited before winning the battle; density and special features provide the necessary range of different danger levels
  • man-made debris, with a similar role as rocks but present in other locations (satellite orbits, near space stations, etc.)
  • medium asteroids (significantly bigger than typical ships) as landmarks, cover, and even military objectives (they can have surface to air weapons)
  • large asteroids (without significant gravity) to provide the same tactical situations as a planetary surface mission with cheaper graphical assets
  • distant and not so distant planets in the background as landmarks

You should probably design your levels as definite missions, i.e. not loitering around and waiting for enemy waves to appear out of nowhere. For example crossing a blockade, shooting down a convoy, escorting a ship, and other reasons to travel with a purpose and accomplish something clear.

#5272962 How to call this government system

Posted by LorenzoGatti on 28 January 2016 - 02:51 AM

I think in the past they had some sort of republic but they found it flawed. Then they decided to got for an empire. But because there were many factions and no one trusted anyone they decided to go for a truly neutral Emperor. They cloned it from a wide selection of supreme genes (not some nobles genes, just genes of the whole race, further selected by some algorithm). This way they got a person at the top that had no prior obligations, no family, no old debts and favours to be repaid. Truly neutral ruler to who all the factions could agree.
As a bonus such person can be considered a superior human (enchancers, the best combination of genes to make the best intellect, aggressive prunning of inferior genes, boosted immunity system, resistance engineered at the very early stage). No mental illnes, idiots and the like which were plaguing monarchistic systems. A speciment truly designed to be an awesome ruler.
I agree with the infrastructure thing. They need an extensive royal cloning facilities.


But there is no "they", only specific powers and factions.

If the old republic is so corrupt and weak that an empire seems a better option, how can distrustful factions agree on a "truly neutral Emperor"?

In the best case, some factions agree and support the emperor but many planets/systems/colonies where other factions are prevalent revolt, proclaiming some combination of independence and rejection of what they can well consider a coup.

And the best case scenario is unlikely: factions do not automatically erase themselves from existence only because of a new institution like an empire, and they'll try to influence and corrupt the empire.


The traditional way to found an empire is by superior power, possibly through peaceful means. For example, a "superior human" can rise to power by being, well, superior (and benevolent enough to gain popular support), crushing dangerous factions in the process; the emperor, rather than someone with a conflict of interest, can worry about being succeeded by his or her clones.

All it takes to have a superhuman emperor without unrealistic political dynamics is a spark of disinterested effort of a plausibly small scale, e.g. a single visionary scientist and a cloning vat, or even pure coincidence (example: Red Son, a recent "alternate universe" version of Superman where Kal-El lands on Earth at a different longitude and succeeds Stalin as the head of USSR).

#5272820 How to call this government system

Posted by LorenzoGatti on 27 January 2016 - 05:10 AM


I have thought of a society which got disappointed by the other government forms and decided to engineer the Emperor. They selected the best genes of their race and they cloned an Emperor to rule them all.

Genetically engineering an emperor isn't something that can be done by "society" as a whole. There must be a powerful organization that has the technological refinement and source material to produce a candidate (e.g the Tleilaxu in Dune) and a position of power or supremacy to impose him/her/it as the legitimate emperor; different factions would be expected to support their own emperors, even if they all agree on the basic premise of building a good ruler, and there might be severe civil wars.


When the emperor dies or retires, the problem returns. Is the emperor-making group permanently at the helm, avoiding disruptions with an easily installed new emperor? Or every succession causes a renewed conflict between factions (example: USA presidential elections)? Or it never happened yet because the first emperor is still ruling (example: humanity in Warhammer 40000)?


You could have mortal but very long-lived emperors that stress the self-preservation of the emperor-building system to the breaking point: where are, after a few centuries, the cloning facilities, the genetic engineers, the political support (in elections or other procedures that have not taken place for generations), etc.? The game could be about the emperor successfully organizing his succession and retirement in hard times.


The Pern novels by Anne McCaffrey are an excellent example of this subject; a planet struggles to maintain astronomy, various races of domesticated dragons, an idle paramilitary corps of telepathic dragonriders, and other expensive things that are only useful against alien critters who fall from the sky at intervals of several generations and are just about as terrible as an empire without his head, with coverage of how it went the first time (heroic emergency mode), how traditions and institutions were established, abandoned, revived and applied, and how great people made the difference.


In general, this system of making emperors is compatible with different government systems, possibly at the same time; true democracy if different candidates are offered for election and produced disinterestedly as a matter of duty and prestige, aristocracy if candidates are derived from the gene pool of certain families, rather corrupt oligarchy if candidates are expected, or engineered, to further the interests of their makers; if the emperor controls succession it would be a true autocratic monarchy; if there isn't much of an election it would be some kind of oligarchy or technocracy.

A custom made emperor candidate would, in most cases, avoid the internal struggles within factions that are usually implied in a normal election: no place for ambitious people who want to be emperor, no need to kill off everyone above yourself in a succession line, etc.

#5272555 C++ exceptions

Posted by LorenzoGatti on 25 January 2016 - 02:59 AM

Just an illustration that while having error reporting for logic errors is theoretically nonsense, in practice it's common as a debugging tool.

It isn't only a debugging tool. The DirectX implementation cannot trust its callers: logically incorrect API usage (for example drawing commands involving vertex data, frame buffers, shaders,textures etc. that don't exist or are in a bad or uninitialized state) is possible, and the best way to deal with it is reporting the caller mistake and containing the corruption, not  silently drifting into dangerous and inconvenient undefined behaviour.