Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ShawnSwander

so if I had 3 clients and my code to move an entity to a random place on the map (wandering) all 3 would generate 3 different places. If I code it so they all try and only the first one is used and the rest just mimic it... it might cause problems if a client sends a move before he recieves a move on the same entity causing a double move or a client with bad information. So it seems like a server side solution is needed for AI or at least a random number sent from the server and processed client side. This is probably the way I want to know if anyone has a better way.

More specifically I was thinking each entity arranges all possible moves into an array and from those options a number generated server side will indicate which option is sent.. The issue I see is if a client cheats and manipulates his map it will allow extra options that other clients don't have and therefore if he cheats and his information is updated first and he sends a packet confirming the move it will cause server side problems. Server side I can't use impact functions as far as I know unless someone knows how.

I look forward to some ideas here .... thanks.

1 decade ago by techtech

It might help if you told us what style of game you are discussing.

Is the game turn-based or can AI clients move whenever they feel like it?

Do the rules of the game allow all players to have perfect information about the state of the world/board or could one AI know information about the state of the game that another AI hasn't discovered yet?

Regarding cheating, the traditional solution to cheating is a client-server design where the server is authoritative meaning the server makes all important decisions, not the clients, and sometimes implies that only the server has complete information about the game.

For example, if two players with guns were separated by a wall and could not see each other, it would obviously be cheating if one client transmitted a message saying "my player shot the other player, killing him" and it would be flawed design if all the other clients believed the message. In a proper client-server design, the client could only transmit a message saying "my player shot his weapon in this direction". Then the server would calculate the trajectory of the bullet and determine if a wall or a player were hit. Then if a player were hit only at that time would the server broadcast a message saying that the other player died.

1 decade ago by ShawnSwander

Its real time but moves have a cool down timer before a new move can be made rather than constant movement. So turn based but you can reserve time and move later but moving will disable further moves for a set period of time.

1 decade ago by jswart

Maybe you could have a table in the server database, called moves:

table_moves:
  id  // id of the move
  player_id  // player id, unique for each player/entity in game
  move_to  // where to move the player/entity

then use jQuery in your game logic to 'grab' the moves data for that turn with ajax.
setupTurn: function() {
    $.ajax() {
        // ajax logic to return table_moves
        // each row in the table puts moves for players in a 'queue'
    }
}

Having not tried this yet myself I can't be sure of the speed issues resulting from calling a database frequently. You would likely have to find a way to cache \ limit these ajax calls to the DB because the way the update functions work in ImpactJS would bring the DB to a halt.

Has anyone tried anything like this? Or know that it wont work?

1 decade ago by ShawnSwander

So my idea is similar to that jswart essentially I have a table on mysql called mobs in game with every instance of an entity and stats including location and the time that that entity can move next...

Clients simulate that time and when its time to move next they will all connect to the server, the first client to connect will update the move the rest will see the updated information including the timestamp indicating the move is new so the other clients will update their screen rather than update the database.

1 decade ago by jswart

Hmm, that is interesting. I would love to see the code to observe how you addressed that problem.

Do you have a single entity w/in each client's game? Ex: GameStateEntity that takes care of calling the DB and updating the locations & stats of each 'in-game' entity?

Or was there some other way that you solved the issue. I'd love to play your game, or poke around at the code that handles this part of the client\server interaction so that I could learn from you.
Page 1 of 1
« first « previous next › last »