So I’m attempting a game with some fairly active npcs, and a piece of code in my game goes:
Every turn:
Repeat with currentactor running through people who are not the player:
[currentactor does a bunch of stuff]
But I was wondering if there was a way to run through people in random (or even just changing) order, because otherwise the characters all act in the exact same order each turn. Is there an easy way to do this, or am I going to have to rethink my whole method?
Every turn:
let X be the list of people;
sort X in random order;
repeat with currentactor running through X:
if currentactor is not the player: ...
or even:
Every turn:
let X be the list of people that are not the player;
sort X in random order;
repeat with currentactor running through X: ...
or, if you want more flexibility:
Definition: a person is other if it is not the player.
Every turn:
let X be the list of other people;
sort X in random order;
repeat with currentactor running through X: ...