hearthbreaker icon indicating copy to clipboard operation
hearthbreaker copied to clipboard

'NoneType' object has no attribute 'game'

Open Ragowit opened this issue 9 years ago • 13 comments

Deck 1: Tinkmaster Overspark, Duplicate, Dancing Swords, Darkscale Healer, Silverback Patriarch, Novice Engineer, Shattered Sun Cleric, Stonesplinter Trogg, Harvest Golem, Gelbin Mekkatorque, Dragonling Mechanic, Water Elemental, River Crocolisk, War Golem, Frostwolf Warlord, Azure Drake, Dancing Swords, Cult Master, Ship's Cannon, Frostwolf Warlord, Stormpike Commando, Silvermoon Guardian, Frostwolf Grunt, Flamecannon, Flamecannon, Wisp, Murloc Raider, Chillwind Yeti, Defender of Argus, Razorfen Hunter

Deck 2: Ogre Brute, Counterspell, Force-Tank MAX, Vaporize, Frost Elemental, Stalagg, Stampeding Kodo, Ethereal Arcanist, Bloodmage Thalnos, Lil' Exorcist, Wisp, Flesheating Ghoul, Coldlight Seer, Gnomish Experimenter, Gnomish Inventor, Jeeves, Silver Hand Knight, Illuminator, Piloted Shredder, Gnomish Inventor, War Golem, Force-Tank MAX, Mogu'shan Warden, Stranglethorn Tiger, Blood Knight, River Crocolisk, Tauren Warrior, Wee Spellstopper, Abomination, Chillwind Yeti

Traceback (most recent call last):
  File "C:\Users\Ragowit\Documents\GitHub\mcts\hearthbreaker\uct.py", line 429, in GetMoves
    if card.can_use(self.game.current_player, self.game) and isinstance(card, MinionCard):
  File "C:\Users\Ragowit\Documents\GitHub\mcts\hearthbreaker\hearthbreaker\cards\base.py", line 491, in can_use
    return super().can_use(player, game) and self.name not in [secret.name for secret in player.secrets]
  File "C:\Users\Ragowit\Documents\GitHub\mcts\hearthbreaker\hearthbreaker\cards\base.py", line 103, in can_use
    return player.mana >= self.mana_cost(player)
  File "C:\Users\Ragowit\Documents\GitHub\mcts\hearthbreaker\hearthbreaker\cards\base.py", line 121, in mana_cost
    for p in self.player.game.players
AttributeError: 'NoneType' object has no attribute 'game'

Ragowit avatar Apr 15 '15 21:04 Ragowit

I'm having trouble replicating this one. I've tried 40000 games with these decks, and no problem so far.

danielyule avatar Apr 16 '15 12:04 danielyule

100 000 games and no error. I think this one is going to be hard to track down.

danielyule avatar Apr 16 '15 13:04 danielyule

Hmm, I will be home from work in about an hour. Will see if I can help out and replicate it.

Ragowit avatar Apr 16 '15 14:04 Ragowit

Well I must admit that it's rare, but I got it again. These were the decks this time.

Deck 1: Chillwind Yeti, Defender of Argus, War Golem, Imp Master, Stranglethorn Tiger, Duplicate, Novice Engineer, Silverback Patriarch, Novice Engineer, Silverback Patriarch, Mechanical Yeti, Jungle Panther, Duplicate, Oasis Snapjaw, Water Elemental, Dalaran Mage, Mana Wyrm, Nightblade, Fen Creeper, Deathlord, Defender of Argus, Stonesplinter Trogg, Nightblade, Boulderfist Ogre, Fen Creeper, Frostwolf Grunt, Clockwork Gnome, Clockwork Gnome, Southsea Deckhand, Murloc Raider

Deck 2: Gazlowe, Stonetusk Boar, Hobgoblin, Boulderfist Ogre, Silvermoon Guardian, Loot Hoarder, Power Word: Shield, Jeeves, Sneed's Old Shredder, Mindgames, Abomination, Light of the Naaru, Captain Greenskin, Bloodmage Thalnos, Novice Engineer, Kel'Thuzad, Burly Rockjaw Trogg, Onyxia, Fel Reaver, Jungle Panther, War Golem, Thoughtsteal, Stampeding Kodo, Amani Berserker, Abusive Sergeant, Fen Creeper, Argent Commander, War Golem, Nat Pagle, Nozdormu

EDIT: The deck building AI had already chosen "Chillwind Yeti, Defender of Argus, War Golem, Imp Master, Stranglethorn Tiger", so it was probably doing a lot of iterations on Duplicate.

Ragowit avatar Apr 19 '15 01:04 Ragowit

And again. The deck building AI had already chosen "Imp Master", so it was probably doing a lot of iterations on Duplicate.

Deck 1: Imp Master, Duplicate, Murloc Raider, Gelbin Mekkatorque, Darkscale Healer, Silverback Patriarch, Novice Engineer, Shattered Sun Cleric, Stonesplinter Trogg, Harvest Golem, Frost Elemental, Dragonling Mechanic, Water Elemental, River Crocolisk, War Golem, Frostwolf Warlord, Silvermoon Guardian, Unstable Ghoul, Tinkmaster Overspark, Puddlestomper, Frostwolf Warlord, Stormpike Commando, Silvermoon Guardian, Frostwolf Grunt, Flamecannon, Flamecannon, Wisp, Murloc Raider, Dragonling Mechanic, Fen Creeper

Deck 2: Fen Creeper, Holy Light, Kel'Thuzad, Avenge, Voodoo Doctor, Booty Bay Bodyguard, Frostwolf Grunt, Gruul, Murloc Tidehunter, Novice Engineer, Nozdormu, Murloc Raider, Defender, Wailing Soul, Spectral Knight, Blessing of Might, Archmage, King Mukla, Loatheb, Kobold Geomancer, Razorfen Hunter, Stormwind Champion, Bloodmage Thalnos, Nerubian Egg, Blessed Champion, Bloodsail Corsair, Sunwalker, Emperor Thaurissan, Ogre Brute, Cairne Bloodhoof

Ragowit avatar Apr 19 '15 09:04 Ragowit

I found the cards in common between the two games and we have:

  • Bloodmage Thalnos
  • Frostwolf Grunt
  • Jeeves
  • Stonesplinter Trogg
  • Water Elemental
  • Murloc Raider
  • Abomination
  • Novice Engineer
  • Silverback Patriarch
  • Defender of Argus
  • Duplicate
  • Silvermoon Guardian
  • Chillwind Yeti
  • War Golem
  • Stampeding Kodo
  • Stranglethorn Tiger

The only card that it seems likely to have caused an issue is duplicate, but it's definitely setting the player. I'm still pretty baffled by this one.

danielyule avatar Apr 19 '15 17:04 danielyule

Again, more deck information. "Dancing Swords, Bloodsail Raider" had been selected by the AI, crashed when doing an iteration on Mad Scientist.

Deck 1: Dancing Swords, Bloodsail Raider, Mad Scientist, Duplicate, Gelbin Mekkatorque, Darkscale Healer, Silverback Patriarch, Novice Engineer, Shattered Sun Cleric, Stonesplinter Trogg, Harvest Golem, Frost Elemental, Dragonling Mechanic, Water Elemental, River Crocolisk, War Golem, Frostwolf Warlord, Silvermoon Guardian, Unstable Ghoul, Tinkmaster Overspark, Puddlestomper, Frostwolf Warlord, Stormpike Commando, Silvermoon Guardian, Frostwolf Grunt, Flamecannon, Flamecannon, Wisp, Murloc Raider, Chillwind Yeti

Deck 2: Puddlestomper, Spider Tank, Clockwork Gnome, Maexxna, Gazlowe, Youthful Brewmaster, Violet Teacher, Hogger, Redemption, Ysera, Sneed's Old Shredder, Pint-Sized Summoner, Jeeves, Piloted Shredder, Silverback Patriarch, Thrallmar Farseer, Gelbin Mekkatorque, Injured Blademaster, Blessing of Wisdom, Voodoo Doctor, Frostwolf Warlord, Sludge Belcher, Stalagg, Recombobulator, Deathwing, Cobalt Guardian, Bloodfen Raptor, Raid Leader, Priestess of Elune, Argent Squire

Ragowit avatar Apr 21 '15 07:04 Ragowit

