Author Topic: Can Glest support there players: one human, one cpu, one network?  (Read 2335 times)

loveheaven

  • Guest
Can Glest support such there players like this way: one human, one cpu, one network at the same time?
Why don't AI commands call the function pushNetworkCommand? How will the clients sync with the server to know what AI are doing if AI commands don't call the function pushNetworkCommand?

Belowing is the current code:

void Ai::returnBase(int unitIndex){
    Vec2i pos;
    CommandResult r;
    int fi;

    fi= aiInterface->getFactionIndex();
    pos= Vec2i(
      random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) +
      getRandomHomePosition();
    r= aiInterface->giveCommand(unitIndex, ccMove, pos); // why don't call the function pushNetworkCommand?
    //aiInterface->printLog(1, "Order return to base pos:" + intToStr(pos.x)+", "+intToStr(pos.y)+": "+rrToStr(r)+"\n");
}

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Can Glest support there players: one human, one cpu, one network?
« Reply #1 on: 11 January 2009, 19:35:09 »
Server and client are playing the same game, so the ai on server and client behaves the same way.
If server and client are in sync, there is no need to publish AI commands, because they are generated by client for itself!
And the decisions on every client will be the same.
« Last Edit: 11 January 2009, 19:51:03 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

loveheaven

  • Guest
Re: Can Glest support there players: one human, one cpu, one network?
« Reply #2 on: 11 January 2009, 20:37:54 »
Server and client are playing the same game, so the ai on server and client behaves the same way.
If server and client are in sync, there is no need to publish AI commands, because they are generated by client for itself!
And the decisions on every client will be the same.
oh! yes, it is. you are right! Thank you very much. I know it!
I saw the thing megapack_v3 you made. It's wonderful. Would you please post an example to tell us how to use blender to make a 3d model?

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Can Glest support there players: one human, one cpu, one network?
« Reply #3 on: 12 January 2009, 10:23:06 »
Blender is not so easy to learn.
Look here:
https://forum.megaglest.org/index.php?topic=4074.0
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

loveheaven

  • Guest
Re: Can Glest support there players: one human, one cpu, one network?
« Reply #4 on: 12 January 2009, 13:14:40 »
Thank you very much! You are very nice.

daniel.santos

  • Guest
Re: Can Glest support there players: one human, one cpu, one network?
« Reply #5 on: 12 January 2009, 20:33:27 »
loveheaven, have a look at the class Shared::Util::Random.  This is a psudo-random number generator that creates the same set of random numbers each time, when seeded with the same value.  This is the mechanism that Glest uses to try to keep client & server AI (as well as other randomness) in sync.  There are flaws with the approach, but they apparently don't surface much on low latency networks and when both machines are able to run at 40 world updates per second.  But once something gets out of sync in one place, it can potentially trigger a chain reaction of synchronization issues -- something I attempt to address in GAE, but as I mentioned in another thread, GAE has yet to accomplish stable network play.

 

anything