Featured games (78)
games approved by the League of Dukes
Games in Showcase (427)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / General Discussions / Re: Simple JNI task on: 2004-01-29 15:42:34
stdin and stdout can be read from and written to using and System.out so I wouldn't bother trying to do this in native code.

The executable file will be called from an external program, that will communicate with it through stdin/out, so I haven't the option to use System.out/in! To be specific, I'm going to write a UCI (universal chess interface) for my chess engine.

To write to stdout in C++ one uses "cout >> ..." isn't it? To read from it "cin", but when do I know when new data is available? How to convert to a Java string?

For a C++/JNI expert this should be piece of cake to answer. Please post some code. Thanks!

2  Discussions / General Discussions / Simple JNI task on: 2004-01-28 01:40:25
Hi there,

I have to write a native executable, that first starts my java program and then continously transfers it all input recived from stdin and writes output from the Java program to stdout. Can anyone please show me how to do this (platform-independently) with VisualC++ or gcc?

Ideally there would be two methods in the Java code, one for writing a String and one to accept a String. I'm a complete Newbie in C/C++ and JNI. Are there any pitfalls?

Thanks a lot!
3  Game Development / Performance Tuning / Re: Array access pretty slow on: 2004-01-20 23:36:32
Oh, that was a lighning fast reply Shocked

No, unfortunately i can't (or at least it would be very messy) implement the stack with recursion.

Another question: generally what is faster, 2 accesses to arrays with length 64 or 1 access to an array with 4096 length? I suppose this depends on CPU caching... so it's platform dependant... a rule of thumb?

Have a nice day!
4  Game Development / Performance Tuning / Array access pretty slow on: 2004-01-20 22:45:31
Lastly I tried an optimization in a frequently executed piece of code: 3 variables of small size needed to be saved in a sort of "stack array" of fixed size. In the first version each variable was stored and retrieved from an individual array.

After packing all info into one single array with shifting and oring (saving two array acceses), the code was significantly faster! Obviously array access is much more expensive than a few bit-ops...

But how expensive is it really? I would guess it takes at least two condition checks for the bounds and one multiplication to calculate the address. Does anyone know exactly?

5  Game Development / Performance Tuning / Re: Find out how many CPUs a system has on: 2004-01-10 14:48:39
Thanks, that will be optimal. Strange they added this functionality so late...

An other question comes to my mind. What about this new hyperthreading technology of intels P4 (I read of a 25% performance increase): will a multithreaded java application benefit from it? If that's true, I should use the parallel algorithm with two threads even on a single processor system, hmm... how to detect a hyperthreading processor?
6  Game Development / Performance Tuning / Find out how many CPUs a system has on: 2004-01-10 05:27:33
In my application I need to find out how many processors the host system has, in order to start an appropriate numer of threads (in my case numberOfThreads = numberOfCPUs). Is there a standard means of achieving this in Java? If not, can anyone please give me a hint how to do this platform-independantly with JNI... (I never used native code, so please explain this in a fool-proof manner) Thanks a lot!
7  Game Development / Performance Tuning / Unreachable code removal on: 2004-01-08 02:59:36
When a block of code is unreachable at compile time, will the compiler remove it? Example:

final boolean DO_THAT = false;

if (DO_THAT) {
 // code...

In my application I'm specially interested in the removal of the condition check, since the condition will always be true or false at compile time.
8  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-11 23:31:18
Thanks a lot for your help. So basically bitIndex2() seems to be the right thing to do - just not in the fastest variant. Originally I hoped that maybe someone would come up with a better algorithm, maybe exploiting some obscure bit fumbling.

Because my work is in the early stages I'll consider switching to C/C++ and later optimize with assembly. Could be quite fun and challenging - maybe I'll toast my CPU  Roll Eyes I wonder how a C++ and then an asm version would compare in terms of cycles.

Can it be true, that Sun 1.2 is faster than the successor VMs? Strange...

Merry Christmas & Happy new Year
9  Game Development / Performance Tuning / Finding index of single 1 bit in a long on: 2003-12-09 15:14:56
Hi everybody. I'm working on a chess program which makes frequent calls to a method, that finds the position of the first (and only) set bit in a long value. So for 1->0, 2->1, 4->2, 8->3, 16->4, ...

The straight-foward code is this:

 public static int bitIndex1(long x) {
   int r = 0;
   while ((x & (1L << r)) == 0)
   return r;

The enhanced version takes less time in the average case:

 public static int bitIndex2(long x) {
   int r = 0;
   if ((x & 0xFFFFFFFF00000000L) != 0) r += 32;
   if ((x & 0xFFFF0000FFFF0000L) != 0) r += 16;
   if ((x & 0xFF00FF00FF00FF00L) != 0) r += 8;
   if ((x & 0xF0F0F0F0F0F0F0F0L) != 0) r += 4;
   if ((x & 0xCCCCCCCCCCCCCCCCL) != 0) r += 2;
   if ((x & 0xAAAAAAAAAAAAAAAAL) != 0) r++;
   return r;

Is it possible to do this even faster? On x86 there is a single assembly instruction which does this kind of stuff Sad
Pages: [1]

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (78 views)
2014-04-15 18:08:23

BurntPizza (69 views)
2014-04-15 03:46:01

UprightPath (81 views)
2014-04-14 17:39:50

UprightPath (66 views)
2014-04-14 17:35:47

Porlus (82 views)
2014-04-14 15:48:38

tom_mai78101 (106 views)
2014-04-10 04:04:31

BurntPizza (166 views)
2014-04-08 23:06:04

tom_mai78101 (262 views)
2014-04-05 13:34:39

trollwarrior1 (212 views)
2014-04-04 12:06:45

CJLetsGame (221 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!