### Navigation

- index
- modules |
- next |
- previous |
- Pyskool 1.1.2 documentation »

# ai

Classes that implement the commands found in command lists, such as `GoTo` and `ConductClass`.

class `ai.``AddLines`(lines)

  Command that adds lines to Eric’s total. May be used by any character.

  Parameters: | lines (number) – The lines to add to Eric’s total.

  `execute`()

    Make a character add lines to Eric’s total.

    Returns: | self.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

class `ai.``Catch`

  Command that makes Eric catch a mouse or frog (if one is at hand).

  `catch_animal`()

    Make Eric catch a mouse or frog if one is at the location of his hand.

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `catch_animal()`
    - `stand_up()`
  `stand_up`()

    Make Eric stand up straight after bending over to catch a mouse or frog.

    Returns: | self.

class `ai.``ChaseEricOut`(min_x)

  Command that makes a character chase Eric up to the girls’ side of the skool gate. It is used by Miss Take if she spots him in the girls’ skool when it’s not playtime.

  Parameters: | min_x – The x-coordinate at which the character should stop chasing Eric, and stand on guard.

  `execute`()

    Make a character take the next step while chasing Eric, or remain by his side if already there.

    Returns: | A `GoTowardsXY` command if the character hasn’t caught up with Eric yet, or None if the character is already by Eric’s side.

class `ai.``CheckIfTouchingEric`(eric_knows_signal, eric_has_mumps_signal)

  Command that checks whether a character is touching Eric. This command is used by Angelface when he has mumps.

  Parameters: | eric_knows_signal – The signal used to indicate that Eric has been told to avoid the character who has mumps. eric_has_mumps_signal – The signal to use to indicate that Eric has mumps.

  `execute`()

    Make a character check whether he’s touching Eric (and has therefore transmitted his disease). If Eric has been informed of the character’s condition, and the character is touching Eric, the appropriate signal is raised to indicate that Eric has mumps.

    Returns: | self.

class `ai.``Command`

  Abstract class from which all other command classes inherit. Subclasses should implement a method named execute.

  `execute`()

    Execute the command. The default implementation provided here does nothing; subclasses should override this method to supply the desired behaviour.

    Returns: | self

  `finish`()

    Perform any required cleanup before the command is removed from the command stack. This method is called on a controlling command just before it is terminated, and on an interruptible command when it is interrupted. The default implementation provided here does nothing; subclasses override this method as necessary.

  `is_GoTo`()

    Return whether this command is one of the `GoTo` commands. This method returns False, but the `GoTo` commands override it and return True.

  `is_interruptible`()

    Return whether this command is interruptible. An interruptible command can be terminated immediately by a command list restart. This method returns True, but subclasses may override it and return False instead.

class `ai.``CommandList`(character)

  A list of commands built from a `CommandListTemplate`. Maintains a command stack from which commands are popped after they have finished executing.

  Parameters: | character (`Character`) – The character to be controlled (the command list owner).

  `add_command`(command)

    Add a command to the stack.

    Parameters: | command – The `Command` to add.

  `command`()

    Hand control of the command list owner over to the current command. The steps taken are:

    1. Add the controlling command (if there is one, and the current command is interruptible) to the stack.
    2. Add the subcommand (if there is one, and the current command is interruptible) to the stack.
    3. If the command stack is empty, pull the next command from the command list and add it to the stack.
    4. Execute the current command (the last command on the stack).
    5. Act on the return value from the current command; if it is:

    > - None, then return from this method;
    > - self (the command itself), then pop the current command from the stack and go to step 3;
    > - another command, then add that command to the stack and go to step 4.

  `get_GoTo_destination`()

    Return the destination of the character, or None if he is not under the control of a `GoTo` command.

  `is_GoToing`()

    Return whether the character is under the control of one of the `GoTo` commands.

  `is_interruptible`()

    Return False if the command stack contains an uninterruptible command, True otherwise.

  `jump`(offset)

    Jump forwards (or backwards) in the list of commands.

    Parameters: | offset – The offset by which to jump. -2 means the previous command, -1 means the current command, 0 means the next command, and 1 means the next command but one.

  `restart`(index=None)

    Restart this command list. When the current command finishes, the next command will be the first command in the command list, or the command denoted by index.

    Parameters: | index – The index of the command at which to restart (defaults to 0).

  `set_GoTo_destination`(destination)

    Set the destination of the character if he is under the control of a `GoTo` command.

    Parameters: | destination (`Location`) – The destination to set.

  `set_controlling_command`(command)

    Set the controlling command for this command list. The controlling command, if set, is executed before and in addition to the current command on the stack (see `command()`). `WalkFast` and `HitNowAndThen` are examples of commands that are used as controlling commands.

    Parameters: | command (`Command`) – The command to set as the controlling command.

  `set_restart_point`()

    Remove the current and all previous commands from the command list. When the current command finishes, the next command will be regarded as the first for the purposes of a command list restart.

  `set_subcommand`(command_name, args)

    Set the subcommand for this command list. The subcommand, if set, is executed before and in addition to the current command on the stack (see `command()`). `MonitorEric` is an example of a command that is used as a subcommand.

    Parameters: | command_name – The name of the command to set as the subcommand. args – The subcommand’s arguments.

  `set_template`(template)

    Set the template for this command list. This method is used to replace a character’s current command list (e.g. when the bell rings). Any interruptible commands remaining on the stack are removed (after calling their `finish()` methods); uninterruptible commands are left in place so that they have a chance to finish before the new command list kicks in.

    Parameters: | template – The `CommandListTemplate` to use.

class `ai.``CommandListTemplate`(command_list_id)

  Template from which a specific command list may be created (one or more times). command_list_id is an identifier for the command list, used only for debugging purposes.

  `add_command`(command_class, *params)

    Add a command to this template.

    Parameters: | command_class – The class object that implements the command. params – The command’s parameters.

  `get_commands`(start)

    Return a list of commands (initialised command class instances) constructed from this template.

    Parameters: | start – The index of the first command. If start is 0, the entire list of commands is returned. If start is N>0, the first N commands are omitted.

class `ai.``ComplexCommand`

  Abstract class used by many commands that require a fixed sequence of steps to be executed with little or no conditional logic. Each step is implemented as a separate method. Subclasses must implement a method named get_commands that returns a list of the names of the methods to execute.

  `done`()

    Terminate this complex command. This method is typically used as the last step in the sequence, and is provided for convenience to subclasses.

    Returns: | self (to terminate this command)

  `execute`()

    Execute the next step (method) in this command’s sequence. What happens after that depends on the return value from the method called; if it is:

    - False, then the step is taken to be still in progress, and will be executed again the next time this method is called
    - None, then the step is taken to be finished
    - self (this command), then the entire command is taken to be finished, and no more steps will be executed
    - another command, then that command is added to the stack (so that it will be executed before proceeding to the next step)
  `restart`()

    Return to the first step in the sequence.

class `ai.``ConductAssembly`

  Command that makes a character conduct assembly. This involves delivering a detention message.

  `execute`()

    Make a character deliver a detention message. After the message has been delivered, a signal is raised to indicate that assembly is finished.

    Returns: | self if the detention message has been delivered, or a `Say` command.

class `ai.``ConductClass`(signal=None, qa_group=None)

  Command that makes a character conduct a class. It determines whether the character is teaching Eric, and passes control to a `ConductClassWithEric` or `ConductClassWithoutEric` command as appropriate.

  Parameters: | signal – The signal raised by the swot to indicate that he’s ready to start the lesson. qa_group – The Q&A group from which to choose questions and answers for the teacher and the swot; if None, the Q&A group will be chosen at random from those available each time a question and answer is generated.

  `execute`()

    Make a character conduct a class.

    Returns: | A `ConductClassWithoutEric` command if the character is not teaching Eric; None if the character is teaching Eric but the swot hasn’t shown up yet; a `ConductClassWithEric` command otherwise.

class `ai.``ConductClassWithEric`(qa_group=None)

  Command that makes a character conduct a class with Eric. This involves waiting until the swot shows up, listening to him while he tells tales and responding appropriately, wiping the board (if there is one in the room), optionally writing on the board, and finally either telling the kids what to do and pacing up and down until the bell rings, or starting a question-and-answer session with the swot. At various points in this process, the character will also respond to the swot’s tales about Eric being missing.

  Parameters: | qa_group – The Q&A group from which to choose questions and answers for the teacher and the swot; if None, the Q&A group will be chosen at random from those available each time a question and answer is generated.

  `execute`()

    Make a character perform the next required action while conducting the class.

    Returns: | None if the character should do nothing at the moment, or an appropriate `Command`.

class `ai.``ConductClassWithoutEric`

  Command that makes a character conduct a class without Eric. This involves wiping the board (if there is one in the room), optionally writing on the board, telling the kids what to do, and then pacing up and down until the bell rings.

  `execute`()

    Make a character perform the next step in conducting this class.

    Returns: | A `WipeBoard` command; a `GoToXY` command to make the character return to the middle of the board after wiping it; a `WriteOnBoard` command (possibly); a `TellClassWhatToDo` command; or a `WalkUpOrDown` command.

class `ai.``DoAssemblyDuty`(assembly_started, assembly_finished)

  Command that makes a character perform assembly duty. This involves checking whether Eric is present in the assembly hall, and chasing him down if he’s absent.

  Parameters: | assembly_started – The signal that indicates assembly has started. assembly_finished – The signal that indicates assembly is finished.

  `execute`()

    Make a character perform assembly duty. If the character has just successfully herded the absent Eric to the assembly hall, the character’s command list is restarted (so that he returns to the back of the assembly hall and starts the Eric-watching process over again).

    Returns: | self if the character has just herded Eric back to the assembly hall, or assembly has finished; None if it’s not time to start keeping an eye out for Eric yet, or Eric is present; or a `FetchEric` command.

class `ai.``DropStinkbomb`

  Command that makes a character drop a stinkbomb.

  `drop`()

    Make a character drop a stinkbomb (thus creating a stinkbomb cloud).

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `raise_arm()`
    - `drop()`
    - `lower()`
    - `done()`
  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

  `lower`()

    Make a character lower his arm after dropping a stinkbomb.

    Returns: | None.

  `raise_arm`()

    Make a character raise his arm in preparation for dropping a stinkbomb.

    Returns: | None.

