Weird snakes

ckb

Minion
Staff member
Looking for snakes, I did this:
foreach mm in $monsters[] if (contains_text(mm.attributes,"SNAKE")) print(mm);

And it gave me this:

Batsnake
Burning Snake of Fire
The Frattlesnake
Frozen Solid Snake
The Snake With Like Ten Heads
Snakeleton
The Frattlesnake
The Snake With Like Ten Heads

Trouser Snake
aggressive grass snake
bacon snake
black adder
coal snake
diamondback rattler
frontwinder
king snake
licorice snake
mutant rattlesnake
prince snake
rock snake
sewer snake with a sewer snake in it
snake
snakefire in the grass
tomb asp
whitesnake
Returned: void

Why do those 2 snakes (emphasis mine) appear twice?
 

Veracity

Developer
Staff member
Code:
boolean[monster] seen;
boolean[monster] duplicates;
foreach mm in $monsters[] {
    if ( seen[mm] ) {
	print(mm);
	duplicates[mm] = true;
    }
    seen[mm] = true;
}
print( count(duplicates) );
yields:

Code:
[color=green]> mm.ash[/color]

The Abominable Fudgeman
The Aquaman
The Author
The Avatar of Boris
The Avatar of Jarlsberg
The Avatar of Sneaky Pete
The Barrelmech of Diogenes
The Bat in the Spats
The Beefhemoth
The Big Wisniewski
The Clownlord Beelzebozo
The Colollilossus
The Cray-Kin
The Emperor
The Frattlesnake
The Free Man
The Fudge Wizard
The Headless Horseman
The Hermit
The Icewoman
The Inquisitor
The Jokester
The Krampus
The Landscaper
The Large-Bellied Snitch
The Lavalier
The Luter
The Mad Libber
The Man
The Mariachi With No Name
The Master Of Thieves
The Mastermind
The Nuge
The Plumber
The Rain King
The Sagittarian
The Server
The Sierpinski brothers
The Silent Nightmare
The Snake With Like Ten Heads
The Temporal Bandit
The Terrible Pinch
The Thing with No Name
The Thorax
The Unkillable Skeleton
The Unkillable Skeleton (Hard Mode)
The Unknown Accordion Thief
The Unknown Disco Bandit
The Unknown Pastamancer
The Unknown Sauceror
The Unknown Seal Clubber
The Unknown Turtle Tamer
The Whole Kingdom
The ghost of Ebenoozer Screege
The ghost of Jim Unfortunato
The ghost of Lord Montague Spookyraven
The ghost of Richard Cockingham
The ghost of Sam McGee
The ghost of Vanillica "Trashblossom" Gorton
The ghost of Waldo the Carpathian
the Crimborg
the abstract concept of poverty
the darkness (blind)
the former owner of the Skeleton Store
the ghost of Monsieur Baguelle
the ghost of Oily McBindle
the ghost of Phil Bunion
the gunk
the most embarrassing moment in your entire life
the realization that everyone you love will die someday
70
Looks like all the monsters that start with "the" or "The"
 

Veracity

Developer
Staff member
type.allValues() does this for $monsters[]:

Code:
		case DataTypes.TYPE_MONSTER:
			this.addValues( list, MonsterDatabase.entrySet() );
MonsterDatabase.entrySet() does this:

Code:
		return MonsterDatabase.MONSTER_DATA.entrySet();
MONSTER_DATA has this little feature:

Code:
					if ( keyName.toLowerCase().startsWith( "the " ) )
					{
						// Some effects seem to sometimes remove The from the start of the monster name even if normally part of name
						// eg. ELDRITCH HORROR Master Of Thieves
						// So allow finding monster without the 'The' also
						MonsterDatabase.MONSTER_DATA.put( keyName.substring( 4 ), monster );
						MonsterDatabase.OLD_MONSTER_DATA.put( keyName.substring( 4 ).toLowerCase(), monster );
					}
So, all "the" monsters appear twice in MONSTER_DATA - once with "the" and once without. Both point to the same MonsterData object.

Looks like when use the entryset to generate allValues, we should only use each MonsterData once. Or, perhaps we should just use the values(). ASH is the only user of MonsterDatabase.entrySet().
 

Veracity

Developer
Staff member
Yeah. When I make that change, your example does this:

Code:
[color=green]> ashq foreach mm in $monsters[] if (contains_text(mm.attributes,"SNAKE")) print(mm);[/color]

aggressive grass snake
bacon snake
Batsnake
black adder
Burning Snake of Fire
coal snake
diamondback rattler
frontwinder
Frozen Solid Snake
king snake
licorice snake
mutant rattlesnake
prince snake
rock snake
sewer snake with a sewer snake in it
snake
snakefire in the grass
Snakeleton
The Frattlesnake
The Snake With Like Ten Heads
tomb asp
Trouser Snake
whitesnake
Interesting. For some reason I used a TreeSet, rather than a HashSet, and the monsters are now in alphabetical order since, it seems, MonsterData objects sort by the monster name ignoring case...
 

zarqon

Well-known member
Also ckb, just in case you weren't already aware, you can also check sub_types:

> ash foreach m in $monsters[] if (m.sub_types contains "snake") print(m);

aggressive grass snake
bacon snake
Batsnake
black adder
Burning Snake of Fire
coal snake
diamondback rattler
frontwinder
Frozen Solid Snake
king snake
licorice snake
mutant rattlesnake
prince snake
rock snake
sewer snake with a sewer snake in it
snake
snakefire in the grass
Snakeleton
The Frattlesnake
The Snake With Like Ten Heads
tomb asp
Trouser Snake
whitesnake
Returned: void
 
Top