It is currently Wed Jun 19, 2013 3:25 am Advanced search

Game engine in C++

Code won't compile? Found a bug? Post here!

Re: Game engine in C++

Postby theli_ua » Thu Sep 16, 2010 10:17 am

albert wrote:Uh, it gives different results? Can you post/attach two game replays which differ, one with Java and one with the C++ engine?

If it differs because of a timeout of one of the bots, that can be kind of random.

just checked out latest java playgame , still different results
Attachments
logs.zip
(50.36 KiB) Downloaded 62 times
theli_ua
Lieutenant
 
Posts: 14
Joined: Tue Sep 14, 2010 7:45 am

Re: Game engine in C++

Postby albert » Thu Sep 16, 2010 10:41 am

Am I correct that you compare "X turns of simulation on Java engine" vs "simple run of your C++ engine, without any bots" ???


Of course not. Reread my post. I used the C++ starter pack bot for that test.

Btw., as I also said, the bots are anyway the biggest bottleneck (at least when you use the C++ engine). That is why my other benchmark has a smaller difference.

@theli_ua: Could you post the replays instead? It's kind of hard to compare those logs by hand (and tools like diff are useless here).
albert
Lieutenant-Colonel
 
Posts: 44
Joined: Sun Sep 12, 2010 9:11 pm

Re: Game engine in C++

Postby theli_ua » Thu Sep 16, 2010 1:03 pm

albert wrote:@theli_ua: Could you post the replays instead? It's kind of hard to compare those logs by hand (and tools like diff are useless here).

sure

thats the same 2 bots, the same map (map 30) , in both player 1 wins, however its 59 turns with cpp engine and 189 with java one
Attachments
replays.zip
(22.34 KiB) Downloaded 62 times
theli_ua
Lieutenant
 
Posts: 14
Joined: Tue Sep 14, 2010 7:45 am

Re: Game engine in C++

Postby albert » Thu Sep 16, 2010 1:36 pm

@theli_ua: Have you watched the replay? Already in the very first turn, the bots are behaving different.

In the C++ replay, the first player sends 21 ships to the left bottom corner. In the Java replay, it sends it to the right upper corner. The second player behaves the same for the first turn - it also sends to the right upper corner, to the same planet as player 1. So it make sense that the Java match takes longer.
albert
Lieutenant-Colonel
 
Posts: 44
Joined: Sun Sep 12, 2010 9:11 pm

Re: Game engine in C++

Postby igner » Thu Sep 16, 2010 5:02 pm

albert wrote:Of course not. Reread my post. I used the C++ starter pack bot for that test.
Btw., as I also said, the bots are anyway the biggest bottleneck (at least when you use the C++ engine). That is why my other benchmark has a smaller difference.

I read it carefully, more than one time :)
I just cant imagine how Java engine could be 30 times (!!!) slower than C++ one:
albert wrote:So, 10 secs vs 0.3 secs

And my benchmarks had only one purpose - to find out how that could be possible (especially in compare to my results)
igner
Lieutenant
 
Posts: 10
Joined: Sun Sep 12, 2010 10:54 am

Re: Game engine in C++

Postby theli_ua » Thu Sep 16, 2010 5:13 pm

albert wrote:@theli_ua: Have you watched the replay? Already in the very first turn, the bots are behaving different.

In the C++ replay, the first player sends 21 ships to the left bottom corner. In the Java replay, it sends it to the right upper corner. The second player behaves the same for the first turn - it also sends to the right upper corner, to the same planet as player 1. So it make sense that the Java match takes longer.

yes, but i have no idea why it behaves differently....
and the results are reproducable every time i play that match
theli_ua
Lieutenant
 
Posts: 14
Joined: Tue Sep 14, 2010 7:45 am

Re: Game engine in C++

Postby igner » Thu Sep 16, 2010 5:13 pm

delt0r wrote:I don't want to descend into a flame war (nothing wrong with C++ or any other lang for that matter).

totally agree with you :)
delt0r wrote:Generally C++ and java have similar performance with similar levels of code quality (baring jvm warm up time).

Main purpose for me was using single compiler and IDE for my bot and engine (to adjust different things in engine). I've made benchmarks only when albert stated that on C++ engine it take 0.3 sec while on Java more than 10 seconds.
delt0r wrote:Also just a quick note. The worse part of the default bots etc in the original java is reading 1 char at a time and appending it to a string from all input streams. This is many many times slower than using a readline method. Just fix that and most of the performance difference will go away.

I believe that was the first thing any developer fixed in bot :) There is one more major performance eater - output to console turns and round results. So i turned it off when do not use viewer :)
igner
Lieutenant
 
Posts: 10
Joined: Sun Sep 12, 2010 10:54 am

Re: Game engine in C++

Postby albert » Thu Sep 16, 2010 6:06 pm

@igner: Yea, it really was like that. :) Try yourself. The C++ starterpack bot is really fast. I am not exactly sure what your "echo C++ bot" does. To reproduce my sample: Use the C++ starterpack bot and play it on map1.txt. It should end exactly with 579 turns and player 2 should win.

Btw., both the engine and the viewer still read one char at a time in my C++ implementation. I was too lazy to make that more complicated. And it still seems fast enough. I am also not sure if that makes really such a huge difference in C++. (std::string does not need to reallocate all the time because it grows exponential or something like this, depending on the STL implementation).

theli_ua wrote:yes, but i have no idea why it behaves differently....
and the results are reproducable every time i play that match


Good question. You should maybe add some debugging message to your bot why it makes that decision to see why your bot behaves different.
albert
Lieutenant-Colonel
 
Posts: 44
Joined: Sun Sep 12, 2010 9:11 pm

Re: Game engine in C++

Postby igner » Thu Sep 16, 2010 6:18 pm

albert wrote:I am not exactly sure what your "echo C++ bot" does.

Code: Select all
// EchoBot.cpp : simplest echo bot for engine load testing

#include <string>
#include <iostream>

int main(int argc, char *argv[]) {
   std::string sCommand;
   while(1) {
      getline(std::cin, sCommand);
      if(sCommand == "go") {
         std::cout << "go\n";
      }
   }
   return 0;
}

It's hard to image faster bot :) Okay, i'll try to reproduce your scenario
igner
Lieutenant
 
Posts: 10
Joined: Sun Sep 12, 2010 10:54 am

Re: Game engine in C++

Postby albert » Thu Sep 16, 2010 6:23 pm

Your echo bot doesn't flush after the output (or maybe just use endl). Maybe that makes it lagging.
albert
Lieutenant-Colonel
 
Posts: 44
Joined: Sun Sep 12, 2010 9:11 pm

PreviousNext

Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron