Results 1 to 7 of 7

Thread: Weird snakes

  1. #1
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    906

    Default Weird snakes

    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?

  2. #2
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,002

    Default

    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:
    > mm.ash
    
    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"

  3. #3
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    906

    Default

    Looks like all the monsters that start with "the" or "The"
    Originally Posted by Veracity View Post
    That is interesting. Do you know why?

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,002

    Default

    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().

  5. #5
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,002

    Default

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

    Code:
    > ashq foreach mm in $monsters[] if (contains_text(mm.attributes,"SNAKE")) print(mm);
    
    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...

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,002

    Default

    Revision 19089

  7. #7
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,675

    Default

    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
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •