Subject: Re: How to make an action only one time ?
From: Michel Etienne (etienne@avignon.inra.fr)
Date: Mon Jun 30 2008 - 17:36:17 CEST
A 11:10 30/06/2008 -0400, Fabrice Vinatier a écrit :
>Hello,
>I am looking for a way to make an action only one time, although the
>condition is still valid for the next time steps.
>I send the code :
>
>(self thePlants select: [:a | a growingState = #harvesting]) size > 0
> ifTrue:
> [self saveAttackDistributions.
> self savePopDistributions]
>
>AttackDistributions and PopDistributions are saved in a file .txt, but if
>there is 10 time steps after harvesting, for example, the saving will be
>done ten times.
>
>If you have an idea of how to prevent this ?
>Cheers,
il suffit de définir le pas de temps auquel vous souhaitez faire les
sauvegardes avec un modulo (t \\ n), n étant le nombre de pas de temps
entre une sauvegarde et la suivante
t \\ 12 = 1 ifTrue: [(self thePlants select: [:a | a growingState =
#harvesting]) size > 0
ifTrue:
[self saveAttackDistributions.
self savePopDistributions]]
lance une sauvegarde aux pas de temps 1, 13, 25 etc
M. Etienne