diff options
author | Griffin Smith <root@gws.fyi> | 2019-09-28T17·20-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-09-28T19·03-0400 |
commit | 1a0f618a829ec356e29176c77ea90a8a5a0157b4 (patch) | |
tree | 90d255974b482f6d59dd26a503d28e7adb090188 /src/Xanthous/Entities/Environment.hs | |
parent | 915264acae35e71f79c6193d022baa2455d880d3 (diff) |
Implement the start of creature AI
Add a Brain class, which determines for an entity the set of moves it makes every step of the game, and begin to implement that for gormlaks. The idea here is that every step of the game, a gormlak will move towards the furthest-away wall it can see.
Diffstat (limited to 'src/Xanthous/Entities/Environment.hs')
-rw-r--r-- | src/Xanthous/Entities/Environment.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Xanthous/Entities/Environment.hs b/src/Xanthous/Entities/Environment.hs index 4ef67a577dbb..e8190cd42a92 100644 --- a/src/Xanthous/Entities/Environment.hs +++ b/src/Xanthous/Entities/Environment.hs @@ -13,7 +13,15 @@ import Brick (str) import Brick.Widgets.Border.Style (unicode) import Brick.Types (Edges(..)) -------------------------------------------------------------------------------- -import Xanthous.Entities (Draw(..), entityIs, Entity(..), SomeEntity) +import Xanthous.Entities + ( Draw(..) + , entityIs + , Entity(..) + , SomeEntity + , Brain(..) + , Brainless(..) + , brainVia + ) import Xanthous.Entities.Draw.Util import Xanthous.Data -------------------------------------------------------------------------------- @@ -22,6 +30,9 @@ data Wall = Wall deriving stock (Show, Eq, Ord, Generic, Enum) deriving anyclass (CoArbitrary, Function) +-- deriving via Brainless Wall instance Brain Wall +instance Brain Wall where step = brainVia Brainless + instance Entity Wall where blocksVision _ = True description _ = "a wall" @@ -64,6 +75,9 @@ instance Draw Door where horizDoor = '␣' vertDoor = '[' +-- deriving via Brainless Door instance Brain Door +instance Brain Door where step = brainVia Brainless + instance Entity Door where blocksVision = not . view open description _ = "a door" |