Jump to content

  • Log In with Google      Sign In   
  • Create Account

frob

Member Since 12 Mar 2005
Offline Last Active Yesterday, 11:42 PM

#5251282 How do you divide 1.6 / 0.1

Posted by on 09 September 2015 - 12:29 AM

Yeah, I mentioned to pay attention to scale in each of the posts.  I guess the fourth time is the charm.  :-)

 

Orders of magnitude are important.

 

One or two orders of magnitude are usually normal in games.

 

Any time you see four or more orders of magnitude out of scale, it is so far distant that it doesn't even matter.

 

When you're working on meter scale, any power of ten (e0xx) more than +2 or -2 (or more) means something is likely broken.  

 

Going bigger, e+2 and you're talking about the distance of sports arenas; still possible in games but less common. e+3 is kilometers where you're normally looking at different levels or zones and normally not used in games. e+4 and you're talking the scale of cities. e+6 and you're talking full planet diameter.  

 

Going smaller, e-2 and you're talking centimeters which are about the limit downward. e-3 is millimeters, the scale of a fingernail width and usually too small for games.  When you had e-5 you're on the scale of the width of a hair, e-10 you're on the scale of a single atom. 




#5251273 How do you divide 1.6 / 0.1

Posted by on 08 September 2015 - 11:16 PM


5629997253417969e-005  the e-005;

It is just that the number is very small.

 

0.0000562999...

 

If you are talking meters, that is 56 micrometers. That's roughly the width of a human hair.

 

If you're talking meters per second, that is moving a human hair's width every second.

 

The one that had e-010, that's on the order of Angrstroms if you're looking at 1.0 being a meter.  That is the size of a single atom.

 

 

Again, those numbers are really small.




#5251259 How do you divide 1.6 / 0.1

Posted by on 08 September 2015 - 10:15 PM

Can you give some more detail on "does not work". ? What you wrote should not be off by a factor of ten.

 

 

On the inexact and rounding thing, that usually takes place about six decimal digits out.

 

People are used to base ten. So we are fine with 0.1 or 0.2 or 0.9321 and similar. That 0.9321 is represented as 9/10 + 3/100 + 2/1000 + 1/10000.  

 

But in base ten we get really messed up when trying to represent a fraction like 2/3. We write 0.666666, repeating forever because we cannot exactly represent it. No matter how hard we try in base ten, it will always be an inexact representation of 2/3. 

 

The same thing applies in other number bases.

 

Computers are base two. They do fractions as 1/2, 1/4, 1/8, 1/16, 1/32, 1/64. They are combined the same way we add 1/10, 1/100, 1/1000, 1/10000.

 

Trying to represent 0.6 will never work out exactly in base two.  As a fractional binary is 0.1001 1001 1001 1001...  that is, 1/2 + 1/16 + 1/32 + 1/256 + 1/512 + 1/4096, which Google says is 0.59985351562.  It gets really close to 0.6, just like 0.66666 in base ten gets really close to 2/3. 

 

Whenever you work with floating point numbers, it is best to think of them as approximations. They are usually right within a small tolerance.  There are technical rules for figuring out the precision, but they're probably more than you want in this post.

 

 

 

 

Since they're approximations, and since only a limited number of bits fit in a value, any time you mix floating points that are different orders of magnitude, about six digits different, the math tends to break down quickly.  So if you've got very small values of acceleration combined with very large forces, the math can break down when the processor tries to convert them to the same scale for the operations.




#5251218 strange deadlock

Posted by on 08 September 2015 - 05:07 PM

Since this is message passing, there are many things that could go wrong. The biggest and most common are that messages can be lost and messages can be transmitted more than once.

 

The answers to both are to ensure they are idempotent and also allow for retry after a short time period.

 

Being idempotent means they can send the request over and over and over again without messing anything up.  An obvious example is on a storefront's 'buy' button.  If for some reason that page gets hit more than once you only want a single transaction to take place. This is often implemented by using unique transaction ID values, if the transaction has already been processed just re-acknowledge the event without billing.

 

