Of Moose and Men, well Class really!

I left off on my last post stubbing in a little code to take care of loading my 'Player Class' (Fighter, Thief etc) into my 'Character' class. I did mention that there are some real subtle rules, I will look at just one of them.

Unfortunately 'Mordol the Moose' rolled a '1' and failed his 'Saving Throw' vs traps and ended up like this;

moose_fail.jpg

Like 'Player Class' at first glance it looks very simple thing to do '4 Player Classes' and '5 types of saving throws' for each. Well what happens if you player is 'Mutil-Classed' such as 'Gutboy Barlehouse' a 9th/8th level Dwarf Fighter/Thief. In the game saving throws for a muti-classed player always use the most favorable result from the tables. So there are times when 'Gutboy' saves as a thief or saves as a fighter.

Anyone else get personal URL from Google Plus?

Back in about September Google Plus send me an email offering:

google.com/+RonSavage

as my entry point into Google Plus. I.e.: That visible text is all I need to type into Chrome or FF.

Also, you can use this text (instead of your long Google id digit string) when indicating you're a contributor to MetaCPAN, etc.

So, did anyone else get such an offer?

Perl Reverse Dictionary / Hash

I translated Perl Reverse Dictionary / Hash

Perl Reverse Dictionary / Hash

Planet Moose - December 2013

Happy new year, and welcome to Planet Moose, a brief write up on what's been happening in the world of Moose in the past month, for the benefit of those of you who don't have their eyes permanently glued to the #moose IRC channel, or the MetaCPAN recent uploads page.

If you'd like to contribute some news for next month's issue, you can do so on the wiki.

Perl Advent Calendar

There were a handful of Moose/Moo-related articles in the 2013 Perl Advent Calendar:

If 'at is a moose Ah woods hate tae see a rat

In my last D&D post I had at least the first problems worked out for Character race. Now I think I will move into the most challenging of all the 'Class' of a character.

In D&D a 'Class' is the role (JOB) a character plays in the game ie fighter, thief, mage etc. There are 5 primary Classes and 5 sub classes which is easy enough to model with Moose a 'Role' for each of the 10 and we are done.

5509980361_487e13de4c_b.jpg

Unlike the epic adventures above a character's 'Class' is not that easy to nail down. The rules around class are a mix subtle complexities, there may be only 5 basic 'Character' 'Classes' for 'Players' and 'NPCs' but each Character falls into one of these types

  • NPC with no class ie (0 level human farmer, Halfling barkeep, etc)
  • NPC or Player with a single class (Fighter, MU, Cleric)
  • NPC or Player with multi-classes (Fighter/MU, Cleric/Assassin)
  • NPC or Player with two Classes (Fighter-MU, Cleric-Fighter)

Sereal v2 Finally Released as Stable

Just now, I've uploaded three distributions to PAUSE: Sereal-Encoder-2.01, Sereal-Decoder-2.01, and Sereal-2.01.

This means that version 2 of the Sereal serialization protocol is finally considered public, stable, and ready for production use. There was a long article about Sereal v2 on the Booking.com blog a few months ago. Since then, at least one major new feature was added to Sereal version 2: Object serialization hooks (FREEZE/THAW). Let me summarize the two major user-visible new features.

The perils of & (and prototypes too!)

In a recent post, Chris K asks, why do I recommend using function() rather than &function() or &function. I happened to see it right before heading to bed, but I wanted to respond, so who knows if this is a good example or not. Anyway here goes, look at this code (seen below if you have javascript), it prints 6 lines, do you know what they will be?

Subroutine Calling Conventions

Hello everyone.

In trying to find places that I might be able to exchange links to get traffic to my tutorial site, I found an article about how one should determine if a tutorial is good. One of the things that they mention is that a tutorial that teaches

&subname()

as a valid subroutine calling convention is out of date. It continues to explain that this does do something, but not what people think it does.

As a matter of fact, I just finished writing a major tutorial on subroutines myself last night. I have looked at numerous resources, all of which say

