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;
}
|