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.
This commit is contained in:
parent
915264acae
commit
1a0f618a82
21 changed files with 493 additions and 281 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue