Re: [jug-discussion] looking for a thread/game guru

2006-12-04 Thread Warner Onstine
What I had originally done (which has now been changed to something  
similar to this) was to have a timed loop that would go through each  
player in the list and either roll the dice or let them roll it.  
Since it was a TImer, it was sitting in its own thread.


Now that I've switched it to simply resume the game after each player  
is done with their turn and have it figure out who the next player is  
instead of using a timed loop.


Thanks everyone for the help, now I know a bit more about threads ;-).

-warner

On Dec 1, 2006, at 10:51 PM, Eric Biesterfeld wrote:


Why is this a thread-related issue? I'm a bit confused

Your controller should be off in its own little world interacting  
with the view as necessary. The view should have a listener to tell  
it when to update. They're off in their own little worlds, with the  
controller and its listeners to the mouse, keyboard, and such.


The model, however, really simple. When controller calls it with  
new information, it wakes up. Oh, hi, someone triggered the  
MouseListener!


if (currentPlayer.isHuman()) {
  do stuff
}

(Of course, your controller should be looking at the model and if  
the player is a human, the dice rolling button should be activated  
as well.)


So, then, how does your model progress? Well, don't think of it as  
a loop, think of it as a nextTurn() call, each time, first  
triggered by the controller when it calls model.newGame(Players[]  
players);


Then newGame initializes the game and says player[0].yourTurn();

If it's a computer player, it calls the model directly and  
interacts automatically. If it's a human player, it gets its inputs  
from the controller, only progressing the game at the Controller's  
pace. ( player.rollDice(); player.buyProperty(true); player.endTurn 
()) -- which, of course, calls model.nextTurn();

___

Or perhaps I'm missing the point?

On 12/1/06, Warner Onstine [EMAIL PROTECTED] wrote: Or at  
least someone who's smarter than me ;-). I'm stuck on a project

for school, essentially it is a Monopoly game. I have created a
separate thread that runs through the list of players and moves them.
If they are a computer player then it rolls the dice for them, but
for the human players I want to allow the user to click the dice.

I've tried a number of techniques to get the game thread to pause and
wait for the user to click the dice but they've either resulted in
pausing the entire game and locking up the interface or just ignoring
the other thread altogether.

Any assistance is greatly appreciated as this is my first real time
with threads and it is driving me absolutely batty!

-warner

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] looking for a thread/game guru

2006-12-01 Thread Todd Ellermann
Ran into some similar problems the first time I wrote a game.  
JInvaders :)  The easiest thing I can suggest is have your game loop in
the main thread and have a token of control handed from player to
player. Have the player be either a user or a computer, but give each
one of them their own thread.  When they get the token (notify) they
are able to do something in the model.  This will also let your
computers perform strategic calculations off the main thread and allow
your users to do actions that don't impact game play without waitng for
their next move.
Have some JInvaders code, but would guess that a google search would
result in much better threading game examples.   JInvaders was written
in Java 1.0  and recompiled with MS J++ to work in old versions of I.E.
boy do I not miss the early days of Java!
-Todd

I haven't thought this all the way through and it has been a while

Happy Holidays to all you back home! 

--- Warner Onstine [EMAIL PROTECTED] wrote:

 Or at least someone who's smarter than me ;-). I'm stuck on a project
  
 for school, essentially it is a Monopoly game. I have created a  
 separate thread that runs through the list of players and moves them.
  
 If they are a computer player then it rolls the dice for them, but  
 for the human players I want to allow the user to click the dice.
 
 I've tried a number of techniques to get the game thread to pause and
  
 wait for the user to click the dice but they've either resulted in  
 pausing the entire game and locking up the interface or just ignoring
  
 the other thread altogether.
 
 Any assistance is greatly appreciated as this is my first real time  
 with threads and it is driving me absolutely batty!
 
 -warner
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


***
Todd R. Ellermann
President PHXJUG.org
[EMAIL PROTECTED]
602-738-6187 cell
***

Does getting an ASU MBA with existing UofA BSCE make me a SunCat? or a 
WildDevil?


 

Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] looking for a thread/game guru

2006-12-01 Thread Warner Onstine

Thanks Todd, this gives me some ideas of what I can try.

-warner

On Dec 1, 2006, at 4:33 PM, Todd Ellermann wrote:


Ran into some similar problems the first time I wrote a game.
JInvaders :)  The easiest thing I can suggest is have your game  
loop in

the main thread and have a token of control handed from player to
player. Have the player be either a user or a computer, but give each
one of them their own thread.  When they get the token (notify) they
are able to do something in the model.  This will also let your
computers perform strategic calculations off the main thread and allow
your users to do actions that don't impact game play without waitng  
for

their next move.
Have some JInvaders code, but would guess that a google search would
result in much better threading game examples.   JInvaders was written
in Java 1.0  and recompiled with MS J++ to work in old versions of  
I.E.

boy do I not miss the early days of Java!
-Todd

I haven't thought this all the way through and it has been a while

Happy Holidays to all you back home!

--- Warner Onstine [EMAIL PROTECTED] wrote:


Or at least someone who's smarter than me ;-). I'm stuck on a project

for school, essentially it is a Monopoly game. I have created a
separate thread that runs through the list of players and moves them.

If they are a computer player then it rolls the dice for them, but
for the human players I want to allow the user to click the dice.

I've tried a number of techniques to get the game thread to pause and

wait for the user to click the dice but they've either resulted in
pausing the entire game and locking up the interface or just ignoring

the other thread altogether.

Any assistance is greatly appreciated as this is my first real time
with threads and it is driving me absolutely batty!

-warner

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





***
Todd R. Ellermann
President PHXJUG.org
[EMAIL PROTECTED]
602-738-6187 cell
***

Does getting an ASU MBA with existing UofA BSCE make me a SunCat?  
or a WildDevil?




__ 
__
Any questions? Get answers on any topic at www.Answers.yahoo.com.   
Try it now.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jug-discussion] looking for a thread/game guru

2006-12-01 Thread Eric Biesterfeld

Why is this a thread-related issue? I'm a bit confused

Your controller should be off in its own little world interacting with the
view as necessary. The view should have a listener to tell it when to
update. They're off in their own little worlds, with the controller and its
listeners to the mouse, keyboard, and such.

The model, however, really simple. When controller calls it with new
information, it wakes up. Oh, hi, someone triggered the MouseListener!

if (currentPlayer.isHuman()) {
 do stuff
}

(Of course, your controller should be looking at the model and if the player
is a human, the dice rolling button should be activated as well.)

So, then, how does your model progress? Well, don't think of it as a loop,
think of it as a nextTurn() call, each time, first triggered by the
controller when it calls model.newGame(Players[] players);

Then newGame initializes the game and says player[0].yourTurn();

If it's a computer player, it calls the model directly and interacts
automatically. If it's a human player, it gets its inputs from the
controller, only progressing the game at the Controller's pace. (
player.rollDice(); player.buyProperty(true); player.endTurn()) -- which, of
course, calls model.nextTurn();
___

Or perhaps I'm missing the point?

On 12/1/06, Warner Onstine [EMAIL PROTECTED] wrote:


Or at least someone who's smarter than me ;-). I'm stuck on a project
for school, essentially it is a Monopoly game. I have created a
separate thread that runs through the list of players and moves them.
If they are a computer player then it rolls the dice for them, but
for the human players I want to allow the user to click the dice.

I've tried a number of techniques to get the game thread to pause and
wait for the user to click the dice but they've either resulted in
pausing the entire game and locking up the interface or just ignoring
the other thread altogether.

Any assistance is greatly appreciated as this is my first real time
with threads and it is driving me absolutely batty!

-warner

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]