Jump to content

  • Log In with Google      Sign In   
  • Create Account

Paradigm Shifter

Member Since 09 Aug 2002
Offline Last Active Yesterday, 05:52 AM

Posts I've Made

In Topic: How Do I Implement An OffSide in Simple Soccer

15 April 2014 - 11:44 AM

Do you understand the offside rule? If you are in the opponents half when a forward pass by your own team is made, and you are nearer the goal than all but one defender (usually the goalie, but this is not a requirement) then you are offside. Let's ignore the "interfering with play" rule ;)

The important thing is you can only be offside when the pass is made, and you must be ahead of the ball (I.e. it is a forward pass)

In Topic: flush savegame to disk

04 March 2014 - 03:59 PM

In Windows have a look at this...





In these situations, caching can be turned off. This is done at the time the file is opened by passing FILE_FLAG_NO_BUFFERING as a value for the dwFlagsAndAttributes parameter of CreateFile. When caching is disabled, all read and write operations directly access the physical disk. However, the file metadata may still be cached. To flush the metadata to disk, use the FlushFileBuffers function.


Some applications, such as virus-checking software, require that their write operations be flushed to disk immediately; Windows provides this ability through write-through caching. A process enables write-through caching for a specific I/O operation by passing the FILE_FLAG_WRITE_THROUGH flag into its call to CreateFile. With write-through caching enabled, data is still written into the cache, but the cache manager writes the data immediately to disk rather than incurring a delay by using the lazy writer. A process can also force a flush of a file it has opened by calling the FlushFileBuffers function.


But I don't know how that affects performance and whether it always works.


EDIT: If it is Windows only, you are probably better using the native file IO functions (CreateFile, WriteFile, etc.) than the C lib ones (fopen, fwrite, etc.) anyway. If you need to go cross-platform I'd look and see if there is a boost library that does what you want.

In Topic: Logic (That's what programming is centered around right?)

01 March 2014 - 06:30 PM

If you really want



You must try though

In Topic: running code on a better computer online

01 March 2014 - 04:27 AM

Here, i tried clearing up your code a bit, at least the insane for loops smile.png

				boli[con] = dutu[(con+cen)*2] == dutu[con*2];			

					if(con == lo2-cin){
						conti = boli[con];
						valu = dutu[con*2] + 32768;
					} else if(boli[con]){
						conti = dutu[(con+cin+cen)*2] == dutu[con*2];
						mani += conti;




EDIT: You can speed that up by getting rid of 2nd while(1) loop... since the first one will never exit ;)


OP: I'd like to see the algorithm too. It looks like you are doing it wrong, whatever it is you are trying to do.

In Topic: running code on a better computer online

01 March 2014 - 03:41 AM

Well you keep writing out 2 bytes at a time. Allocate all the memory you need, fill it, then write it to disk in one go.