In TCP and similar flow-control systems the source just keeps sending more and more data, up to the size of a window and assuming the data has all arrived for processing. The client periodically acknowledges that they received everything up to a certain spot so the host can drop all that and advance the window, or the client says it missed something and the server re-transmits that block and advances the sliding window up to the point that was missing. 

 

With that in mind, going over the original post again...

 


The client sends a publish packet, then the server must answer with a pubrec packet. After receiving the pubrec, the client answers with a pubrel packet and finally the server send a pubcomp packet. This will ensure the message is reliably received only once.
This is basically guaranteed to eventually fail.  There are always network problems of dropped packets and lost connections. 

 

Make sure you have no "only once" requirement. The data can arrive as many times as necessary and be requested over and over without ill effect.  The client can drop the connection, reconnect, and repeat earlier requests. The server needs to handle duplicate requests gracefully, generally this means re-transmitting without re-processing as described above.

 


Then it is passed to the work queue which is in charge to acknowledge all the publish-pubrec-pubrel-pubcomp chain. ... This ensures that only one message is inflight and that the order is preserved.

Machines crash. Sometimes data gets lost.  Better to allow individual blocks of work to remain on the server, and allow for them to expire on clients. If the client takes to long or loses connection for any reason, distribute the work out to another client. 

 

If there is any possible way to arrange it for the data, make sure that individual blocks can be processed independently of each other. Then you can queue up a large amount of work, farm it out to any number of machines, and re-assemble it as it returns.  If something arrives back early, hold on to it to reassemble the parts in the right order.  If something doesn't return in a timely manner, farm it out to another machine to be processed again.  Don't force ordering on distributed processes, it slows things down.

 


So it happens that when the client and the server send a publish packet at almost the same time, they both have the publish at their heads. And both wait for the pubrec packet to arrive, but none of them can send a pubrec becuase the publish is still on the head waiting for the pubrec which can't be sent
That isn't a client/server. That is two machines both acting as clients and as servers.

 

As above, it can be avoided by not requiring any system wait. If another machine says they've got something for you, acknowledge the delivery, validate it, and then release them to do whatever else they want to do. It shouldn't matter if they gave you a duplicate of something they already sent, or sent you something out of order, or something you weren't expecting, just say "thank you" to the connection and allow them to advance to the next block of work.




#5251192 Video of the game and copyrights.

Posted by on 08 September 2015 - 01:50 PM

There are many IP rights beyond copyright.

 

Both the words "Yoda" and "Jedi" are trademarks of Lucasfilm. 

 

Visual designs of the Yoda character are owned by Lucasfilm and Disney.

 

Unless the "picture of Yoda" is one you drew, the copyright of the image belongs to someone else, probably Lucasfilm.

 

 

 

If the app store catches your unauthorized use, you will likely have your application blocked. They have options to do more, but they probably won't.

 

Lucas was fairly generous in allowing fan-made stories, not so much in fan-made games.

 

Disney will likely send their attack lawyers after you as soon as they discover it.




#5251080 i need someone help me in eclipse

Posted by on 07 September 2015 - 07:13 PM

Sorry, looks too much like homework.

Java collections support the functions built in.

For guidance, nearly every data structures and basic algorithms book has these problems in assignments, read the books to find the logic.

From the FAQ: Do not ask homework related questions, they will be closed on sight.


#5250890 Can one access one class field, by another class field?

Posted by on 06 September 2015 - 02:43 PM

Alvaro's suggestion, using pointer math to get to sequential items, is unsafe and not guaranteed to work in all cases, but in practice works practically everywhere.  The three items are in order sequentially, so getting the address of the first item then using pointer math to advance to the other items will work.

 


I forgot to add that it shouldn't add any memory overhead like it is with using references. I am just curious - no special need for it. I am still learning C++.