class `ai.``DumpWaterPistol`

  Command that makes Eric throw away his water pistol.

  `dump_water_pistol`()

    Make Eric drop his water pistol.

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `dump_water_pistol()`
    - `stand_up()`
  `stand_up`()

    Make Eric stand up straight again after dropping his water pistol.

    Returns: | None.

class `ai.``EndGame`

  Command that ends the game. May be used by any character.

  `execute`()

    Make a character end the game.

    Returns: | None.

class `ai.``EvadeMouse`(delay)

  Command that makes a character stand on a chair or start jumping.

  Parameters: | delay – The delay before the character will get off a chair or stop jumping.

  `execute`()

    Make a character:

    1. stand or remain standing on a chair, or
    2. start or continue jumping, or
    3. finish either one of these activities (after a certain time).

    Returns: | self if the character has finished standing on a chair or jumping, None otherwise.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (a musophobe must not be distracted while evading a mouse).

class `ai.``Fall`

  Command that controls a falling object (a conker or a drop of water or sherry).

  `execute`()

    Control an object that may be falling. If the object is not falling, do nothing; otherwise make it fall a bit, taking appropriate action if it hits the floor or a person’s head.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (falling objects do not care about the bell).

class `ai.``FallToFloor`

  Command that controls Eric’s descent to the floor (as from a bike that has run out of momentum, or a plant that has died).

  `execute`()

    Make Eric fall. If he has reached the floor, he will assume a sitting position.

    Returns: | self if Eric has hit the floor, or None if he’s still falling.

class `ai.``FetchEric`

  Command that makes a character find and hover around Eric until he goes to wherever he should be.

  `execute`()

    Make a character take the next step in the search for Eric.

    Returns: | self if Eric is where he should be, or is due to be expelled; None if the character is already beside Eric; or a `GoTowardsXY` command.

class `ai.``FindEric`

  Command that makes a character go and find Eric.

  `execute`()

    Make a character take the next step in the search for Eric. The skool clock is stopped to ensure that the character has enough time to find him. When Eric is found, he is frozen until the character decides to unfreeze him.

    Returns: | self if Eric has been found and frozen, None if Eric has been found but cannot be frozen at the moment, or a `GoTowardsXY` command.

class `ai.``FindEricIfMissing`

  Command that makes a character start looking for Eric if he’s not where he should be.

  `execute`()

    Make a character check whether Eric is where he should be, and go looking for him if not.

    Returns: | self if Eric is where he should be, or a `FetchEric` command.

class `ai.``FindSeat`(go_to_back=True, move_along=True)

  Command that makes a character find a seat and sit down.

  Parameters: | go_to_back – True if the character should seek out the back seat, False if he should find the nearest seat. move_along – True if the character should move along to the next seat even if he’s already standing beside one, False otherwise.

  `execute`()

    Make a character find a seat, turn round if he’s already beside one but facing the wrong way, or sit down.

    Returns: | self if the character sat down, None if he’s beside a seat but had to turn round, or a `GoToXY` command to send him to a seat.

class `ai.``FireCatapult`

  Command that makes a character fire a catapult.

  `aim`()

    Make a character start or finish raising his catapult to eye level.

    Returns: | False if the character has yet to raise the catapult to eye level, or None if he has raised it to eye level.

  `fire`()

    Make a character launch a catapult pellet.

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `aim()`
    - `fire()`
    - `lower()`
    - `done()`
  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (a catapult-firing character should finish what he’s started).

  `lower`()

    Make a character start or finish lowering his catapult.

    Returns: | False if the character has not finished lowering his catapult, or None if he has.

class `ai.``FireNowAndThen`

  Command that makes a character check whether it’s a good time to launch a catapult pellet, and act accordingly. This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  `get_command`()

    Returns the command that should be used to make a character fire his catapult.

    Returns: | A `FireCatapult` command.

  `ready`()

    Return whether this character will fire a catapult pellet. The answer will be True if all the conditions described in `HitOrFireNowAndThen.ready` are met, and also:

    - The character’s x-coordinate is divisible by 4.
    - The character’s catapult pellet is not currently airborne.
    - The character chooses to.

class `ai.``FireWaterPistol`

  Command that makes a character fire a water pistol.

  `aim`()

    Make a character take out his water pistol and aim it.

    Returns: | None.

  `fire`()

    Make a character pull the trigger of his water pistol (thus releasing a jet of water or sherry).

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `aim()`
    - `fire()`
    - `lower()`
    - `done()`
  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

  `lower`()

    Make a character put his water pistol back in his pocket.

    Returns: | None.

class `ai.``Flight`(phases, command_list_id=None)

  Command that controls Eric’s flight through a designated sequence of locations (relative to the starting point) and animatory states.

  Parameters: | phases – The phases of animation to proceed through. command_list_id – The ID of the command list Mr Wacker should switch to when Eric hits the ground; if not blank, Eric will be paralysed when he hits the ground.

  `execute`()

    Move Eric to the next location and phase of animation in the flight sequence.

    Returns: | self if Eric has landed safely; a `Freeze` command if Eric has landed but is now immobilised (as when falling from a great height); or None otherwise.

class `ai.``Floored`(count)

  Command that controls a character who has been knocked to the floor.

  Parameters: | count – The delay before the character should get up.

  `execute`()

    Make a character remain on the floor, or get up if enough time has passed.

    Returns: | self if the character has got up and is ready to resume normal service, None otherwise.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (the bell cannot raise characters from the floor).

class `ai.``Follow`(character_id)

  Command that makes a character follow another character.

  Parameters: | character_id – The ID of the character to follow.

  `execute`()

    Make a character go to the same destination as another character.

    Returns: | self if the destination has been reached, or a `GoTo` command.

class `ai.``Freeze`

  Command that controls Eric while he’s frozen (as by the `FindEric` command).

  `execute`()

    Control Eric while he’s frozen. Each time this method is called, a check is made whether Eric has acknowledged understanding of the message being delivered to him (see `TellEricAndWait`).

    Returns: | None.

class `ai.``GoTo`(location_id, destination=None, go_one_step=False)

  Command that makes a character go to a location.

  Parameters: | location_id – The ID of the location to go to (may be None). destination (`Location`) – The location to go to (required if location_id is None). go_one_step – True if this command should terminate after sending the character one step towards the destination.

  `execute`()

    Make a character take the next step towards his destination.

    Returns: | self if the character has already reached his destination, None otherwise.

  `is_GoTo`()

    Return whether this command is one of the `GoTo` commands.

    Returns: | True.

class `ai.``GoToRandomLocation`

  Command that makes a character go to a location chosen at random.

  `execute`()

    Make a character start the journey towards a randomly chosen location.

    Returns: | A `GoTo` command.

class `ai.``GoToXY`(x, y)

  Command that makes a character go to a location specified by x- and y-coordinates.

  Parameters: | x – The x-coordinate of the location to go to. y – The y-coordinate of the location to go to.

class `ai.``GoTowardsXY`(x, y)

  Command that makes a character take one step towards a location.

  Parameters: | x – The x-coordinate of the location to go towards. y – The y-coordinate of the location to go towards.

class `ai.``GrassAndAnswerQuestions`

  Command that makes a character tell tales and answer the teacher’s questions during a lesson. It is used by the swot.

  `execute`()

    Make a character tell a tale, wait for a teacher to ask a question, or answer a teacher’s question.

    Returns: | None if the character should do nothing at the moment, or an appropriate `Command`.

class `ai.``Grow`(half, full, die)

  Command that controls a plant.

  Parameters: | half – The delay between being watered and appearing at half-height. full – The delay between being watered and growing to full height. die – The delay between being watered and dying.

  `execute`()

    Control a plant. If the plant has recently been watered, it will grow to full height and then die (disappear).

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (plants do not care about the bell).

class `ai.``Hit`

  Command that makes a character throw a punch.

  `aim`()

    Make a character start or finish raising his fist.

    Returns: | None if the character’s fist is fully raised, False otherwise.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `aim()`
    - `hit()`
    - `lower()`
    - `done()`
  `hit`()

    Make a character deck anyone unfortunate enough to come into contact with his raised fist.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

  `lower`()

    Make a character start or finish lowering his fist.

    Returns: | None if the character’s fist is fully lowered, False otherwise.

class `ai.``HitNowAndThen`

  Command that makes a character check whether it’s a good time to throw a punch, and act accordingly. This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  `get_command`()

    Returns the command that should be used to make a character throw a punch.

    Returns: | A `Hit` command.

  `ready`()

    Return whether this character will throw a punch. The answer will be True if all the conditions described in `HitOrFireNowAndThen.ready()` are met, and also:

    - There is someone punchable in front of the character.
    - The character chooses to.

class `ai.``HitOrFireNowAndThen`

  Abstract command that makes a character check whether it’s a good time to throw a punch or launch a catapult pellet, and act accordingly.

  `execute`()

    Make a character start throwing a punch or launching a catapult pellet if conditions are favourable.

    Returns: | self if conditions are not favourable, or a `Hit` or `FireCatapult` command.

  `ready`()

    Return whether now is a good time for this character to throw a punch or fire a catapult pellet. The answer will be True if all the following conditions are met:

    - The character is not on a staircase.
    - There are no adults nearby facing the character.
    - The character is standing upright.

class `ai.``Hop`(phases)

  Command that controls a frog while it’s hopping.

  Parameters: | phases – The phases of animation to use for the hop.

  `execute`()

    Move a frog to the next phase of animation in the hop.

    Returns: | self if the hop is finished, or None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

class `ai.``Jump`

  Command that makes a character jump.

  `down`()

    Make a character return to the floor after jumping.

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `up()`
    - `down()`
    - `done()`
  `up`()

    Make a character jump into the air.

    Returns: | None.

class `ai.``JumpIfOpen`(door_id, offset)

  Command that jumps forwards or backwards in a character’s command list if a specified door or window is open.

  Parameters: | door_id – The ID of the door or window to check. offset (number) – The offset by which to jump in the command list.

  `execute`()

    Jump forwards or backwards in a character’s command list if a specified door or window is open.

    Returns: | self.

class `ai.``JumpIfShut`(door_id, offset)

  Command that jumps forwards or backwards in a character’s command list if a specified door or window is shut.

  Parameters: | door_id – The ID of the door or window to check. offset (number) – The offset by which to jump in the command list.

  `execute`()

    Jump forwards or backwards in a character’s command list if a specified door or window is shut.

    Returns: | self.

class `ai.``JumpOffSaddle`

  Command that controls Eric after he’s jumped off the saddle of the bike.

  `check_cup`()

    Place the frog in a cup (if Eric has it and has reached a cup).

    Returns: | None

  `fall`()

    Guide Eric back to the floor after jumping off the saddle of the bike.

    Returns: | False if Eric has not reached the floor yet, or None otherwise.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `rise()`
    - `reach()`
    - `check_cup()`
    - `fall()`
    - `done()`
  `reach`()

    Make Eric rise again and raise his arm (to reach for a cup).

    Returns: | None.

  `rise`()

    Make Eric rise off the bike saddle.

    Returns: | None.

class `ai.``Kiss`

  Command that controls Eric while he kisses (or attempts to kiss) another character.

  `finish_kiss`()

    Control Eric as he finishes a kiss or attempted kiss. If there was no one within kissing range in front of Eric, he will return from the midstride position. If there was someone kissable within kissing range, they will either finish the kiss with Eric (if they accepted it) or deck him (if they decided to slap him instead).

    Returns: | None.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `start_kiss()`
    - `finish_kiss()`
    - `done()`
  `start_kiss`()

    Control Eric as he begins an attempt to kiss someone. If there is no one within kissing range in front of Eric, he will move midstride. If there is someone kissable within kissing range, they will either accept the kiss or slap him.

    Returns: | None.

class `ai.``KnockedOver`(delay, reprimand_delay, sleep)

  Command that controls an adult character who has been knocked over by a catapult pellet or conker.

  Parameters: | delay – The delay before the character rises. reprimand_delay – The delay before the character gives lines to someone for knocking him over. sleep – Whether the character should remain unconscious for a while (as when Albert is struck by a conker).

  `execute`()

    Control an adult character who has been knocked over. If conditions are right and the character holds a safe combination letter, he will reveal it. If enough time has passed since being knocked over, the character will give lines if any suitable recipient is nearby.

    Returns: | self if the character has got up and is ready to resume normal service, None otherwise.

class `ai.``MonitorEric`(command_list_id, chase_x)

  Command that makes a character keep an eye out for Eric, and act appropriately if he’s spotted. It is used by Miss Take to make her chase Eric out of the girls’ skool if she spots him there when it’s not playtime. This command is used as a subcommand (see `CommandList.set_subcommand()`).

  Parameters: | command_list_id – The ID of the command list to execute if Eric is spotted. chase_x – The x-coordinate beyond which Eric must be for the monitor to start chasing Eric.

  `execute`()

    Make a character check whether they can see Eric in the girls’ skool during a non-playtime period, and switch to an appropriate command list if so.

    Returns: | self.

class `ai.``MoveAboutUntil`(signal, walkabout_range=(1, 7))

  Command that makes a character walk up and down until a signal is raised.

  Parameters: | signal – The signal to wait for. walkabout_range – The minimum and maximum distances to walk away from the walkabout origin.

  `execute`()

    Make a character walk up and down unless the signal has been raised.

    Returns: | self if the signal has been raised, or a `WalkAround` command.

class `ai.``MoveBike`

  Command that controls a bike when Eric’s not sitting on the saddle.

  `execute`()

    Control a bike when Eric’s not sitting on the saddle. If the bike is resting on the floor or is not yet visible, do nothing; otherwise move the bike forwards.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (the bike does not care about the bell).

class `ai.``MoveDeskLid`(delay)

  Command that controls a desk lid.

  Parameters: | delay – The delay before an opened desk lid closes.

  `execute`()

    Control a desk lid. If the desk lid is not raised, nothing happens. If the desk lid has just been raised, the contents of the desk (if any) are delivered to the lid-raiser.

    Returns: | None.

class `ai.``MoveDoor`(barrier_id, shut)

  Abstract command that makes a character open or close a door or window.

  Parameters: | barrier_id – The ID of the door or window. shut – True if the door or window should be shut, False otherwise.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `raise_arm()`
    - `move_door()`
    - `lower_arm()`
    - `done()`
  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False.

  `lower_arm`()

    Make a character lower his arm after opening or closing a door or window.

    Returns: | None.

  `move_door`()

    Open or close a door or window.

    Returns: | None.

  `raise_arm`()

    Make a character raise his arm in preparation for opening or closing a door or window, or do nothing if the door/window is already in the desired state.

    Returns: | self if the door/window is already in the desired state, or None if the character raised his arm.

class `ai.``MoveFrog`(p_hop, p_turn_round, p_short_hop)

  Command that controls a frog.

  Parameters: | p_hop – Probability that the frog will keep still if Eric is not nearby. p_turn_round – Probability that the frog will turn round. p_short_hop – Probability that the frog will attempt a short hop (instead of a long hop) if not turning round.

  `execute`()

    Control a frog.

    Returns: | A `Hop` command, or None if the frog decides not to move.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (frogs do not care about the bell).

