# Unity "Victory" function. Your opinion wanted.

This topic is 3463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Well, I'm sorry, but I want to be honest.

I don't see any sense behind your idea and no practical use. I don't think this can be used to ommit thousands of lines of code. Logic is logic, and if you simplify it and simplify it you'll reach a level where it can't anymore be simplified. And there is surely no magic function to replace thousands of lines of low-level logic.

Alexander

##### Share on other sites
I have a victory equation already:
def is_victorious(): return enemies.empty()
Can you explain how yours would simplify my code?

##### Share on other sites
But what if there is a possibility of a tie? It wouldn't be able to tell me if the game ended in a draw. And as for the point you pass in (I say point because it's basically a 5-dimensional point, at least how you're using it), how would you know what to pass in? For my chess game, how would I know what point to pass into the function to tell me if there was a three fold repetition, stalemate, check mate, draw, fifty move rule, or the impossibility of a check mate (and yes, these are all possible outcomes of the game)? And even if I did know what to pass in, how would the function know how to deal with those numbers? And how would this function be a "universal" solution? How could it handle all the possible outcomes of chess, Halo, scrabble, sudoku, Snake, Pong, Portal, Tetris, Starcraft, Metal Gear Solid, etc...

No, I don't think it could ever do what I needed it to without me customizing it to my needs, which destroys its whole purpose. And if a game really truly does require thousands and thousands of lines of code, I'm going to guess it requires some special tests that a single, 5 float parameter fuction couldn't do.

##### Share on other sites
Quote:
 Original post by ItignitionI think that I have exhausted the attention and interest of my peers in the topic I am about to present to you

Might have to do with talking yet failing to present anything concrete.

Quote:
 It is a programming function that collects 5 arguments of game play, war-room data or the status of a pool game; basically anything.

[true,false] = f(a,b,c,d,e). Ok.

Quote:
 The inspiration of the victory equation is a result of writing code-block after code-block of conditional “if-else” code that I believe is unnecessary no matter what game you are creating or to what the theme or conditional is.

Then comes de-coupling of code, entity driven approach, polymorphism, and other programming concepts. Patterns such as factories also help reduce hard-coding values.

Furthermore, it can be shown that if/else condition can be implemented using logical operations only. Through that, they can be transcribed into pure FSMs, which is basically what current processors are.

Quote:
 The victory equation takes 5 arguments (at this point).
Why not 42? 38 of them can be the same as the 4th dimension.

Quote:
 Each of the 5 arguments takes into account a value from each xyz co-ordinate and includes the 4th and 5th dimensional coordinate that is happening on screen at a given frame.
This makes no sense.

Quote:
 The x-plane values, the –y-axis values, the z-axis values, omitting 4th dimension from Einstein theory of Time and light (for now; because I cannot see the applicability), BUT includes the 5th hyper-dimensional value (from within).
Oh-key.

Quote:
 The 5th dimensional value might perplex you at this point, but to best describe what it is, in game terms it is understood by (“INSTA-damage”) or better described as damage that has no vector, velocity or collision instance. Think of a 2D world where a force from the z-axis comes in to collide with an entity. The entity would be confused and not understand why he is losing health because he cannot see the 3rd dimensional co-ordinate.
So, Act of god?

Quote:
 Anyway, back to the “Victory” equation. I am asking this to the game community what they think about this. Would you use this?

Use what? You haven't shown anything, demonstrated anything, there is nothing, except a 3 things which kinda are, one which is omitted for no explainable reason, and one thing which is everything else.

What is the equation? For example, an existing application, when executed, returns either 0 (success) or non-zero (failure). As such, any existing application conforms to "victory" equation.

Quote:
 Do you think it has application in eliminating the “if-else” and looping conditionals of game programming? I assume that thousands of thousands of lines of code could be omitted because of the nature of the “Victory” equation

If something can be omitted, it's redundant in the first place. Turing complete languages allow same algorithm to be implemented in either of them. If the "victory" equation is Turing complete, then it can do the same.

