I was wrong in saying that the RNG was faster with 0, this is not assembler shifted in perl. The system was made on FreeBSD 11.0 and Debian GNU/Linux. Now I've tried to make some main characters by rewriting the Deity class :
package HollyGameAI::MutualExclusiveDeityAI; our @ISA = "MutualExclusiveAI"; sub MutualExclusiveDeityAI { my $class = shift; my $self = $class->SUPER::MutualExclusiveAI(@_); bless $self, ref($class) || $class; }
Here are some examples for use as Deities for the main character _NOTE_ however that I do not know how to override the Factory with inherited methods inside the MutualExclusiveAI class, I cannot repost however with that as a question (the clue of the post however) :
package HollyGameAI::MutualExclusiveAI; use lib "../HollyGameAI"; use Factory; sub MutualExclusiveAI { my ($class) = shift; my $self = { aiclass => HollyGameAI::Factory->Factory(@_) }; bless $self, ref($class) || $class; }
Here are Moradin and Umberlee classes based on the system :
package HollyGameAI::Umberlee; our @ISA = "MutualExclusiveDeityAI"; sub Umberlee { my $class = shift; my $self = $class->SUPER::MutualExclusiveDeityAI(qw(swim empow +er)); bless $self, ref($class) || $class; }
package HollyGameAI::Moradin; our @ISA = "MutualExclusiveDeityAI"; sub Moradin { my $class = shift; my $self = $class->SUPER::MutualExclusiveDeityAI(qw(empower)); bless $self, ref($class) || $class; }
Here is a better RNG, the meaning of the superfluous sets is to use the roll previous method without shifting in :
package HollyGameAI::RNG; ### Random Number God, dice class sub RNG { my $class = shift; my $self = { dx => 0 }; return bless $self, ref($class) || $class; } sub set { my ($self, $dxx) = @_; $self->{dx} = $dxx; } sub rollDX { my $self = shift; return rand($self->{dx}); } sub rollD1 { my $self = shift; return rand(1); } sub rollD3 { my $self = shift; return rand(3); } sub rollD6 { my $self = shift; return rand(6); } sub rollD10 { my $self = shift; return rand(10); } sub rollD20 { my $self = shift; return rand(20); } sub rollPreviousDX { my $self = shift; return rand($self->{dx}); } sub roll { my ($self, $dxx) = @_; $self->set($dxx); given ($self->{dx}) { when ($_ = 0) { return 0; } when ($_ == 1) { return rollD1; } when ($_ == 3) { return rollD3; } when ($_ == 6) { return rollD6; } when ($_ == 10) { return rollD10; } when ($_ == 20) { return rollD20; } } return 0; }

In reply to Re^3: A small Deity AI class system by holyghost
in thread A small Deity AI class system by holyghost

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.