1
7DRLs / Re: Rogmind - 7drl2016 - finished
« on: October 30, 2018, 12:10:06 AM »
Ok, here's the documentation
Each turn your golem votes on what action to perform and once impossible actions (like walking through a wall) are removed, the remaining action with the highest votes is chosen and executed (if multiple actions have the same amount of vote a random one is chosen).
Currently the only available action is moving in the eight cardinal directions:
movenorth
movenortheast
moveeast
movesoutheast
movesouth
movesouthwest
movewest
movenorthwest
And moving in the eight relative directions:
moveforward
moveforwardright
moveright
movebackright
moveback
movebackleft
moveleft
moveforwardleft
A vote on an action looks like this
increase <action> by <amount> <predicate>
or
decrease <action> by <amount> <predicate>
when the <predicate> is true the vote on <action> is increased or decreased by <amount>
For example to make the golem follow walls, you can give it this program
increase moveForward by 10
increase moveRight by 5
increase moveRight by 10 ( not walkable back ) or ( not walkable forward ) right
increase moveForward by 5 ( not walkable left ) or ( not walkable right ) forward
In an open space it moves forwards because forward has the highest vote.
When this is impossible it turns and moves right because right has the second highest vote.
The predicate ( not walkable left ) or ( not walkable right ) forward checks to see if the tile to the forward left is blocked or the tile to the forward right is blocked.
If moving right would leave it touching a wall (because either the forward right or backwards right tile is not walkable) then the vote on going right is increased to 15.
If moving forward would leave it touching a wall the the vote on going forward is increased to 15.
This means that it goes whichever way leaves it touching a wall.
And finally if all these directions are blocked the the golem goes in a random unblocked direction.
We don't have to stick with primitive actions, new actions that can be voted on are defined by
to <action name>
[<vote>]
so from then on you can increase of decrease <action name>
This multiplies all the votes in <action name>'s body by e to the amount of vote <action name> got.
This means you can choose to view the program as a kind of hand crafted neural network.
You can also use macros to reduce typing a little bit <macro name> is <macro body> replaces the macro name with its body within the rest of the program.
List of functions
Numeric
age : how long since you saw that location
distanceTo
- : negative
sign: sign of number
max
min
+ : add
- : subtraction
* : multiply
/ : divide
health
maxHealth
damage
speed
Boolean
immediately visible: only those tiles that are visible this turn
walkable: can you walk there
flyable
destructable: can the terrain be destroyed
opaque: can you not see through it
swimmable
named <name>: is there a creature plant item or terrain named <name> at that location
not
or
and
> : greaterThan
>= : greaterThanEqual
< : lessThan
<= : lessThanEqual
= : equal
!= : notEqual
hostile
friendly
neutral
walker
swimmer
flier
Directions
north
east
south
west
forward
right
back
left
Each turn your golem votes on what action to perform and once impossible actions (like walking through a wall) are removed, the remaining action with the highest votes is chosen and executed (if multiple actions have the same amount of vote a random one is chosen).
Currently the only available action is moving in the eight cardinal directions:
movenorth
movenortheast
moveeast
movesoutheast
movesouth
movesouthwest
movewest
movenorthwest
And moving in the eight relative directions:
moveforward
moveforwardright
moveright
movebackright
moveback
movebackleft
moveleft
moveforwardleft
A vote on an action looks like this
increase <action> by <amount> <predicate>
or
decrease <action> by <amount> <predicate>
when the <predicate> is true the vote on <action> is increased or decreased by <amount>
For example to make the golem follow walls, you can give it this program
increase moveForward by 10
increase moveRight by 5
increase moveRight by 10 ( not walkable back ) or ( not walkable forward ) right
increase moveForward by 5 ( not walkable left ) or ( not walkable right ) forward
In an open space it moves forwards because forward has the highest vote.
When this is impossible it turns and moves right because right has the second highest vote.
The predicate ( not walkable left ) or ( not walkable right ) forward checks to see if the tile to the forward left is blocked or the tile to the forward right is blocked.
If moving right would leave it touching a wall (because either the forward right or backwards right tile is not walkable) then the vote on going right is increased to 15.
If moving forward would leave it touching a wall the the vote on going forward is increased to 15.
This means that it goes whichever way leaves it touching a wall.
And finally if all these directions are blocked the the golem goes in a random unblocked direction.
We don't have to stick with primitive actions, new actions that can be voted on are defined by
to <action name>
[<vote>]
so from then on you can increase of decrease <action name>
This multiplies all the votes in <action name>'s body by e to the amount of vote <action name> got.
This means you can choose to view the program as a kind of hand crafted neural network.
You can also use macros to reduce typing a little bit <macro name> is <macro body> replaces the macro name with its body within the rest of the program.
List of functions
Numeric
age : how long since you saw that location
distanceTo
- : negative
sign: sign of number
max
min
+ : add
- : subtraction
* : multiply
/ : divide
health
maxHealth
damage
speed
Boolean
immediately visible: only those tiles that are visible this turn
walkable: can you walk there
flyable
destructable: can the terrain be destroyed
opaque: can you not see through it
swimmable
named <name>: is there a creature plant item or terrain named <name> at that location
not
or
and
> : greaterThan
>= : greaterThanEqual
< : lessThan
<= : lessThanEqual
= : equal
!= : notEqual
hostile
friendly
neutral
walker
swimmer
flier
Directions
north
east
south
west
forward
right
back
left