version 12 by Michael Callaghan

  • Home page
  • Beginning
  • Previous
  • Next

  • Section 3.8 - Rule for deciding if it is the patroller's turn to move
    To decide if (Bod - a patroller) is ready to move:
        [calculate how many turns have elapsed since the patroller was activated]
        let elapsed turns be the turn count minus the StartTurn of the Bod;
        [a simple error check to prevent division by 0]
        if the Turn Frequency of the Bod is less than 1:
            now the Turn Frequency of the Bod is 1;
        [calculate whether the elapsed turns is exactly divisible by the Turn Frequency]
        let decision be the remainder after dividing the elapsed turns by the Turn Frequency of the Bod;
        if decision is 0 and the location of the Bod is a room:
            decide yes;
        decide no.