There are non-portable ways to do what you describe, to access members inside another structure.  They rely on a knowledge of the compiler and hardware so that you know the system will put the data in the correct place and in the correct format. 

 

A union is one method of doing it.  Be aware that the language standard specifically warns the code is not portable and can break across machines.

union MyUnion {
    sometype a;
    othertype b;
    thattype c;
};

The three values, a, b, and c, all occupy the same block of memory. There are several rules about using them, and it is not something you should be doing as a beginner.

 

One of the more common versions of this was networking internet address structure.  It was a union of a 32-bit value for one type, and a structure with four 8-bit values for the second type.  That way you could address it as a 32-bit single value, or as four 8-bit values like aa.bb.cc.dd that most people are familiar with.

 

Since the exact layout of values is different on machines, the four values needed to be mapped on a compiler-specific and machine-specific basis.  The three major forms are for some systems a.b.c.d, sometimes d.c.b.a, sometimes b.a.d.c. 

 

 

There are a few other methods of doing it, mostly using raw memory addresses rather than named objects. All of them are inherently unsafe across machines and require specific knowledge of the compiler and architecture you are working on.




#5250717 Demonstrating a strategy game in a convention

Posted by on 05 September 2015 - 01:17 PM

You need to start by building an 'elevator speech'.

If someone asks about the game, have a single sentence summary of what makes it amazing. Then have a single 30-second statement if they want more. Memorize both. It needs to be short enough that you could tell a stranger while standing in an elevator.

Since you know you cannot show them everything, figure out an interesting gameplay location and have a save game at that location. Restart from that save game and allow the people at the booth to see the interesting thing at that location. Allow them to do more if they want, but have some ability to jump immediately to an awesome something.


#5250648 [SFML] [C++] vector subscript out of range

Posted by on 04 September 2015 - 09:42 PM

On your specific error, probably you are expecting to iterate over enemy.enemyArray for the inner loop rather than projArray.

If that was a typo in your post but different in your actual code, stop that in the debugger when the error occurs and look at the values of collideCounter and collideCounter2. You should find that one of them exceeds the length of the array they are being used on, either projArray or enemyArray.


As for the general condition, I sure hope you have a small number of items in those arrays. That kind of all-to-all comparison results in dangerously fast computational growth. Most systems build spatial trees and only compare the immediate neighbors.


#5250645 GameState is a bad method nowadays ?

Posted by on 04 September 2015 - 09:33 PM

State machines, including nested state machines, are an incredibly powerful tool both inside computer science generally and inside games specifically.

While you can use scenes to implement some of those things, and tools like Unity do this, there is also nothing inherently wrong with using state machines to track and flow through the system. It is not "a bad method". It is one method of many.

State machines are the correct tool to use when you flow through states. That is what they are for, that is what they do. If that is what you need part of your game to do, then it is the right tool for the job. When you need to flow from state to state to state, using transition rules along the way, you use a state machine.

For the example of having multiple pieces open at once, that is composition rather than state. Each component is engaged in states. The console is using states to indicate its drawing mode and display status. The option windows are a hierarchy defined by state and state machines. The title screen and menus are a state machine defined by state and state machines. Most of the AI in TF2 is powered by state machines. Most game objects and spawners and other parts are run by state machines.

You don't need to use state machines for everything, and there may be other tools available for various tasks, but still embrace the fact that state machines are found practically everywhere in computer programming, including concepts like the lowly switch statement and if/else trees.


#5250613 How will a dedicated server help this game?

Posted by on 04 September 2015 - 03:14 PM


Would a dedicated server improve this game? Or add more latency?

Depends on details.

 

 

A dedicated server usually means a star architecture where everyone has a direct connection to the server. P2P usually means a fully connected mesh where everyone needs to send out many messages to many people. Both have benefits and drawbacks.

 