class `ai.``MoveMouse`(hide_range, sprints, sprint_range, life_range)

  Command that controls a mouse.

  Parameters: | hide_range (2-tuple) – Minimum and maximum delays before the mouse comes out of hiding. sprints (2-tuple) – Minimum and maximum number of sprints the mouse will make before hiding. sprint_range (2-tuple) – Minimum and maximum distances of a sprint. life_range (2-tuple) – Minimum and maximum number of sprint sessions the mouse will engage in before dying (if released by Eric).

  `execute`()

    Control a mouse. The pattern of movements of a mouse is as follows:

    > 1. Sprint up and down a few times.
    > 2. Hide for a bit.
    > 3. Go to 1, or die.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (mice do not care about the bell).

class `ai.``MovePellet`

  Command that controls a catapult pellet.

  `execute`()

    Move a catapult pellet if it’s currently airborne, remove it from sight if it’s reached the end of its flight, or else do nothing. If the pellet is airborne and hits a wall, door, window, shield, cup, conker or head, appropriate action is taken.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (a catapult pellet should not be stopped by the bell).

class `ai.``MoveWater`

  Command that controls a stream of liquid (water or sherry) fired from a water pistol.

  `execute`()

    Move a stream of water or sherry one phase further in its trajectory. If the liquid hits a cup, a plant or the floor on its journey, appropriate action is taken.

    Returns: | None.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (flying liquids are unstoppable).

class `ai.``OpenDoor`(barrier_id)

  Command that makes a character open a door or window.

  Parameters: | barrier_id – The ID of the door or window.

class `ai.``Pause`

  Command used to occupy a character while they are responding to an attempted kiss from Eric.

  `execute`()

    Occupy a character while they are responding to an attempted kiss from Eric. The character’s animation is controlled by the `Kiss` command while this command is in effect.

    Returns: | self if the character has finished responding to the kiss, or None if they are still occupied.

class `ai.``ReleaseMice`

  Command that makes Eric release some mice.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `release_mice()`
    - `stand_up()`
  `release_mice`()

    Make Eric release some mice.

    Returns: | None.

  `stand_up`()

    Make Eric stand up straight after bending over to release some mice.

    Returns: | self.

class `ai.``Restart`

  Command that restarts a character’s command list.

  `execute`()

    Restart a character’s command list.

    Returns: | self

class `ai.``RideBike`(bike)

  Command that controls Eric while he’s on a bike.

  Parameters: | bike – The bike Eric’s riding.

  `execute`()

    Control Eric while he’s on a bike. Keep the bike moving if Eric pedals, or carry Eric along with the bike if he’s standing on the saddle.

    Returns: | self if Eric has dismounted; a `JumpOffSaddle` command if Eric jumped while standing on the saddle; a `Flight` command if Eric hit the skool gate while standing on the saddle; a `FallToFloor` command if the bike ran out of momentum; or None otherwise.

class `ai.``Say`(words, notify=False)

  Command that makes a character say something.

  Parameters: | words – The words to say. notify – True if the character who is listening should be notified (as during a question-and-answer session between a teacher and the swot), False otherwise.

  `execute`()

    Make a character utter the next bit of whatever he’s saying. If the character has finished speaking, his speech bubble is removed, and any listeners are notified.

    Returns: | self if the character has finished speaking, None otherwise.

  `finish`()

    Remove the character’s speech bubble. This method is called if the command is removed from the command stack before exiting normally.

class `ai.``SetClock`(ticks)

  Command that makes a character set the skool clock to a specified time.

  Parameters: | ticks (number) – The time to set the clock to (remaining ticks till the bell rings).

  `execute`()

    Make a character set the skool clock.

    Returns: | self.

class `ai.``SetControllingCommand`(command_name, *params)

  Command that sets a controlling command on a character’s command list. See `CommandList.set_controlling_command()` for more details.

  Parameters: | command_name – The name of the controlling command. params – The controlling command’s initialisation parameters.

  `execute`()

    Set the controlling command on a character’s command list.

    Returns: | self.

class `ai.``SetRestartPoint`

  Command that makes the next command in a character’s command list be regarded as the first (for the purposes of a restart).

  `execute`()

    Make the next command in a character’s command list be regarded as the first (for the purposes of a restart).

    Returns: | self.

class `ai.``SetSubcommand`(command_name, *args)

  Command that sets a subcommand on a character’s command list. See `CommandList.set_controlling_command()` for more details.

  Parameters: | command_name – The name of the subcommand. args – The subcommand’s parameters.

  `execute`()

    Set a subcommand on a character’s command list.

    Returns: | self.

class `ai.``ShadowEric`

  Command that makes a character run after Eric and then hover around him until the bell rings.

  `execute`()

    Make a character take the next step in the search for Eric, or remain by his side.

    Returns: | A `GoTowardsXY` command if the character hasn’t found Eric yet, or None if the character is already by Eric’s side.

