Jump to content

  • Log In with Google      Sign In   
  • Create Account


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

#5092777 Copyright "crowdinfringement"

Posted by frob on 09 September 2013 - 12:54 PM

I'm not sure how your Torrent analogy applies. One is about creating a character, the other is about distribution.



For creating characters, do you mean something like City of Heroes?


In CoH you could make your own superheros based on a bunch of factors. The developer intentionally blocked many well-known superhero characters and names (eg. Wolverine) but Marvel sued them for trademark infringement. It was an interesting case, especially since Marvel created some of the violating characters and then sued over them. The judge dismissed most of the charges, and sadly the remaining ones were settled under undisclosed terms. 


Another game with massive player-created content was Spore. People would generate fairly graphic and obscene things, dubbed "Sporn". The game developers were smart enough to see this one in advance and kept group of people to review the player-uploaded content. Even so, a lot of rather offensive Sporn made it through to public servers and the company had a constant battle to keep it in check.



The takeaway:  When dealing with publicly visible player-made content you absolutely need some good business lawyers involved. Plural.  You need to be prepared not only for those who violate IP rights, but also those who will do everything in their power to generate offensive and sexually explicit content.


Player-generated content can be fun, but it is also an expensive nightmare from a legal standpoint.

#5092772 Finding Game Jobs

Posted by frob on 09 September 2013 - 12:23 PM

Be prepared to work for free until your work is proven,  Usually don't get paid until job is done and working effectively
Bad advice.


Unpaid jobs are probably unlawful due to minimum wage concerns. In the US there are six requirements that must be met for it to be legal to be an unpaid position.  Unpaid interns are only legal in rare situations where the intern is more of an observer or when the intern produces unusable content generally at a cost to the company. Software development would not qualify on 4/6 of the requirements. Specifically it is not a training environment but instead is a workplace environment, results are used to benefit of the company, the person potentially fills the slot of a regular employees rather than a non-displacing task of observing them, and employer derives direct advantage from the activities. Most states are cracking down on violations of the Fair Labor Standards Act, and if you see a company violating it, report it.


If you are working on a contract basis you should be collecting money at every milestone. One of those paid milestones should be the signing of the contract, before any production work is complete. 

#5092409 Model–view–controller pattern

Posted by frob on 07 September 2013 - 11:05 PM

Actually it is frequently used in games.

One ubiquitous example is online games where processing is done on the server. The authoritative model is kept on the server. The view is shown on the client machine, and many different views can exist. The controller transmits clicks into events that get fed back to the model.

It applies for the whole gambit of online games. Everything from Words With Friends to WoW follow the MVC idioms.

Many large games follow the pattern. Although you don't need to follow it, it absolutely simplifies things. You have a game simulator that does the work. You have a decoupled rendering engine. And you have a decoupled user interface that generates events for processing.

#5092300 CS Degree - Is it worth it?

Posted by frob on 07 September 2013 - 09:56 AM

Being "worth it" is also a bit subjective.

Where do you live? Some regions of the world don't really care about education. Other regions of the world will require a BS degree in Computer Science just as a simple test to prune the number of applicants coming from HR.

What is the cost of the degree? Some schools are cheap, others are very expensive. I have relatives in schools that cost just over $1000 USD per semester. Sometimes on the board we discuss people who entered schools costing $10,000 USD per semester or more. I do not believe the quality of education between the schools is a 10x difference. Shopping around is important.

What is taught? Just like the cost varies, the content also varies. Some schools focus on rigorous theory with little practical content. Some schools are little more than trade schools with just enough theory to get by. As you shop around you should consider both the cost and content.

A bachelors degree in Computer Science is the typical requirement in games programming. It is not absolutely required, but you do not exist in a vacuum. If you have a portfolio, but the other person as a portfolio and a degree, which one is more likely to be hired?

#5092232 Merge tools

Posted by frob on 07 September 2013 - 12:43 AM

While many systems come with merge tools of varying quality, my favorite is Araxis Merge.

It is a paid product but very much worth the money.

Also the diff of images and office documents are very nice, especially when working with game art.

#5092231 Need advice on TDD approach

Posted by frob on 07 September 2013 - 12:13 AM

After reading that a few times, it looks like you have a unit test for the buffers, and an acceptance test / integration test for the archiving system as a whole.