But if-else, as well as looping, are merely one thing common to C-family of languages (in a broad sense). They are not by far the only way to implement algorithms.

And one thing missed by "victory" equation is this;
- You go to store, and buy WoW. Thousands of hours of fun promised.
- You go home, install it
- The game prints: "true"

And that is it....

Or perhaps this topic is so far above my modest understanding of universe that I can't comprehend what it's about.

##### Share on other sites
Some of the responses so far have been blunt, to say the least.

However, I'm afraid to say I don't quite understand what exactly your equation does. I understand it in the general sense but cannot see the practicality of the equation. It may because I'm not getting the full scope of the things. Since you understand what you are doing far more than us I think that to convince us and well enlighten us perhaps a demo would be good. Otherwise I don't really see how it could be like a magic bullet. I'm not one to cut corners or do anything that makes the job 'easier' so it may just be a bias. It is a cool idea and thanks for sharing it with us, but I think maybe a visual would assist us in understanding what exactly your aim is.

##### Share on other sites
I'm finding many of the responses for this community not very friendly. I agree with Jinroh when he said they are blunt but I do want to address one of them.

Mike you raise a very good point. I do not have an answer for your chess game. I think you could be correct because the game possesses a 3rd value "a tie" which then does not have applicability with the victory equation because the game does not end in a boolean answer. there is a 2 ( 0=lose, 1=win, 2=tie) a tie.

Keep in mind, there is no existence of the Victory equation. Think of it as the absolute perfect example of polymorphism.

