/// <summary> /// tell the pony to choose her next action and direction but only /// from her available passive actions. /// </summary> private PonyState DecideFromPassiveActions() { var choice = new PonyState { Action = ChoosePassiveAction(), Direction = ChooseDirection() }; return(choice); }
/// <summary> /// tell the pony to choose her next action and direction but only /// from her available passive actions. /// </summary> private PonyState DecideFromPassiveActions() { var choice = new PonyState { Action = ChoosePassiveAction(), Direction = ChooseDirection() }; return choice; }
/// <summary> /// allow the pony's personality to choose her next action and /// direction from any of her available actions. she is a free pony /// and you should never tell her otherwise. /// /// eventually this will be tweakable via the this.pony file for each /// pony to make them all unique to their own respective personalities. /// </summary> private PonyState DecideByPonyality() { var choice = new PonyState(); bool undecided = false; bool lazy = false; // if the pony is too tired then she should go to sleep. if she can // sleep, that is. if(this.Energy <= 0) { if(this.CanDo(PonyAction.Sleep)) { choice.Direction = this.Direction; // if she is doing something active, stop first instead of // just falling asleep in mid sprint. if(this.IsActive()) { choice.Action = this.DecideFromPassiveActions().Action; } else { choice.Action = PonyAction.Sleep; this.Energy = 400; } return choice; } else { // else just reset it. this.Energy = 400; } } do { choice.Action = this.ChooseAction(); choice.Direction = this.ChooseDirection(); undecided = false; /////////////////////////////////////////////////////////////// // directional choices //////////////////////////////////////// // direction choices are up for grabs every time a pony thinks // she had decided what to do. if she elects to be indecisive // about her actions later then she will rethink her direction // as well. // does the pony want to change directions? pony does not like // to change direction too often while performing actions. if(choice.Direction != this.Direction && !this.RandomChance(this.Ponyality.Spazziness)) { // if pony is doing something active and will continue to // do so then there is a higher chance she will not change // directions. if(this.IsActive() && Pony.IsActionActive(choice.Action)) choice.Direction = this.Direction; // if pony is doing something active and she suddenly stops // then this too will have a greater chance of not changing // directions. if(this.IsActive() && !Pony.IsActionActive(choice.Action)) choice.Direction = this.Direction; } /////////////////////////////////////////////////////////////// // action choices ///////////////////////////////////////////// // apply personality quirks to the pony's decision making // system to allow for subdued but unique behaviour. // don't ever do these. if(choice.Action == PonyAction.Sleep || choice.Action == PonyAction.Teleport2) { undecided = true; continue; } // if she has decided she is being lazy... if(lazy) { return this.DecideFromPassiveActions(); } // pony generally like be lazy. if she is doing somethng lazy // there is a greater chance she will not want to do something // active. if(!this.IsActive() && Pony.IsActionActive(choice.Action)) { if(this.RandomChance(this.Ponyality.Laziness)) { undecided = lazy = true; continue; } } // pony do not like to flaunt their personality quirks, if we // selected one of the personality actions then there is a high // chance she should be undecided. this should make the quirky // actions more special when they do actually happen. switch(choice.Action) { case PonyAction.Action1: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; case PonyAction.Action2: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; case PonyAction.Passive1: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; } // pony that can teleport generally do not teleport that often. i assume // the action takes mana or something, lol. if(choice.Action == PonyAction.Teleport) { if(this.RandomChance(30)) { undecided = true; continue; } } // pony may tire easy. if she is doing something active and has chosen to // continue to be active, there is a chance she is too tired and will be // lazy instead. if(this.IsActive() && Pony.IsActionActive(choice.Action)) { if(!this.RandomChance(this.Ponyality.Stamina)) { undecided = lazy = true; continue; } } } while(undecided); return choice; }
/// <summary> /// allow the pony's personality to choose her next action and /// direction from any of her available actions. she is a free pony /// and you should never tell her otherwise. /// /// eventually this will be tweakable via the this.pony file for each /// pony to make them all unique to their own respective personalities. /// </summary> private PonyState DecideByPonyality() { var choice = new PonyState(); bool undecided = false; bool lazy = false; // if the pony is too tired then she should go to sleep. if she can // sleep, that is. if (this.Energy <= 0) { if (this.CanDo(PonyAction.Sleep)) { choice.Direction = this.Direction; // if she is doing something active, stop first instead of // just falling asleep in mid sprint. if (this.IsActive()) { choice.Action = this.DecideFromPassiveActions().Action; } else { choice.Action = PonyAction.Sleep; this.EnergyReset(); } return(choice); } else { // else just reset it. this.EnergyReset(); } } do { choice.Action = this.ChooseAction(); choice.Direction = this.ChooseDirection(); undecided = false; /////////////////////////////////////////////////////////////// // directional choices //////////////////////////////////////// // direction choices are up for grabs every time a pony thinks // she had decided what to do. if she elects to be indecisive // about her actions later then she will rethink her direction // as well. // does the pony want to change directions? pony does not like // to change direction too often while performing actions. if (choice.Direction != this.Direction && !this.RandomChance(this.Ponyality.Spazziness)) { // if pony is doing something active and will continue to // do so then there is a higher chance she will not change // directions. if (this.IsActive() && Pony.IsActionActive(choice.Action)) { choice.Direction = this.Direction; } // if pony is doing something active and she suddenly stops // then this too will have a greater chance of not changing // directions. if (this.IsActive() && !Pony.IsActionActive(choice.Action)) { choice.Direction = this.Direction; } } /////////////////////////////////////////////////////////////// // action choices ///////////////////////////////////////////// // apply personality quirks to the pony's decision making // system to allow for subdued but unique behaviour. // don't ever do these. if (choice.Action == PonyAction.Sleep || choice.Action == PonyAction.Teleport2) { undecided = true; continue; } // if she has decided she is being lazy... if (lazy) { return(this.DecideFromPassiveActions()); } // pony generally like be lazy. if she is doing somethng lazy // there is a greater chance she will not want to do something // active. if (!this.IsActive() && Pony.IsActionActive(choice.Action)) { if (this.RandomChance(this.Ponyality.Laziness)) { undecided = lazy = true; continue; } } // pony do not like to flaunt their personality quirks, if we // selected one of the personality actions then there is a high // chance she should be undecided. this should make the quirky // actions more special when they do actually happen. switch (choice.Action) { case PonyAction.Action1: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; case PonyAction.Action2: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; case PonyAction.Passive1: undecided = !this.RandomChance(this.Ponyality.Quirkiness); continue; } // pony that can teleport generally do not teleport that often. i assume // the action takes mana or something, lol. if (choice.Action == PonyAction.Teleport) { if (this.RandomChance(30)) { undecided = true; continue; } } // pony may tire easy. if she is doing something active and has chosen to // continue to be active, there is a chance she is too tired and will be // lazy instead. if (this.IsActive() && Pony.IsActionActive(choice.Action)) { if (!this.RandomChance(this.Ponyality.Stamina)) { undecided = lazy = true; continue; } } } while(undecided); return(choice); }