Hello!
I'm writing a small game. The fileOut code for the game is pasted at http://paste.lisp.org/display/120545 . I got a rather strange bug going on, which I will describe here, in the hope that somebody has the time to help me. The bug is like this: If you open the game (with FiveInARowGame new openInWorld) and if you also have a Transcript window open, then the game works correctly. (Try clicking somewhere in the game board, and the AI will respond after 0.5 seconds, and the tag 'Crosses'' turn.' will change to 'Nought''s turn.' and back again.) But if you close the Transcript window, or if you remove a certain "Transcript show: '' . " statement in the FiveInARowGame>>performAI method, then mouse response will become less responsive in the game, and the 'Crosses'' turn.' tag will not update as it should any longer. Now, my question is: what magic does this call to Transcript do which causes my game to update correctly, and what message should I send instead to get the same effect, even without a Transcript window open ? Best Regards Martin Nilsson _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Martin,
You wrote: > But if you close the Transcript window, or if you remove a certain > "Transcript show: '' . " statement in the FiveInARowGame>>performAI method, > then mouse response will become less responsive in the game, and the > 'Crosses'' turn.' tag will not update as it should any longer. I tried your game in Squeak 4.1 (I know I am a little out of date. I don't know which Squeak you used.) I did not notice any change in responsiveness whenever I tried any of your transcript related changes. > the tag 'Crosses'' turn.' will change to > 'Nought''s turn.' and back again I never noticed this happen. ( Perhaps me machine is too fast, or eyes too slow :D) but the turn notifier switching works fine when I step through it with the debugger, with the transcript window closed. Hope this helps, David _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by martinnilsson
>Martin,
>You wrote: >> But if you close the Transcript window, or if you remove a certain >> "Transcript show: '' . " statement in the FiveInARowGame>>performAI method, >> then mouse response will become less responsive in the game, and the >> 'Crosses'' turn.' tag will not update as it should any longer. >I tried your game in Squeak 4.1 (I know I am a little out of date. I >don't know which Squeak you used.) >I did not notice any change in responsiveness whenever I tried any of >your transcript related changes. I'm using Squeak 3.9. I will update to 4.2 now to test if this makes any difference. >> the tag 'Crosses'' turn.' will change to >> 'Nought''s turn.' and back again >I never noticed this happen. ( Perhaps me machine is too fast, or eyes >too slow :D) but the turn notifier switching works fine when I step >through it with the debugger, with the transcript window closed. There should be half a second delay between it turning to 'Nought''s turn.' and then back again to 'Crosses''turn.' , because I added half a second delay to the performAI method which is performed inbetween the changes of the turn notifier. That you don't see this indicates to me that you have replicated my bug after all. Don't you see the changes to the turn notifier when you have a Transcript window open either? Because then it works for me. Anyway, I will update to Squeak 4.2 and see what happens. >Hope this helps, >David Regards Martin ____________ _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
If you are using Transcript show: without doing addDeferredUIMessage:, there could be problems in Morphic.
see <http://forum.world.st/addDeferredUIMessage-Documentation-td2216105.html> Ken At 2:17 PM +0000 3/16/11, Martin Nilsson apparently wrote: > >Martin, > >>You wrote: > >>> But if you close the Transcript window, or if you remove a certain >>> "Transcript show: '' . " statement in the FiveInARowGame>>performAI method, >>> then mouse response will become less responsive in the game, and the >>> 'Crosses'' turn.' tag will not update as it should any longer. > >>I tried your game in Squeak 4.1 (I know I am a little out of date. I >>don't know which Squeak you used.) > >>I did not notice any change in responsiveness whenever I tried any of >>your transcript related changes. > >I'm using Squeak 3.9. I will update to 4.2 now to test if this makes any >difference. > >>> the tag 'Crosses'' turn.' will change to >>> 'Nought''s turn.' and back again > >>I never noticed this happen. ( Perhaps me machine is too fast, or eyes >>too slow :D) but the turn notifier switching works fine when I step >>through it with the debugger, with the transcript window closed. > >There should be half a second delay between it turning to 'Nought''s turn.' >and then back again to 'Crosses''turn.' , because I added half a second >delay to the performAI method which is performed inbetween the changes >of the turn notifier. That you don't see this indicates to me that you >have replicated my bug after all. Don't you see the changes to the turn >notifier when you have a Transcript window open either? Because then it >works for me. Anyway, I will update to Squeak 4.2 and see what happens. > >>Hope this helps, > >>David > >Regards >Martin >____________ > >_______________________________________________ >Beginners mailing list >[hidden email] >http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by martinnilsson
Ok, thank you Ken, but the problem comes up when I _remove_ the Transcript show: message, not when I add it. I.e. Transcript show: seems to do something which makes my UI work correctly.
/Martin
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by martinnilsson
Hi! I have now replicated the bug in Squeak 4.2.
Regards Martin
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by martinnilsson
On 16.03.2011, at 11:33, Martin Nilsson wrote:
> Now, my question is: what magic does this call to Transcript do which causes my game to update correctly It performs a "world cycle", which causes a redraw. > , and what message should I send instead to get the same effect, even without a Transcript window open ? You could write "self world doOneCycleNow". However, this normally hints at a design flaw. Morphic is an event-driven system. It has a main loop that processes events, then redraws the changed parts of the world. Since your code does not "return" to the main loop while doing the AI, the UI will not update. The "proper" way would be doing the UI in a background process, which would notify the UI process when done. Then other things could happen in parallel to the AI "thinking". If you don't care about the world being frozen while the AI is doing its thing, then you don't need a background process, and forcing a world cycle to update the display is fine. Certainly simpler. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 16.03.2011, at 16:40, Bert Freudenberg wrote: > On 16.03.2011, at 11:33, Martin Nilsson wrote: > >> Now, my question is: what magic does this call to Transcript do which causes my game to update correctly > > It performs a "world cycle", which causes a redraw. > >> , and what message should I send instead to get the same effect, even without a Transcript window open ? > > You could write "self world doOneCycleNow". However, this normally hints at a design flaw. > > Morphic is an event-driven system. It has a main loop that processes events, then redraws the changed parts of the world. > > Since your code does not "return" to the main loop while doing the AI, the UI will not update. The "proper" way would be doing the UI in a background process, which would notify the UI process when done. Then other things could happen in parallel to the AI "thinking". I meant to write "doing the AI in a background process" of course. > If you don't care about the world being frozen while the AI is doing its thing, then you don't need a background process, and forcing a world cycle to update the display is fine. Certainly simpler. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by martinnilsson
Thank you! The problem is solved, and I think I see clearly why. I will look into background processes later, and for now I'll go with the simple solution. Great!
/Martin Nilsson > ----- Original Message ----- > From: Bert Freudenberg > Sent: 03/16/11 04:40 PM > To: A friendly place to get answers to even the most basic questions about Squeak. > Subject: Re: [Newbies] Strange bug with Morphic > > On 16.03.2011, at 11:33, Martin Nilsson wrote: > > > Now, my question is: what magic does this call to Transcript do which causes my game to update correctly > > It performs a "world cycle", which causes a redraw. > > > , and what message should I send instead to get the same effect, even without a Transcript window open ? > > You could write "self world doOneCycleNow". However, this normally hints at a design flaw. > > Morphic is an event-driven system. It has a main loop that processes events, then redraws the changed parts of the world. > > Since your code does not "return" to the main loop while doing the AI, the UI will not update. The "proper" way would be doing the UI in a background process, which would notify the UI process when done. Then other things could happen in parallel to the AI "thinking". > > If you don't care about the world being frozen while the AI is doing its thing, then you don't need a background process, and forcing a world cycle to update the display is fine. Certainly simpler. > > - Bert - > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |