diff --git a/src/the_great_game/agent/agent.clj b/src/the_great_game/agent/agent.clj index 7a17103..7d3f999 100644 --- a/src/the_great_game/agent/agent.clj +++ b/src/the_great_game/agent/agent.clj @@ -1,7 +1,43 @@ (ns the-great-game.agent.agent - "Anything in the game world with agency") + "Anything in the game world with agency" + (:require [the-great-game.objects.object :refer [ProtoObject]] + [the-great-game.objects.container :refer [ProtoContainer]])) ;; hierarchy of needs probably gets implemented here ;; I'm probably going to want to defprotocol stuff, to define the hierarchy ;; of things in the gameworld; either that or drop to Java, wich I'd rather not do. +(defprotocol ProtoAgent + "An object which can act in the world" + (act + [actor world circle] + "Allow `actor` to do something in this `world`, in the context of this + `circle`; return the new state of the actor if something was done, `nil` + if nothing was done. Circle is expected to be one of + + * `:active` - actors within visual/audible range of the player + character; + * `:pending` - actors not in the active circle, but sufficiently close + to it that they may enter the active circle within a short period; + * `:background` - actors who are active in the background in order to + handle trade, news, et cetera; + * `other` - actors who are not members of any other circle, although + I'm not clear whether it would ever be appropriate to invoke an + `act` method on them. + + The `act` method *must not* have side effects; it must *only* return a + new state. If the actor's intention is to seek to change the state of + something else in the game world, it must add a representation of that + intention to the sequence which will be returned by its + `pending-intentions` method.") + (pending-intentions + [actor] + "Returns a sequence of effects an actor intends, as a consequence of + acting. The encoding of these is not yet defined.")) + +;; (defrecord Agent +;; "A default agent." +;; ProtoObject +;; ProtoContainer +;; ProtoAgent +;; ) diff --git a/src/the_great_game/objects/container.clj b/src/the_great_game/objects/container.clj new file mode 100644 index 0000000..80a18ce --- /dev/null +++ b/src/the_great_game/objects/container.clj @@ -0,0 +1,11 @@ +(ns the-great-game.objects.container + (:require + [the-great-game.objects.game-object :refer :all])) + +(defprotocol ProtoContainer + (contents + [container] + "Return a sequence of the contents of this `container`, or `nil` if empty.") + (is-empty? + [container] + "Return `true` if this `container` is empty, else `false`.")) diff --git a/src/the_great_game/objects/game-object.clj b/src/the_great_game/objects/game-object.clj new file mode 100644 index 0000000..25c878c --- /dev/null +++ b/src/the_great_game/objects/game-object.clj @@ -0,0 +1,19 @@ +(ns the-great-game.objects.game-object + "Anything at all in the game world") + +(defprotocol ProtoObject + "An object in the world" + (id [object] "Returns the unique id of this object.") + (reify-object + [object] + "Adds this `object` to the global object list. If the `object` has a + non-nil value for its `id` method, keys it to that id - **but** if the + id value is already in use, throws a hard exception. Returns the id to + which the object is keyed in the global object list.")) + +(defrecord GameObject + [id] + ;; "An object in the world" + ProtoObject + (id [_] id) + (reify-object [object] "TODO: doesn't work yet"))