P2P means more problems with communications meshes, especially when nodes are locked behind nasty firewalls with little to no NAT traversal. Supporting a partial mesh for P2P can add significant complexity, and adding repeaters for hard-to-reach P2P nodes means basically paying for dedicated machines anyway. Using a host machine in a P2P system means finding the best-connected machines and adding traversal steps to anyone that cannot directly reach the server, which can be a tricky networking problem. Star where the server is publicly addressable means all those problems vanish, since clients typically can reach the public internet.

 

P2P causes tricky situations when a game host or controller or best connected player drops out, or when connection performance changes. Host migration and mesh renegotiation take thoughtful design. Star has less issue with that since everyone has a single connection to the server that runs the match.

 

P2P means higher traffic load on individual machines as they must handle more messages, but the individual players pay the costs; Star means less traffic burden on individual clients but a much heavier burden on the server, meaning the studio or person hosting the server pays a higher cost.

 

Trust issues can be reduced with star on game servers you control. Star means clients trust the server and the server only trusts what it validates. P2P means trust noone without consensus, and consensus can be slow. 

 

Star servers can have both less and more latency.  An individual's latency to the server can be quite low, you know your time to the server is x ms. In P2P a peer's latency to multiple peers can be more erratic and varied, one is x ms, another is y ms, another is z ms. Getting enough data to form consensus can take much longer or be much shorter depending on the physical networking details and locations on the globe.

 

There are many other tradeoffs between star and P2P architectures, those are just the ones that immediately jump to mind.

 

 

 

If you're looking for simplicity, usually a dedicated server you own is the least headaches for developers and for customers. Development is faster and cheaper, the troubling networking conditions are much reduced, but long-term running costs are much higher as the server requirements and bandwidth requirements are much increased.




#5250594 Most efficient way of designing a vector class in 3D

Posted by on 04 September 2015 - 10:51 AM


Hmm? I don't think this is true. Or am I misunderstanding? I recently SIMD-ified an inner loop in one of my projects and compared the assembly before and after. I was using a home-grown xywz vector4 and Visual Studio 2015 properly used the *PS instructions.

Automatic vectorization sometimes works, sometimes doesn't.  If the compiler happens to recognize a specific pattern it might do it in parallel.

 

The problem is that the result isn't guaranteed.  It is an optimization that sometimes the compiler does, but it could easily stop doing due to a minor change in the code, or an update to the compiler and build tools.

 

And there are many cases where the code could be easily made SIMD where the compiler doesn't recognize it. The programmer could take some few simple actions and vectorize loops with little work.

 

If you want to actually rely on SIMD, you need to explicitly code for it.  




#5250486 Best comment ever

Posted by on 03 September 2015 - 04:57 PM

 


typedef void (*VFunc)(void *);  /* Pointer to function with argument (void *), returning void. */

Considering how weird pointer-to-function syntax is in C, I'd almost say that comment was necessary.

 

 

Agreed that the comment was a good idea. They get especially nasty when they are functions that request a function back.  So you get a function that returns a pointer to a function with an argument that returns whatever.

 

I've seen joke code, but never in real life, where that is nested more that once.  So a function that returns a function that returns a function, etc., repeated to absurdity.




#5250485 How to implement DLC

Posted by on 03 September 2015 - 04:50 PM

Since you tagged Unity, I assume you're wanting to build something in there even though you didn't mention it in your post.

 

Unity has a feature it calls an AssetBundle

 

The details can be found in the link, but basically you write your initial program so that it can load the asset bundle. 

 

On your own you will need to create some descriptive file or process that has a list of what is in the bundle and how to use it.   Then you need to dynamically load all the content and scripts into your game.  Once loaded, they are regular GameObject or Texture2D whatever you stored in them.

 

The exact details are going to depend on your project.  You might build an asset bundle of a bunch of high resolution textures and a list of which models they go with. Or you might build an asset bundle with some new game objects, and a list of places in your game they should be spawned at. You might add them to an AssetDatabase that your code searches for lists of assets.  

 

