TaleSpire Dev Log 447
Hi folks.
Today, I continued with the dice engine.
For those who didn’t see yesterday’s post, here is a warning:
GMs, Players, and even implementors of rule systems will not have to deal with the things I’m talking about below. The code gubbins I’ll be showing is for the underthehood implementation that will make the nice, userfriendly stuff work.
Currently, the available operations in the language are:
Math:
+

=
>
>=
<
<=
abs
floor
ceil
round
*
/
expt
mod
remainder
Functions and specialforms:
dice  Creates a dice set
roll  Puts the dice passed to this function into the dice tray for a user to roll
sort  sorts dice based on their score given a userprovided predicate
taken  make a new diceset containing the first N dice from another diceset
takeif  make a new diceset containing any dice from the given diceset that satisfy a predicate
dropif  make a new diceset without any dice from the given diceset that satisfy a predicate
highface  return the 'highest' face for a given die (e.g. 6 for a d6)
lowface  return the 'lowest' face for a given die (e.g. 1 for a d6)
count  returns the number of dice in a diceset
show  Push an entry into the dice history
let  for lexically defining variables and functions
if  it's a conditional
recurse  for calling the function you are in, only works from the tail position
This allowed me to implement:
 various kinds of exploding dice
 fate dice
 rerolling on various criteria
 more complete math functionality
 counting the number of dice that satisfied some criteria
Many of the functions support dicesets as well as numbers, so 2d6+5 would compile to (+ (roll (dice d6 2)) 5)
.
It’s going rather well. Next on the todolist, I’d like to implement currying, clean things up, and start implementing the compiler.
I’m also considering using fixedpoint math instead of floats, and I’m looking into combining recursion with rerolls[0].
This will have to wait as I really need to do some work for TitanCraft tomorrow. They’ve been waiting patiently for me to sort out some bugs, and this week has gotten away from me.
We’ll get back to dice by the middle of next week for sure.
Disclaimer: This DevLog is from the perspective of one developer. So it doesn’t reflect everything going on with the team
[0] This sounds weird. However, we don’t want infinite loops, and this would mean the code would always yield to the user so they can cancel the roll if it goes on for too long.
CedrychSkye
UserCedrychSkye
User ·Baggers
Baggers
·