Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simulate simultaneous movement by pieces on gameboard  RSS feed

 
Zeki Karaca
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need some advice. I am just a novice so bare with me. I am working on an assignment where i have 4 players. All players have pawns on the gameboard (20x20 squares). A pawn has some power and can attack another pawn. All pawns are stored in a LinkedList. At time T all players move there pawns according to some strategy. So ALL pawns need to be moved at the same time. I don't use multiple threads so somehow i need to simulate these movements. But i really don't know how i would do that.

Now it works like this.



So according to this FIRST player 1 moves his first pawn and then second, third etc. Then, when he finishes... player 2 moves his pawns etc.

This works fine. But it's not what i want. Somehow i need to make all pawns move at time T, and next round again all pawns move.

Because these moves can cause chain reactions. If 4 pawns want to go to 1 empty spot... all should die. This will never happen because player 1 fills this spot before the others move...

Any help would be appreciated. Just want to know what kind of things i should think of... should i simulate all moves... somehow check conflicts... and according to the results... do moves?
 
Miklos Szeles
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zerca,

Without real code it's not easy to give advice, since I don't know how you store info, what are the game rules. Anyway you don't need multiple threads for this. You can simply run through on all players steps in a turn, then after it you can check all the fields and count how many player stepped to the same position, and do something based on that.

P.S.:I don't think this thread has anything to do with Swing;)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!