<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
 <!ENTITY copyrightDates '2000,2001'>
 <!ENTITY % METACOSM SYSTEM "../en.metacosm.ent">
 %METACOSM;
]>

<article lang="EN">
  <articleinfo>
    <title>RFC - Events system</title>
    <corpauthor>&author;</corpauthor>
     <revhistory>
      <revision>
        <revnumber>0.4</revnumber>
        <date>May, 7th 2000</date>
        <authorinitials>Ruffy</authorinitials>
        <revremark>More detailed explanations - examples added</revremark>
      </revision>
      <revision>
        <revnumber>0.3</revnumber>
        <date>May, 3th 2000</date>
        <authorinitials>Ruffy</authorinitials>
        <revremark>Major changes both in the Event concept and in Events system - examples added</revremark>
      </revision>
      <revision>
        <revnumber>0.2</revnumber>
        <date>March, 29th 2000</date>
        <authorinitials>Ruffy</authorinitials>
        <revremark>Conversion to metacosm-DTD - Events types</revremark>
      </revision>
      <revision>
        <revnumber>0.1</revnumber>
        <date>March, 5th 2000</date>
        <authorinitials>Ruffy</authorinitials>
        <revremark>First written version</revremark>
      </revision>
      <revision>
        <revnumber>First draft and discussions</revnumber>
        <date>February, 19th 2000</date>
        <authorinitials>Elkine, Horus, Janselmeer, Ruffy</authorinitials>
      </revision>
    </revhistory>
    <abstract>
      <simpara>The goal of this document is to define the use of events and the concept
of events system, in the Metacosm project.</simpara>
    </abstract>
  </articleinfo>

&license;
&project;

<sect1>
<title>Notations</title>
  <para>Some terms are defined in the Vocabulary-RFC, which is available on the official
  web site. Their first letter is in uppercase.</para>

<sect1>
<title>Event</title>
  <para>
    <glosslist>
      <glossentry id="event">
        <glossterm>Event</glossterm>
        <glossdef>
          <para>An Event is something happening somewhere, which can be important for
          somebody.</para>
          <para>something: many different things are Events and Events have many different types.</para>
          <para>happening: an Event is caused by an Action, triggered by a timer or randomly
          produced. It can be created by the Game, by a Bot, by a Player or by something
          external.</para>
          <para>somewhere: it can be precisely located (in a Place or in a World) or not located
          (generated by the Game).</para>
          <para>important: an Event is something susceptible to make somebody or something have
          a reaction. Important means of some value, but not necessary for everybody.</para>
          <para>somebody: somebody (or something) will react to the Event. It can be one person,
          several people, everybody, even nobody ('which *can* be'): the Game, a part of the Game,
          parts of the Game, a Player, several Players, all Players, a Bot, several Bots,
          all Bots, nobody/nothing or a mix of these possibilities.</para>
          <para>Perceptions system transports low level information. Players can convert these low
          level information into high level information by themselves, because they are able to
          think and deduce. We aren't able to make bots really think. So we introduce the Events
          system which transports high level information: bots can react to Events. Players can
          also take part of the info contained in Events (but they obviously are free to react or
          not).</para>
        </glossdef>
      </glossentry>
    </glosslist>

    <para>An Event contains only data (not the references on data): real info can be
    modified after an Event happen, and somebody who knows about the Event doesn't
    necessarily know about the change. Moreover an Event can contain false/wrong data
    (transmission error, lie, etc).</para>
</sect1>

<sect1>
<title>Events system</title>
  <para>Events can be produced (thrown) by several ways, as we said in the
  <link linkend="event">Event section</link>.</para>

  <para>The "patient zero" could learn the info
    <itemizedlist>
      <listitem><para>directly (rare case)
                <example><title>God of War</title>
                <para>The God of War is unhappy and asks for more blood. All his believers
                will be directly notified (because he's an omnipotent god).</para>
                </example>
      </para></listitem>
      <listitem><para>as a direct witness (transported with a Stimulus)
                <example><title>The robbery</title>
                <para>Raoul is attacked by a robber. The clients of the bakery and he
                know a robbery happened.</para>
                </example>
                <example><title>The king</title>
                <para>The king makes a speech and announces new trade agreements with an
                other kingdom. All the crowd knows about this event.</para>
                </example>
      </para></listitem>
      <listitem><para>could be the source of the Event
                <example><title>Lier</title>
                <para>Sedecias launch false rumour on Raoul: the baker is a murderer.
                The false Event'll propagate.</para>
                </example>
                <example><title>Pyromaniac</title>
                <para>The pyromaniac knows that he burns the forest.</para>
                </example>
      </para></listitem>
    </itemizedlist>
  </para>

  <para>There are two ways to diffuse them:
    <itemizedlist>
      <listitem><para>through Items: Items can be used to transport information
                (tape recorder, letter, CD, marble tablet, book, computer, ...)</para>
      </listitem>
      <listitem><para>through Creatures: Creatures can talk, gossip, lie, etc.</para>
    </itemizedlist>
  </para>

  <sect2>
  <title>Direct transmission</title>
    <para>The direct transmission (Controllers are directly noticed) relies on EventsDispatchers.</para>
    <para>Events are transmitted only to Entities which ask for them (so which can interpret them).</para>
    <para>Some Entities (like gods) are allowed to produce an Event and send it to an EventsDispatcher.
    Everybody can receive Events by registering for some Events type to an EventsDispatcher (the faithful).</para>
    <para>This way implies nothing about perception.</para>
    <warning><para>Events reception should be logical or at least plausible... So somebody
    should have good reasons to listen to Events.<para></warning>
  </sect2>

  <sect2>
  <title>Transmission via perceptions</title>
    <para>The source of the Event'll send Stimuli to the StimuliDispatcher (and to the EventsDispatcher).
    The Event is sent linked with these Stimuli.</para>
    <para>The StimuliDispatcher'll propagate these Stimuli+Event. As for Stimuli, Events can be
    not understood or misunderstood. The receiver can reemit what it perceived (can be used for rumours,
    reports, info diffusion, etc).</para>
    <para>A Event can be linked to zero, one or more Stimuli. A Stimulus can be linked to
    zero, one or more Events.</para>

    <example>
    <title>Dead man</title>
      <para>"You see a dead man."</para>
      <para>A 'death' Event is linked to the visual Stimulus, so the Entity can 'manage'
      this death and reacts logically (burying, stealing, doing nothing, spit on
      its enemy corpse, cry on its mother corpse, call the police, start
      investigation, etc.</para>
    </example>

    <example>
    <title>The sleeping man</title>
      <para>You see a sleeping man and you make a mistake.</para>
      <para>A wrong 'death' Event is linked to the visual Stimulus. You'll probably be
      surprised if you try to steal the man. If you go to the police, you'll repeat
      what you see (Stimulus + Event)</para>
    </example>
  </sect2>

  <sect2>
  <title>Transmission via Items</title>
    <para>The Event is linked to some Item (a media in fact). If an Entity is able to read
    the content of the media, he/she/it can learn the Event.</para>
    <para>To have the Item is not enough: few people can read a CD-ROM just by touching it
    and sensing the holes on its surface...</para>
    <para>Moreover content can be ciphered or incomprehensible for the Entity (unknown
    language, unknown domain, etc).</para>
    <para>So Creatures can exchanged info by writing letters, by calling, etc.</para>
  </sect2>

  <sect2>
  <title>Transmission via Creatures</title>
    <para>Cf Memory-RFC for rumours mechanism</para>
  </sect2>

  <sect2>
  <title>EventsDispatcher</title> 
    <para>The EventsDispatcher has two roles: to log all Events and to relay some of these Events.</para>
    
    <para>All Events are sent to the EventsDispatcher (and some to a StimuliDispatcher).</para>
    <para>Some Entities could subscribe to an EventsDispatcher. Enrolment is a way to say "I
    want to be informed of Events types A, B and C." You don't declare what you plan to generate
    but only what you wish to receive.</para>
  </sect2>
</sect1>

<sect1>
<title>More examples</title>
  <example>
  <title>The pyromaniac's return</title>
    <para>GrosBill burns a forest.
      <orderedlist>
        <listitem><para>Goddess of Nature sends clerics (with maces) to teach him he's a
        bad bad guy. (twice direct transmission twice)</para></listitem>
        <listitem><para>Newspapers talks about. (witnesses report to some journalists)</para></listitem>
        <listitem><para>King sends guards to catch him. (witnesses report to the King + mission)</para></listitem>
        <listitem><para>Ecosystem is modified, weather is modified. (the local Place receives the Event
        and modifies the weather)</para></listitem>
      </orderedlist>
    </para>
  </example>

  <example>
  <title>A robbery again</title>
    <para>A robbery happens in a temple, so an Event is thrown.
      <itemizedlist>
        <listitem><para>Bad example: Event is received by guards, so they go to the temple.
        How can we explain they know such an info?</para></listitem>
        <listitem><para>Good example: Event is received by the temple goddess, so she can cast
        a malediction on guilties.</para></listitem>
        <listitem><para>Another good example: in fact, robbers triggered a magic alarm. A bipper
        sounds at the guard post, so guards go to the temple.</para></listitem>
      </itemizedlist>
    </para>
  </example>

  <example>
  <title>I'm a god</title>
    <para>For a player: You see a marvellous woman, dressed in white. She's incredibly
    beautiful and can't be at all a simple woman. She's too perfect. And moreover,
    there is a golden aura around her.</para>
    <para>For a bot: 'divine presence' Event</para>
  </example>

  <example>
  <title>Long live the King!</title>
    <para>For a player: You read the newspaper and discover during the night the King
    is dead.<para>
    <para>For a bot: 'famous person death news' Event</para>
  </example>

</sect1>

<sect1>
<title>Why Events?</title>
  <para>Advantages are flexibility, extensibility, its commonly use in very famous
  projects (X11, window managers, etc). It's quite simple too.</para>

  <para>Drawback is overload for the Game, but we need these features...</para>

  <para>For us, it has some other advantages, such as providing a AI management for Bots
  (to simulate perceptions understanding and reactions) and a dynamic game (by
  managing some laws and some actions/reactions).</para>
</sect1>

<sect1>
<title>Events vs Stimuli?</title>

  <para>Read the Perceptions-RFC, for more info on Stimuli and Perception system.</para>

  <para>Stimulus concept is more Player-oriented, and Event concept is more
  Bot-oriented. It's really easy for a Player to interpret Stimuli, but it will be
  really hard to do complete Stimuli recognition for Bots. It would be far too
  intricated to try to make the bots realize there is an aggression when they
  receive a scream stimulus for example: there could be an aggression without a
  single scream, and there could be a scream without an aggression. To determine
  that, the bot would have to process a lot of other stimuli which would perhaps
  not be available. Each time, it would be like trying to put together the pieces
  of a puzzle, and that would be too difficult and too long. Events make the
  situation much easier to handle. That's why many Events are more specifically
  for Bots (they can be used indirectly for Players too).</para>

</sect1>

<!-- Need to be reworked too -->
<sect1>
<title>Events types</title>
  <para>This list is NOT exhaustive. It will be complete as soon as we have new strange
  ideas to put in.</para>

  <para>We have chosen a hierarchical order. If something can be classified in several
  branches, several Events will be produced.</para>

  <para>We choose not to detail too much: such a list is part of the game instance,
  not of the framework. We won't detail PlayerEvents into PlayerEntranceEvent,
  PlayerLeavingEvent, PlayerDeletionEvent, PlayerBanningEvent, PlayerIdleEvent,
  etc. Some instances can, for example, propose a chat between Players and use
  Events to manage it.</para>

  <sect2>
  <title>WeatherEvents</title>
    <para>WeatherEvents represent changes in the weather. They are local to one Place.</para>
    <itemizedlist>
      <listitem><para>TemperatureEvents (increase, decrease, etc)</para></listitem>
      <listitem><para>PrecipitationEvents (dryness, normal, etc)</para></listitem>
      <listitem><para>PressureEvents (low, normal, high, etc)</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>TimeEvents</title>
    <para>TimeEvents represent the course of time. They are local to one World. They are
    thrown by the Game timer.</para>
    <itemizedlist>
      <listitem><para>DayEvents (today is a next day)</para></listitem>
      <listitem><para>MonthEvents (today begins a new month)</para></listitem>
      <listitem><para>YearEvents (today begins a new year)</para></listitem>
      <listitem><para>SeasonEvents (today begins a new season)</para></listitem>
      <listitem><para>TideEvents (rising/ebb/low/high tide)</para></listitem>
    </itemizedlist>
  </sect2>
    
  <sect2>
  <title>CosmologicalEvents</title>
    <para>CosmologicalEvents represent changes in the World that are due to cosmos.</para>
    <itemizedlist>
      <listitem><para>SunEvents (sunset, zenith, sunrise)</para></listitem>
      <listitem><para>SatelliteEvents (moonset, moonrise)</para></listitem>
      <listitem><para>StarEvents (evolution far in the sky)</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>EcologicalEvents</title>
    <para>EcologicalEvents represent major changes in the Ecology domain.</para>
    <itemizedlist>
      <listitem><para>DisasterEvents (pollution, flood, tsunami, etc)</para></listitem>
      <listitem><para>SpeciesEvents (species birth, species death)</para></listitem>
      <listitem><para>PlaceEvents (major changes in a Place (desert became plain))</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>PoliticalEvents</title>
    <para>PoliticalEvents regroup changes in politics.</para>
    <itemizedlist>
      <listitem><para>FunctionEvents (elections, putsches, death, etc)</para></listitem>
      <listitem><para>RelationEvents (treaties, negotiations, etc)</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>EcosystemEvents</title>
    <para>EcosystemEvents represent changes in a local ecosystem.</para>
    <itemizedlist>
      <listitem><para>FloraEvents (growing, etc)</para></listitem>
      <listitem><para>FaunaEvents (Population increase, decrease, etc)</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>ReligiousEvents</title>
    <para>Events linked to Deities or Cults.</para>
  <itemizedlist>
    <listitem><para>DeityEvents (divine intervention, divine appearance, etc)</para></listitem>
    <listitem><para>CultEvents (celebrations, etc)</para></listitem>
  </itemizedlist>
  </sect2>

  <sect2>
  <title>MagicalEvents</title>
    <para>Events linked to magic</para>
  </sect2>

  <sect2>
  <title>JusticeEvents</title>
    <para>Events linked to justice</para>
    <itemizedlist>
       <listitem><para>IllegalActionEvents (to steal, to rape, to kill, etc)</para></listitem>
       <listitem><para>JusticeCourtEvents (judgements, etc)</para></listitem>
    </itemizedlist>
  </sect2>

  <sect2>
  <title>MilitaryEvents</title>
    <para>Events linked to armies (wars, fights, etc)</para>
  </sect2>

  <sect2>
  <title>EconomicalEvents</title>
    <para>Events linked to Economy (Stock Exchange evolution, products prices evolution, etc)</para>
  </sect2>

  <sect2>
  <title>CreatureEvents</title>
    <para>Events linked to Creatures (birthday, death, etc)</para>
  </sect2>

  <sect2>
  <title>PlaceEvents</title>
    <para>Events linked to activity in a Place (building, etc)</para>
  </sect2>

  <sect2>
  <title>ItemEvents</title>
    <para>Events linked to Items</para>
  </sect2>

</sect1>

</article>