I encountered it again (deck information below), and I tried to reproduce it but got nothing with 276000 games and counting. This got me thinking, maybe it's the game.copy() event that is the problem? Does that one successfully copy all the secrets correctly?

Deck 1: Dragonling Mechanic, Duplicate, Nerub'ar Weblord, Darkscale Healer, Silverback Patriarch, Novice Engineer, Shattered Sun Cleric, Ship's Cannon, Harvest Golem, Frost Elemental, Dragonling Mechanic, Water Elemental, River Crocolisk, Ice Lance, Gurubashi Berserker, Azure Drake, Unstable Ghoul, Cult Master, Micro Machine, Gurubashi Berserker, Archmage, Silvermoon Guardian, Frostwolf Grunt, Maexxna, Kel'Thuzad, Argent Squire, Murloc Raider, Chillwind Yeti, Defender of Argus, Razorfen Hunter

Deck 2: Ragnaros the Firelord, Grimscale Oracle, Kobold Geomancer, Bloodsail Raider, Snowchugger, Tauren Warrior, Baron Rivendare, War Golem, Sunfury Protector, Argent Commander, Sunwalker, Gnomeregan Infantry, Sylvanas Windrunner, Harrison Jones, Onyxia, Kirin Tor Mage, Captain's Parrot, Dark Iron Dwarf, Southsea Deckhand, Murloc Tidehunter, Spider Tank, Acidic Swamp Ooze, Secretkeeper, Bomb Lobber, Dragon's Breath, Southsea Deckhand, Millhouse Manastorm, Dire Wolf Alpha, Kel'Thuzad, Doomsayer

Ragowit avatar Apr 21 '15 17:04 Ragowit

Does it have to do with duplicating noncollectable cards? The first game had Tinkmaster and Gelbin, second had Imp Master; third had Imp Master, Gelbin, and Tinkmaster; fourth had Gelbin, Tinkmaster Harvest Golem and Dragonling Mechanic; fifth had Dragonling, Harvest, and Razorfen.

randomflyingtaco avatar Apr 22 '15 05:04 randomflyingtaco

I added try-except into the mana_cost function that would print out the card if it got into the except part.

And it did indeed print out Duplicate.

I have not looked into the game.copy() idea I wrote about earlier.

Deck 1: Master Swordsmith, Duplicate, Nerub'ar Weblord, Darkscale Healer, Silverback Patriarch, Novice Engineer, Shattered Sun Cleric, Ship's Cannon, Harvest Golem, Frost Elemental, Dragonling Mechanic, Water Elemental, River Crocolisk, War Golem, Frostwolf Warlord, Silvermoon Guardian, Nerubian Egg, Tinkmaster Overspark, Micro Machine, Frostwolf Warlord, Stormpike Commando, Silvermoon Guardian, Frostwolf Grunt, Kel'Thuzad, Flamecannon, Wisp, Murloc Raider, Chillwind Yeti, Defender of Argus, Razorfen Hunter

Deck 2: Mana Wyrm, Murloc Tidecaller, Stormpike Commando, Sneed's Old Shredder, Gnomish Experimenter, Illuminator, Spellbreaker, Murloc Warleader, Worgen Infiltrator, Wee Spellstopper, Southsea Captain, Mirror Image, Twilight Drake, Raid Leader, Piloted Shredder, Murloc Tidecaller, Gurubashi Berserker, Hobgoblin, Lord of the Arena, Ironforge Rifleman, Harrison Jones, Stormpike Commando, Duplicate, Frostwolf Grunt, Sunwalker, Ravenholdt Assassin, Flesheating Ghoul, Piloted Sky Golem, Frost Elemental, Blizzard

Ragowit avatar Apr 22 '15 21:04 Ragowit

I figured it out. Some secrets are setting self.player to None when they are deactivated. What I don't understand is how a de-activated secret is making it back into a player's hand.

danielyule avatar Apr 23 '15 14:04 danielyule

I guess I could try and take a look into implementing the replay feature, saving it if I encounter a problem.

Ragowit avatar Apr 24 '15 08:04 Ragowit

If I did everything right with the replay thingie so is this the replay to get this error: https://gist.github.com/Ragowit/68bd9718e80dfc330ff5

Ragowit avatar Apr 25 '15 08:04 Ragowit