Exactly how you pull them out is something you need to plan for in your design. Also, since people have done it before, DLC is something you need to plan and experiment with BEFORE launching the initial project. You cannot really back-fit DLC into a shipped application. Most games with DLC have several DLC packages at launch as these were the packages used to test and validate that the DLC system is working properly.




#5250481 Should fanfic games be legal?

Posted by on 03 September 2015 - 04:14 PM


It'd be hard to draw a line there. You'd have to determine what part of the IP you are referring to. That's why I was saying sequels and spin-offs would have to wait until the franchise copyright expires, rather than the individual work expires.

This is where it starts to get really complicated.

 

The safest answer would be that you need to wait until both the copyright has expired AND the trademarks on all the characters, logos, and other distinctive elements have become dead and ceased use in commerce.

 

It is not enough for the trademarks to die due to lack of use, since copyright will persist until you are dead.  Even if your descendants want to use the material after copyright expires, trademark protections exist as long as it remains used in commerce.

 

 

 

Let's do a little thought experiment with that.

 

There are a few people who argue that the original Steamboat Willie, Plane Crazy, and Gallopin Gaucho cartoons expired because of their first screen audience release dates and published copyright information. Let's use that rather than Super Mario Bros for the first part of this thought experiment.

 

If these were in public domain today, you could make copies of the original works.  The first step would be to track down one of the 1928 films. You couldn't use any of the many re-releases because they touched them up, cleaned the audio, repainted some bad frames, and those later re-releases are not public domain.

 

Next, you would only be allowed to use the 1928 version of mickey mouse. He looked very much like a mouse, radically different from today's mickey mouse.  You could derive from the black and white Mickey rodent wearing overalls, the Minnie rodent wearing a skirt, Pete the cat, and Oswald the rabbit. All of them would be the 1928 versions, not the 2015 versions.

 

You could not use any of the trademarked terms or trademarked logos since trademarks persist as long as the thing is used in commerce. Even though the 1928 film would be useable as a copy, you could not create your own Mickey Mouse line of products due to trademark rules. Similarly Minnie and Pete are both names covered by trademark.

 

So now bringing it back to Mario.

 

Wikipedia tells me Mario first appeared in 1981 in Donkey Kong (then called "Jumpman"), Luigi in 1983 in Mario Bros. Assuming no other changes, that version of Donkey Kong will enter public domain in 2077, and that version of Mario Bros will enter public domain in 2079.

 

So fast forwarding to 2079...

 

For convenience, assume all the characters in the franchise are still in active use, trademarked, and no other changes to law have happened.

 

You could make and distribute copies of the original Donkey Kong published in 1981, and the original Mario Bros published in 1983.  It was made for arcade machines, and by 1983 had been ported to a few systems. 

 

You could make derivative works using those characters and those old stories, but not making use of whatever advancements have happened between 1984-2079, those are still protected.  

 

You get the original blue/red/orange Jumpman/Mario, the white faced (remember Japanese beauty) red-head pink dress "the Lady" (later named Pauline), the two-tone blocky Donkey Kong, and the blue/orange/green Luigi, as they appeared in 1981 and 1983, not as they would be depicted in 2079. 

 

You don't get any story developed between 1984-2079. They were brothers as established in 1983, but any story revelations or changes made after 1983 would be off limits until they enter public domain.

 

You could not use Princess Peach or Daisy or any other modern characters, because they had not been introduced before the 1983 cutoff date you have in 2079.

 

Assuming the names are trademarked and used in commerce in 2079, you could use the names in a direct clone because that is from copyright, but could not make your own product with the same names or iconography covered by trademark in 2079.

 

 

 

 

So if you're alive in 2079, and you still have some really old arcade boxes or Atari 2600s or whatever else they were ported to, or someone manufactures those devices in 2079, then you can make all the copies you want since copyright will have expired.  Your rights to make clones and similar products may be somewhat by trademark and other IP laws, but direct copies could be enjoyed by anybody.  






PARTNERS