class `ai.``ShutDoor`(barrier_id)

  Command that makes a character close a door or window.

  Parameters: | barrier_id – The ID of the door or window.

class `ai.``Signal`(signal)

  Command that makes a character raise a signal.

  Parameters: | signal – The signal to raise.

  `execute`()

    Make a character raise a signal.

    Returns: | self.

class `ai.``SitForAssembly`(assembly_finished, sit_direction, sit_range=(1, 4))

  Command that makes a character find a spot to sit down during assembly, and keeps him seated until assembly has finished.

  Parameters: | assembly_finished – The signal that indicates assembly is finished. sit_direction – The direction to face when sitting down. sit_range – The minimum and maximum distances the character should walk back to find a spot to sit.

  `find_spot_to_sit`()

    Make a character find a spot to sit during assembly. If assembly has already finished, the command is terminated.

    Returns: | self if assembly has finished, or a `GoToXY` command to send the character to a place to sit down.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `find_spot_to_sit()`
    - `sit_down()`
    - `get_up()`
    - `done()`
  `get_up`()

    Make a character get up if assembly has finished. If assembly has not finished yet, return here next time.

    Returns: | False if assembly is still in progress, or None if the character got up off the floor.

  `sit_down`()

    Make a character sit down for assembly, or turn round to face the right way for assembly. If assembly has already finished, the command is terminated.

    Returns: | self if assembly has finished, False if the character was turned round, or None if the character sat down.

class `ai.``SitStill`

  Command that makes a character do nothing. It is used to make a character sit still during a lesson.

  `execute`()

    Make a character do nothing.

    Returns: | None.

class `ai.``StalkAndHit`(character_id)

  Command that makes a character seek out another character while throwing occasional punches. This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  Parameters: | character_id – The ID of the character to stalk.

  `execute`()

    Make a character proceed one step further towards whoever he’s stalking, and consider throwing a punch while he’s at it.

    Returns: | A `HitNowAndThen` command.

class `ai.``StartAssemblyIfReady`(signal)

  Command that restarts a character’s command list unless it’s time to start assembly.

  Parameters: | signal – The signal to raise to indicate that assembly has started.

  `execute`()

    Restart a character’s command list unless it’s time to start assembly.

    Returns: | self if it’s time to start assembly, None otherwise.

class `ai.``StartDinnerIfReady`

  Command that makes a character start dinner if the time has come, or restarts the character’s command list if it’s still too early. It is used by teachers on dinner duty.

  `execute`()

    Make a character start dinner, or restart his command list if it’s too early to start dinner.

    Returns: | self

class `ai.``StartLessonIfReady`(signal)

  Command that makes a character start a lesson if the time has come, or restarts the character’s command list if it’s still too early.

  Parameters: | signal – The signal to raise when starting the lesson.

  `execute`()

    Make a character start a lesson, or restart his command list if it’s too early to start the lesson. If it’s time to start the lesson, the character has a special safe secret question, and he can see the answer on a nearby blackboard, he will reveal his safe secret.

    Returns: | A `TellKidsToSitDown` command if it’s time to start the lesson, self otherwise.

class `ai.``Stink`(delay)

  Command that controls a stinkbomb cloud.

  Parameters: | delay – The delay before the stinkbomb disappears.

  `execute`()

    Animate a stinkbomb cloud (if it’s visible).

    Returns: | None.

class `ai.``StopEric`(alertee_id, command_list_id, alert_message, escape_x, danger_zone)

  Command that makes a character try to stop Eric escaping from skool, and alert whoever should be alerted.

  Parameters: | alertee_id – The ID of the character to alert. command_list_id – The ID of the command list the alerted character should use. alert_message – The alert message to scream. escape_x – The x-coordinate beyond which Eric should be regarded as trying to escape. danger_zone – The minimum and maximum distance to the left of the watcher that Eric must be for him to raise the alarm.

  `execute`()

    Make a character raise the alarm (if he hasn’t already) that Eric is trying to escape, and continue trying to stop Eric if need be.

    Returns: | self if the character has deemed it no longer necessary to try and stop Eric escaping, or None otherwise.

class `ai.``TellClassWhatToDo`

  Command that makes a character tell a class what to do. It is used by teachers.

  `execute`()

    Make a character tell the class what to do.

    Returns: | A `Say` command, or self if the character has finished telling the class what to do.

class `ai.``TellEric`(message)

  Command that makes a character say something to Eric.

  Parameters: | message – The message to give to Eric.

  `execute`()

    Make a character say something to Eric. When the character has finished speaking, Eric will be unfrozen.

    Returns: | self if the character has finished speaking, or a `Say` command.

class `ai.``TellEricAndWait`(message)

  Command that makes a character say something to Eric, and wait for a response.

  Parameters: | message – The message to give to Eric.

  `execute`()

    Make a character say something to Eric, and then wait for a response. When Eric has responded, he will be unfrozen. If Eric does not respond within a certain period, the character will repeat the message and wait again.

    Returns: | self if Eric has responded, None if the character is waiting for Eric to respond, or a `Say` command.

class `ai.``TellKidsToSitDown`

  Command that makes a character tell the kids to sit down.

  `execute`()

    Make a character tell the kids to sit down.

    Returns: | A `Say` command, or self if the character has finished telling the kids to sit down.