For the buffering system, I would think this kind of test would work for the problem you described:
public class BufferedOutputStreamShould {
  public void StoreMaxBytesWithoutFlushing() {...}
  public void StoreMaxPlusOneBytesWithFlushing_AndLeaveOneByteBuffered() {...}
  public void BeEmptyAfterAddingOneByteAndFlushing() {...}
These things could be testable by exposing the maximum number of bytes that can be buffered and the bytes still in the buffer. Neither requires great insights into the details, and you can modify the actual number of bytes later without changing the interface. Simple functions like GetBufferTotalSize() and GetBufferRemaining() should suffice, no need for friends.

This should address your concerns about it dumping the data before it is completely full, and verify that buffering is dumping the data when it becomes exactly full.

The archiving system as a whole can operate without regard to buffering. Here's the things I would expect in the integration tests:

public class ArchivingSystemShould  {
  public void GiveIdenticalFooAfterSaveLoad() {...}
  public void GiveIdenticalBarAfterSaveLoad() {...}
  public void HandleBatchOfFiftyLoadSave() {...}
Is that about it?

#5091986 Inline

Posted by frob on 05 September 2013 - 09:41 PM

Inline is required when the function is inside the header but not within the class declaration and the header is used in multiple compilation units. Without the inline keyword the function will be multiply defined and will not compile.


Also a static inline function is a special case that is not quite what you asked. That use of "static inline" has its own meaning and is significant when you see it used.




Beyond that, the inline keyword for non-static functions is just a hint.  It is a request that the compiler is free to ignore, asking to replace the body of the function into the code that calls it.


Over the decades that the inline keyword has been in use compilers have come a long way. The optimizers have become extremely good at detecting functions that should be made inline and automatically moving them inline. This is why for many compilers the inline keyword is unnecessary except for the one required case of functions in a header.


Other times the optimizer may detect that inlining a function marked inline would result in worse performance so they reject it.  Sometimes they may even include the function one time and reject the same function elsewhere based on contextual information.



There are compiler-specific ways to tell the compiler that you know better than it and it should inline the function even when it normally wouldn't want to. Those are __forceinline and __declspec(noinline) on the MSVC and related compilers, or __attribute__((always_inline)) and __attribute__((noinline)), or compiler-specific codes for different compiler familes.  Usually it is a bad idea to override the compiler unless you have actual profiling data that proves the result.  


On modern systems unless you have actual values from profilers, map files, and disassembly which demonstrates a function should or should not be inlined, it is best to let the optimizer figure it out for you.

#5091914 How to cache?

Posted by frob on 05 September 2013 - 04:27 PM

And, is accessing memory to read from by multiple threads all performance safe?
Thread safety for memory is accomplished through memory barriers. 


It is one of many issues involved in threaded programming. You must establish a memory barrier before modifying any shared variable. This can be accomplished with interlocked functions which have great performance, or through more complex locks which require additional CPU time.

#5091868 [SOLVED] Socket programming in C++

Posted by frob on 05 September 2013 - 02:02 PM

The Networking Forum FAQhas links to several good tutorials on the subject.

#5091865 how many threads for game loop

Posted by frob on 05 September 2013 - 01:53 PM

Hi all,
I saw java game used 2 threads. One thread for game loop (update, render) and one for handling input (keyboard, mouse). Game loop thread was manually created by programmer. The other cames from "Event Dispatcher Thread" of .JFrame.
On the other hand, I saw C++ game had just one thread (Example SDL or DirectX game progamming tutorials ). It is like this:
So, my question is "which one should I use?".
P/S: please explain why

As a beginner you have much to learn already. You are already learning about graphics, animation, audio, effects, user interfaces, event systems, resource management, and much more.
Threading can be a good thing in games, but it is a complex topic.  As I recently wrote elsewhere:
In the process you will also need to learn about proper use of synchronization and locks and mutexes and semaphores, reentrant code, threaded storage, processing granularity, purity/isolation of data, memory barriers, CPU caches and cache coherency, and other topics. You will need to learn about the bugs that come with threading including deadlocks and livelocks, resource starvation, race conditions, memory thrashing, convoying, write tearing, and much more. Threading has even spawned a mathematical notation called transactional object calculus to help model the complexity of threading. It is an interesting topic and very much worth learning, just be aware of the scope. 


Threading has many benefits in games. Threads can be used as a structural system to isolate processing to prevent bugs from collapsing your program. Threads can be used for extra eye candy.  Threads can be used to help schedule work. 


Multithreading should not be relied on for game-critical performance.  That is, don't write a program that absolutely relies on parallel algorithms because the resources may not be there on low-end machines or heavily loaded machines. Do so at your own peril.



Certainly you can add all that to your game if you want to, but beginners usually have a hard enough time with a single processing thread.


In your case somebody else is running a thread for input.  That is fine, we will assume they know what they are doing and have resolved all those issues mentioned above in their own code. You don't need to use their threads. Just make your design single threaded for now.


For some things that you think you want threads for, what you really want is asynchronous calls.  That means somebody else is doing all the hard work in threading. Somebody else who knew how to do it has already solved the problem.  Asynchronous disk reads and asynchronous network communication and asynchronous rendering. Learn to use asynchronous functions so you can take advantage of processing power without stalling your app.

#5091714 How to cache?

Posted by frob on 04 September 2013 - 11:47 PM

As HappyCoder mentioned, this is almost entirely automatic. The CPU is able to detect sequential access patterns. Even if you are pulling from two or four or more data streams, as long as you are traversing them sequentially the CPU can almost always detect it and prefetch your data.

A lot of experts have spent decades trying to get processors to automatically detect and prefetch your data. The processors do a wonderful job of it when you access your data sequentially.

That said, there are a few hardware-specific prefetch instructions available at a low level. Most programmers will never use them. They are generally used in extreme cases, and only when you have a fixed target of knowing exactly what processor you are using. Not "exact processor" as in, "I'm using an x86 chip", or "I'm using an i7 processor." They are only useful as a final level of optimization on an exact processor like "This will only run on the 4960X" or "This will only run on the ARM694E-S". Even then, they would only be used after nearly every other type of algorithmic and structural optimization has been exhausted. In games this typically means they are limited only to consoles with known chipsets.

#5091641 What does the dimensions of the cache size and numbers of the bus speed tell...

Posted by frob on 04 September 2013 - 03:12 PM

Thanks for that, updated the post. 

#5091404 Why are static variables bad?

Posted by frob on 03 September 2013 - 02:04 PM

So I remembered the topics against static variables I thought I should ask, why are static variables considered bad?

Static lifetime is hard to manage. Some static objects get initialized even before main() is called and in an order you cannot enforce. Static objects are not destroyed until long after main() has finished. 


Static variables introduce hidden dependencies between objects.


Static variables have unenforced ownership semantics. Who modifies the variable and when? 


Static variables can be a nightmare for automated testing. They introduce subtle (and not-so-subtle) behavior that can invalidate tests.

#5091394 What does the dimensions of the cache size and numbers of the bus speed tell...

Posted by frob on 03 September 2013 - 01:42 PM

Cache is high speed memory.


You want all your data to be as close to the processor as possible.  Here are some approximate numbers:


1 processor cycle = 0.3 nanoseconds.

L1 cache hit = 4 cycles (1.2 ns)

L2 cache hit = 10 cycles (3 ns)

L3 cache hit, line unshared = 40 cycles (12 ns)

L3 cache hit, line shared in another core = 65 cycles (20 ns)

L3 cache hit, line modified in another core = 75 cycles (22.5 ns)

Remote L3 cache hit = 100-300 cycles (30ns-90ns)

Local dram = 60ns

Remote dram = 100 ns

Swapped to disk = 10,000,000 ns



If your code needs some data and it is already in the processor there is no wait.

If your code needs some data and it is kept in L1 cache there is a very small wait.

If your code needs some data and it is kept in L2 cache there is a longer wait.

If your code needs some data and it was already modified in another processor your program can briefly stall.

If your code needs some data and it is all the way out in main memory it can take a relatively long time for your program to continue.

If your code needs some data and that data has been swapped out to virtual memory on disk, it can stall your program for what seems like an eternity.



When they talk about cache associativity they are referring to how the data is stored within the cache.  As a gross simplification, when you have a large number of cache bins you need to keep track of which bin contains which data. When you have 128KB of memory kept in 64-byte bins that is a lot of bins. On the one hand you want all your data in cache memory.  On the other hand you don't want to search every bin in order to find which bin actually holds your data. If you have a 16-way set associative cache it means you need to sort through 1/16th of the bins to find the data.

#5091363 slow speedup of cpu's ?

Posted by frob on 03 September 2013 - 11:13 AM

There was a good article about a decade ago, "The Free Lunch Is Over" that you should probably read.  


Moore's law, the observation that the number of transistors in an integrated circuit doubles about every two years, continues to hold true.


For 30 years or so that doubling was applied to a single processor.  Programmers got a "free lunch" because the processors running their code became faster.  You could design software that was more advanced than your hardware and be assured that by the time it launched the hardware would be able to handle it.


Starting about 15 years ago that "free lunch" began to end. Processor speed is still increasing but it is happening as a lateral change. Instead of having a single processor with improving performance, we have a growing number of processors with similar performance.


Parallel algorithms are harder to write, but can achieve both linear speedup and even superlinear speedup thanks to cache effects, accumulated memory, and other properties of parallel hardware. 


The improvements in performance are still there, we just need to work harder to get them.