&subname;
(I know that's slightly different, but similar enough to cause alarm) and
subname ()

are both acceptable. I looked again today, and found the same information. So could someone please clear this up...what (if any) difference is there between these two conventions, and am I making some major mistake if I write tutorials with the ampersand method?

God hath given you one face and you make yourselves another.

In the continuing story of Moose and D&D I left off with what I think was a slick use of Moose:Util to load in a Character's race.

As all long term D&D players now you will eventually run into a player who says the following;

image013.jpg

Well in my present 'Character' class I allow this as my race is just a string.


  has 'race' =>(
	is		=>'ro',
	isa		=>'Str',
);

So this post will look into how to handle this sort of sin against nature.

In the old days it was simple, each race was a class and if you tried something like this

Eating my own dogfood (parallel tests)

I'm relatively pleased with my work in creating parallel testing with Test::Class::Moose, but I wanted to make sure that it worked with a real world example, so today I took a small, but real test suite and converted it and tried out my parallel testing code. The results were interesting.

Resolving non-perl dependencies for perl modules in Debian/Ubuntu

One of the things developers often struggle with is dependency resolution.

For example:
cpanm WWW::Curl::Easy -v

.....

Configuring WWW-Curl-4.15 ... Locating required external dependency bin:curl-config... missing.

Unresolvable missing external dependency.

Please install 'curl-config' seperately and try again.

NA: Unable to build distribution on this platform.

A framework for Alien modules (the Alien2 Manifesto)

The purpose of Alien modules is to provide external libraries or other dependencies for CPAN packages. This Alien2 Manifesto updates the original Alien module description based on practical lessons from existing Alien module implementations and some perceived limitations.

The original Alien manifesto provided the idea but not a framework for how modules in the Alien namespace were to work. The plan was to "let evolution work for us and see what individual Alien packages need and then eventually factor it out". We are now more than 10 years after this first proposal and there are now some lessons to be learned from current implementations of Alien modules. Let's start with a review of the responsibilities of an Alien module and some observations.

On installation, make sure the required package is there, otherwise install it.

This is the main purpose of Alien modules, to provided external library or program dependencies needed for CPAN modules installation and operation.

Looking for Moose in all the Wrong Places

In my last post I again ending up like poor Keith Haring in his picture below.

13-Ptgintocorner04.jpg

I programmed what I wanted but it was beginning to look like the same stuff I started with.

So playing around a bit I remembered that Moose has the before, after and around Method Modifiers that work like DBI's callbacks that some of you might remember form one of my earlier posts. The great thing about these is that can be used from inside a role for code outside the role as long as the code is referenced in a 'requires'.

So I to move the max values out of the Character class and into the Dwarf role I gave this a shot

Perl and Me, Part 4: A Worthy Program, Exceedingly Well Read

This is part 4 of an ongoing series where I explore my relationship with Perl.  You may wish to begin at the beginning.

This week we look at code legibility.

Last week I talked about why Moose is important to my journey as a Perl programmer, and where I feel that it could be even better.  I concluded that it all comes back to code legibility. 

Perl Reverse Dictionary/Array

I have translated "Perl Reverse Dictionary/Array".

Perl Reverse Dictionary/Array

Graphics::Potrace

A few months ago I released Graphics::Potrace, that provides Perl bindings to the potrace library. So, if you want to convert rasters into vectors from Perl... you know where to go.

Thou yeasty elf-skinned baggage!

With my last post I managed to apply a role to an instance of a class. What I think this will allow me to do is keep my base 'classes' from sprawling out of control while also encapsulation a good number of Game Rules' (or Biz Rules) in to small parts that I can easily reuse.

So far it has handled things quite well and even taught me a few things and I think has really exposed what Roles can do in Moose. Now as my D&D story moves along I am about to jump into what I think is going to be the to big test for Moose.

Character Races??

The differing races bring a new level of complexity to the game, well except mundane old humans who, unlike the other races, get no extra abilities, bonuses, penalties or alike.

Any Perl code for circular dendrograms?

As seen here.

The vague plan is to write a front-end to GraphViz2 (which is a front-end to Graphviz) to do this sort of stuff, unless someone beat me to it.

And yes, I know Graphviz contains 'twopi'.

TIA.

Change Counting Problem - Feedback Requested

There's a common programming challenge where you write a program to take a dollar amount from the user, and then return the simplest way to create that amount with only coins (using the fewest coins possible). I took a crack at this a while back, and I would like to know if there are ways it could be improved or if you would have done it differently.

Merry Christmas! Parallel testing with Test::Class::Moose has arrived

You'll want to checkout the forks branch to see it in action. Read the docs for Test::Class::Moose::Role::Parallel to see how to use it (you'll probably need to create your own schedule).

What follows is a very naïve benchmark where I reduced a 12 minute test suite down to 30 seconds.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.