class `ai.``TripPeopleUp`

  Command that makes a character trip people up while running towards his destination. This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  `execute`()

    Make a character start or continue running, and trip up anyone in his path.

    Returns: | self.

class `ai.``Unsignal`(signal)

  Command that makes a character lower a signal.

  Parameters: | signal – The signal to lower.

  `execute`()

    Make a character lower a signal.

    Returns: | self.

class `ai.``WaitAtDoor`(door_id)

  Command that makes a character wait at a door until everyone is on the correct side of it (that is, boys on the boys’ side, girls on the girls’ side).

  Parameters: | door_id – The ID of the door to wait at.

  `execute`()

    Make a character wait at a door until everyone is on the correct side of it.

    Returns: | self if everyone is on the correct side of the door, None otherwise.

class `ai.``WaitUntil`(signal)

  Command that makes a character wait until a signal is raised.

  Parameters: | signal – The signal to wait for.

  `execute`()

    Make a character wait for a signal.

    Returns: | self if the signal has been raised, None otherwise.

class `ai.``WalkAround`(walkabouts, walkabout_range=(1, 7))

  Command that makes a character walk up and down a given number of times.

  Parameters: | walkabouts – The number of times to walk up and down. walkabout_range – The minimum and maximum distances to walk away from the walkabout origin.

  `execute`()

    Make a character walk up (away from the walkabout origin) or down (back to the walkabout origin). If the character is on a staircase, make him finish going up or down it first.

    Returns: | self if the designated number of walkabouts has been performed, None if the character is on a staircase, or a `GoToXY` command.

class `ai.``WalkFast`

  Command that makes a character walk fast (as kids do half the time, and teachers do when chasing Eric). This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  `execute`()

    Ensure that a character starts or continues to walk fast.

    Returns: | self.

  `finish`()

    Trigger a speed change for the character so that he no longer runs continuously.

class `ai.``WalkUpOrDown`

  Command that makes a character walk up (away from an origin) or down (back to the origin).

  `execute`()

    Make a character walk up or down.

    Returns: | A `GoToXY` command, or self if the character is ready to turn round.

class `ai.``WatchForEric`(alertee_id, command_list_id, alert_message, escape_x, danger_zone)

  Command that makes a character keep an eye out for Eric, and alert someone if they spot him trying to escape from skool. This command is used as a controlling command (see `CommandList.set_controlling_command()`).

  Parameters: | alertee_id – The ID of the character to alert. command_list_id – The ID of the command list the alerted character should use. alert_message – The message to scream if Eric is spotted trying to escape. escape_x – The x-coordinate beyond which Eric should be regarded as trying to escape. danger_zone – The minimum and maximum distance to the left of the watcher that Eric must be for him to raise the alarm.

  `execute`()

    Make a character check whether Eric is trying to escape from skool, and take appropriate action if he is.

    Returns: | A `StopEric` command if Eric is spotted trying to escape, or self otherwise.

class `ai.``WipeBoard`

  Command that makes a character wipe a blackboard.

  `get_commands`()

    Return the list of steps (methods) to execute for this complex command. The steps are:

    - `walk()`
    - `wipe()`
    - `lower_arm()`
    - `done()`
  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (blackboards should never be left partially wiped).

  `lower_arm`()

    Make a character lower his arm after wiping a bit of a blackboard. If there are any bits of the blackboard left to wipe, the command is restarted.

    Returns: | None.

  `walk`()

    Make a character walk to the next part of the blackboard that needs wiping. If the character hasn’t started wiping yet, he is sent to the nearest edge of the blackboard.

    Returns: | A `GoToXY` command to send the character to the appropriate location.

  `wipe`()

    Make a character raise his arm and wipe a bit of a blackboard.

    Returns: | None.

class `ai.``Write`

  Command that controls Eric while he’s writing on a blackboard.

  `execute`()

    Control Eric while he’s writing on a blackboard.

    Returns: | self if Eric has finished writing on the blackboard, None otherwise.

class `ai.``WriteOnBoard`(message)

  Command that makes a character write on a blackboard.

  Parameters: | message – The message to write on the blackboard.

  `execute`()

    Make a character write the next letter of the message on a blackboard. The character’s arm will be alternately raised or lowered while writing.

    Returns: | self if the character has finished writing, None otherwise.

  `is_interruptible`()

    Return whether this command is interruptible.

    Returns: | False (a blackboard should not be left half-written on)

class `ai.``WriteOnBoardUnless`(signal)

  Command that makes a character write on a blackboard unless a specified signal has been raised.

  Parameters: | signal – The signal to check before writing on the blackboard.

  `execute`()

    Make a character write on a blackboard unless a signal has been raised.

    Returns: | self if the signal has been raised, or the blackboard is dirty, or the character has finished writing on the blackboard; a `WriteOnBoard` command otherwise.

`ai.``get_command_class`(command_name)

  Return the class object for a given command.

  Parameters: | command_name – The name of the command.

### Navigation

- index
- modules |
- next |
- previous |
- Pyskool 1.1.2 documentation »