As for Anthus, amid your sarcasm and willfulness to be aggressive towards this idea (I have no idea why it make you so mad??):( I am trying to example the concept of this as best I can to you the reader. To elaborate on the 2 dimensional entity that I explain of (that you somehow took offense to) I steer you to this great video on the explanation of flatland, to gain understanding into what I am talking about.

From the way that I see it, most games that involve a live or die boolean as to what mesh or sprite gets deleted all follow a similar trait. "Does the A sprite get deleted or does the B sprite get deleted" and if the programmer can represent an amount to this question to a simple float value represented by force then we can predict who wins.

2d war game:
player1xplane = forceValue(1000 troops)
player2xplane = forceValue(200 troops)
bool player1 = 1

2d shmup
player1yplane = forceValue(64.4) // strength of shots on y-geometric plane
NPCyplane = forceValue(20) // strength of enemy NPC

now for 3d mesh
who wins:

The point here is the possibility of matching the victory function against an object and having one generic collision evaluation equation returned back by the Victory equation.

the point is just trying to omit

while (!health == 0)
if....
if.....
if ....

It just a thought, and again, I am not a physicist just a open-minded programmer.

[Edited by - Itignition on July 10, 2008 3:02:13 PM]

##### Share on other sites
Quote:
 Original post by ItignitionIt just a thought, and again, I am not a physicist just a open-minded programmer.

No one is getting after you for not being a physicist. What no one understands is why you're trying to mix physics and boolean logic. As Antheus said, you don't have to use a bunch of if-else statements to test if the game is still running. There are more advanced methods, all of which are practical. Attempting to force physics into game logic is a bad idea. And your example has nothing to do with Einstein, Hawkings, quantum mechanics, or even classical physics. And why would anyone want to omit their main game loop (what you used as while (health != 0))? That's when you play the game. Why the heck would you want to remove your game loop and tell the player that he lost before he could even click a unit and tell it what to do. Again, as Antheus helped showed, if a person tries to play such a game, they're gonna be one pissed off person.

##### Share on other sites
Either this is a joke, or I just don't understand what you're saying. Give us a simple but actual example of this "Victory function", because right now what you say makes absolutely no sense to me(actually, it sounds like Star Trek pseudo-science technobubble).

##### Share on other sites
You're not making too much sense though. Are you proposing this as collision detection? There's already algorithm's for calculating collision of various geometric primitives.

From the way you've described it it just sounds like you're trying to say

if (collision(a1,b1,c1,a2,b2,c2))
then if ( e1 > e2 ) return true
else return false

There's nothing revolutionary there and it definitely doesn't have an application in most games. I guess I'm just in the majority here that don't really understand what you're trying to say. I mean no offense it's just what your proposing doesn't really fit into games at all.

##### Share on other sites
Why stop there?

Why not make a compute_result(int) function, which could replace any existing computation?

avatar->pos.x = compute_result(54);

or

crazy_talk = compute_result(LAY_OF_THE_WEED);

##### Share on other sites
Quote:
 Original post by ItignitionAs for Anthus, amid your sarcasm and willfulness to be aggressive towards this idea (I have no idea why it make you so mad??):(

You did not make me mad in any way. And aside from last sentence, my post contains no sarcasm - only legit questions.

Quote:
 I am trying to example the concept of this as best I can to you the reader. To elaborate on the 2 dimensional entity that I explain of (that you somehow took offense to)

No offense taken whatsoever. I'm on my best PR behavior.

Quote:
 I steer you to this great video on the explanation of flatland, to gain understanding into what I am talking about.

I watched the Cosmos series when it originally aired on TV. I own the book Sagan published in combination with the series.

Quote:
 From the way that I see it, most games that involve a live or die boolean as to what mesh or sprite gets deleted all follow a similar trait. "Does the A sprite get deleted or does the B sprite get deleted" and if the programmer can represent an amount to this question to a simple float value represented by force then we can predict who wins.

Here are two more (non-aggressive) thought experiments:

- What is the "victory" result of a game of "Thermo-nuclear war"?
- What is the result of ELO rated matches?

##### Share on other sites
Quote:
 Original post by Antheus- What is the "victory" result of a game of "Thermo-nuclear war"?

A strange game. The only winning move is not to play.

##### Share on other sites
Mike, I'm not in any way suggesting the elimination of the game loop. I'm just attempting to research if there is a more abstract way of approaching conditional logic in games. The questions I'm asking myself are:

1.Is there a better way?
2.Does this not see terribly in-efficient to you as a programmer?
3.Is it possible to have a generic function (which I have no idea how big, or at this point) to do all of the former if-else, switch-case.
4. Could we have a conditional victory frame algorithm for each soldier on the battlefield.

Try this example...

Think of an RTS. 100 units on a screen. Does not matter if its a C&C clone, an AOE clone a Startcraft clone, whatever. They all share the same property as victory over their foe.

EACH Freindly-unit A runs his victory equation against his enemy-unit B. the equation is generic so it take the sprite positionx ,y and z checks if there is damage from the 5dimension or cheat mode. Then the equasion takes a force value and runs it against the force value of the enemy. then the function returns whether the player dies or lives.

so the victory equation, no matter if its in a shmup, scroller or rts, has a generic formula to govern combat.

that is the premise. (I'm trying my best to explain, but I'm having trouble over this thread, I apologize for this)

##### Share on other sites
I think Dancin Fool just hit the nail on the head. If a generic formula exists I did not know about it.

where is are these generic (well known) algorithms posted or documented?

Thank you.

##### Share on other sites
This function would run in O(n2) if I'm not mistaken according to your example. swiftcoder's function runs in O(1). Also, why would I want to test against all the units? The units are only going to kill who I tell them to attack, so why should I care if the enemy unit accross the map could kill my sniper when my sniper is just picking off local enemies? And why would that make me lose? Each of those games have a generic win/lose which is generally similar, but the actual implementation is different because they have different enemies, different requirements, different goals.

##### Share on other sites
Quote:
 Original post by ItignitionEACH Freindly-unit A runs his victory equation against his enemy-unit B. the equation is generic so it take the sprite positionx ,y and z checks if there is damage from the 5dimension or cheat mode. Then the equasion takes a force value and runs it against the force value of the enemy. then the function returns whether the player dies or lives.so the victory equation, no matter if its in a shmup, scroller or rts, has a generic formula to govern combat.that is the premise. (I'm trying my best to explain, but I'm having trouble over this thread, I apologize for this)

But this is how every game works.

With one exception. Your equation, as stated above, does not exist. Since games which contain non-existent code don't compile, programmers implement "victory" equation.

And it looks like:
// This is the part you never defined, the nonexistent equationbool victory(Unit attacker, Unit target, Game g){  int damage_to_deal = g.godMode() ? attacker.weapon.damage : 99999;  if (inRange(attacker, target, attacker.weapon.range)) {    target.dealDamage(damage_to_deal);  }  return target.health < 0;}...// This is then the magic use of this equationwhile (victory(player, enemy, game));

You can formulate and parametrize aspects of the game in any way you want. Ultimately it's just syntax.

With event-driven approach, things would be different:
enemy.onDamage = playDamageAnimation;enemy.onDeath = playerVictoryenemy.onAttack = playAttackAnimationplayer.onDeath = gameOverplayer.onAttack = dealDamage,playAttackAnimation

And then, once everything is wired up, you start the game and things seemingly just happen.

This is data-driven programming, or data-flow approach, or many other variations. LabView uses such programming model, so do some other applications. DirectShow used to provide an editor for this type of multimedia stream manipulation with the DX kit.

##### Share on other sites
Quote:
 where is are these generic (well known) algorithms posted or documented?

Wikipedia knows all

I guess I'm one of the majority of people who doesn't understand your function. Where exactly would you apply this function in the main program? What if it's one of those games that have no win, lose, or tie at all? Instead of trying to force abstract theories in game logic, work out the function on paper or something and list the steps the function will take to return its value.

##### Share on other sites
Quote:
 Original post by ItignitionI think Dancin Fool just hit the nail on the head. If a generic formula exists I did not know about it.where is are these generic (well known) algorithms posted or documented? Thank you.

He's talking about a generic collision detection algorithm, not a generic win/lose algorithm.

##### Share on other sites
Quote:
Original post by Antheus
Quote:
 Original post by ItignitionAs for Anthus, amid your sarcasm and willfulness to be aggressive towards this idea (I have no idea why it make you so mad??):(

You did not make me mad in any way. And aside from last sentence, my post contains no sarcasm - only legit questions.

Quote:
 I am trying to example the concept of this as best I can to you the reader. To elaborate on the 2 dimensional entity that I explain of (that you somehow took offense to)

No offense taken whatsoever. I'm on my best PR behavior.

Quote:
 I steer you to this great video on the explanation of flatland, to gain understanding into what I am talking about.

I watched the Cosmos series when it originally aired on TV. I own the book Sagan published in combination with the series.

Quote:
 From the way that I see it, most games that involve a live or die boolean as to what mesh or sprite gets deleted all follow a similar trait. "Does the A sprite get deleted or does the B sprite get deleted" and if the programmer can represent an amount to this question to a simple float value represented by force then we can predict who wins.

Here are two more (non-aggressive) thought experiments:

- What is the "victory" result of a game of "Thermo-nuclear war"?
- What is the result of ELO rated matches?

The answer to your last question is player A if his objective was suicide, thus he wins, or the reciprocal player2 :)

Again, I told you guys in the first thread.......

"But you people as educated mathematicians, theorists and programmers (who are probably, far more educated and smarter than I am), might have an idea of this subject and can hopefully comment on the plausibility of this equation that I am attempting to construct."

##### Share on other sites
So, back from the first post, you say that this function will recieve 5 arguments. What are those arguments exactly? It sounds to me like the it would basically scan the entire game, recieve arguments, and determine whether the player wins or loses. But what exactly ARE they?? Are they missions the player must accomplish? Or does it basically scan the game and checks what kind of changes the player made to the game and determines whether they win or lose.

I'm not being mean or anything. I think it's interesting but I have absolutely NO idea what you're talking about and I have no idea how I could apply this to a game.

##### Share on other sites
Quote:
 Original post by MoonshoeSo, back from the first post, you say that this function will recieve 5 arguments. What are those arguments exactly? It sounds to me like the it would basically scan the entire game, recieve arguments, and determine whether the player wins or loses. But what exactly ARE they?? Are they missions the player must accomplish? Or does it basically scan the game and checks what kind of changes the player made to the game and determines whether they win or lose.I'm not being mean or anything. I think it's interesting but I have absolutely NO idea what you're talking about and I have no idea how I could apply this to a game.

This is how I have self defined it for the Victory Equation.

Definition of "force": unit count, attack power, unit strength, unit, object.

the Victory equation would evaluate the game world or scene co-ordinate system and not the object level co-ordinate system.

The generic polymorphic function essentially manipulates these arguments:

Argument 1: force over the x axis, the magnitude, measured not in velocity, but in force or power. the strength of the unit. Could be represented by health, attack power or anything representing x-axis force.

Argument 2: force over the y axis, the magnitude, measured not in velocity but in force or power. (same as x, but on the y-axis)

Argument 3: force over the z axis, the magnitude, measured not in velocity but in force or power. (same as x and y but on the z-axis in the event of a 2D game or non 3d world, this would be represented by -1 or non applicable).

Argument 4: force over the 4th dimensional axis. "the energy" from within, measured not by velocity but in force or power ( note: I used the example of god mode, because I could not think of another example of losing health or momentum or any other sort of energy without having an event or collision.) Because there is not plot on the x or Y axis the loss of energy is represented here by the "unconditional amount of loss of energy health or power" to the opposing player.

Argument 5: Because the time is a concern in gaming and used readily, the argument in the Victory equation would take the timing into account of the amount NOT of energy or power, NOR in momentum or velocity, but of the required measure in time to correctly delay the instantaneousness of the event occurring

Note: the 5th argument allows for death animations, bloom effects, hell whatever you want to slip in there as the delay before the function returns. This argument can be multi threaded.

I have to go to work, but this is the best that I can explain where I am on the Victory equation currently.

##### Share on other sites
...Now I'm even MORE confused. So, what is this "force" that determines whether the player wins or loses in all those coordinates? And argument 5 is supposed to be some kind of magic parameter to make the game faster if it lags? And what if the game has no win, lose, or tie at all????

Again, I'm not trying to be mean, but I'm going to be completely honest. It sounds like what mikeman said.

##### Share on other sites
Quote:
 Original post by Moonshoe...Now I'm even MORE confused. So, what is this "force" that determines whether the player wins or loses in all those coordinates. And what if the game has no win, lose, or tie at all????Again, I'm not trying to be mean, but I'm going to be completely honest. It sounds like what mikeman said.

Force is the polymorphic argument here.

k lets set up a scene.

You are playing as an army of 500 that is trapped in the middle of a valley and the enemy is coming at you from all sides. the valley has 2 entrances, your army cannot cross laterally because the valley mountains are too high and steep.

you are currently bring attacked from the x-coordinate by a force of 1000 soldiers. (one force of 500 coming from the rear and 500 from the front)

you are currently outnumbered on the x axis by 500.

your opponents object is sending you = Vic(1000,0,0,0,0);

so, as they are approaching you realize that you are being strafed by 10 aircraft on your y co-ordinate. so Vic(1000, 10 * 2,) supposing aircraft have 2 times the power or force of a foot soldier

because during game play the battlefield is sometimes dynamic, you are receiving an attack on your z coordinate from a tunneler machine who is drilling through the rock. the drill is 40 times the power of the foot soldier

at this point the victory equation updates to Vic(1000,10 * 2, 3*40, 0, 0)
which has a value of of 40 times the power of a foot soldier.

in the current game state, cheats are disabled and the enemy is not hitting you with an electromagnetic pulse beam that you cannot see. Therefore the status of the equation is

vic(1000, 10*2, 3 * 40, -1, 0 );

and finally...

because animations take time. and effects to draw to screen and we dont have control over multiple computer platforms we use a time mechanism to govern delay) of say rest(8);

vic(1000, 10*2, 3* 40, -1, 8);

##### Share on other sites
Sounds like a recipe for a damned boring game of Sim City!

It's about time someone invoked the timeless classic: Please post some code so we can diagnose your problem properly (or at least understand what the hell this is about.)

• 11
• 11
• 9
• 12
• 10
• ### Similar Content

• So I am building a turn based rogue-like (think CDDA). The game is going to have a very large map (up to 1000's x 1000's) however to alleviate most of that I obviously can't render everything so there will just be render a certain radius around the player and just load in and out data as the player moves.
The next major system I am prototyping is making interactive tiles destructible and pretty much everything will be destructible besides basic landscape (cars, doors, windows, structures, etc. will be destructible)
While I am only rendering a certain amount of tiles around the player, I want to keep the amount of colliders active at one time to be as small as possible for performance and currently the tilemap tool I use automatically merges colliders together.
So instead of creating a separate colliders for each of these tiles and having the destructible behavior tied to that object (which my tilemap tool would allow me to do) I was thinking that I would store an array of all the X and Y locations for the interactive tilemap layer and let the tilemap manage the colliders.
Then when I hit a collider on the interactive tilemap layer, instead of of getting the behavior for how to deal with the destruction for that tile from that game object, I would pull it from the array I mentioned earlier based on the tile I attempt to interact with which I already have.
Does this sound like a good approach? Any other recommendations would be welcomed.

• Hey guys,
I have a really weird problem. I'm trying to get some data from a REST service. I'm using the following code:

private void GetTheScores() { UnityWebRequest GetCommand = UnityWebRequest.Get(url); UnityWebRequestAsyncOperation operation = GetCommand.SendWebRequest(); if (!operation.webRequest.isNetworkError) { ResultsContainer rez = JsonUtility.FromJson<ResultsContainer>(operation.webRequest.downloadHandler.text); Debug.Log("Text: " + operation.webRequest.downloadHandler.text); } } The problem is that when I'm in Unity's editor, the request doesn't return anything (operation.webRequest.downloadHandler.text is empty, the Debug.Log command just prints "Text: "), but when I enter the debug mode and insert a breakpoint on that line, then it returns the text properly. Does anyone have an idea why is this happening?
The real problem I'm trying to solve is that when I receive the text, I can't get the data from the JSON. The markup is really simple:
[{"id":1,"name":"Player1"},{"id":2,"name":"Player2"}] and I have an object that should accept that data:
[System.Serializable] public class ResultScript { public int id; public string name; } There is also a class that should accept the array of these objects (which the JSON is returning):
[System.Serializable] public class ResultsContainer { public ResultScript[] results; } But when I run the code (in the debug mode, to get any result) I get an error: ArgumentException: JSON must represent an object type. I've googled it but none of the proposed solutions work for me.
Also (regardless if I'm in the debug mode or not) when I try to do some string operations like removing or adding characters to the GET result, the functions return an empty string as a result
Can you help me with any of these problems?
Thank you
• By nihitori
The Emotional Music Vol. I pack focuses on beautiful and esoteric orchestral music, capable of creating truly emotive and intimate moods. It features detailed chamber strings, cello and piano as the main instruments, resulting in a subtle and elegant sound never before heard in video game royalty-free music assets.

The pack includes 5 original tracks, as well as a total of 47 loops based on these tracks (long loops for simple use and short loops for custom / complex music layering).

A 15 seconds preview of each main track is available on Soundcloud:

• Another one of our new UI for #screenshotsaturday. This is the inventory screen for showing what animal fossils you have collected so far. #gamedev #indiedev #sama

• We're looking for programmers for our project.
Our project is being made in Unity
Requirements:
-Skills in Unity
-C#
-Javascript
-Node.js
We're looking for programmers who can perform a variety of functions on our project.
Project is a top-down hack-and-slash pvp dungeon-crawler like game. Game is entirely multiplayer based, using randomized dungeons, and a unique combat system with emphasis on gameplay.
We have a GDD to work off of, and a Lead Programmer you would work under.
Assignments may include:
-Creating new scripts of varying degrees specific to the project (mostly server-side, but sometimes client-side)
-Assembling already created monsters/characters with existing or non-existing code.
-Creating VFX
This project is unpaid, but with royalties.

---