Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : An extra Brained Step
New Topic New Poll Post Reply
Poster Message
TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
icon An extra Brained Step (+1)  
Well, this is an intriguing situation that's been around since JtRH. I did a search of the boards to see if it had been brought up before, but couldn't find it.

In any case, here goes. Of course, since this is such an old bug, there's a fair chance it'll never be fixed, but documenting it at least never hurts.

Beethro moves before monsters. If, after Beethro moves, a living brain senses Beethro (that is, Beethro didn't kill this brain by stabbing it with his own sword), then a flag is set that allows all monsters to make brained moves. This will occur for the rest of the turn unless all brains in the room are destroyed, even if the living brain that sensed Beethro was killed (assuming Beethro was invisible and only in the range of that one brain). This much is documented elsewhere in the forum, in any case.

The bug, however, is that if something else kills the brain during the turn (Mimics, Guards, Adders, etc.), and that was the last brain in the room, then all remaining monsters still to take their turn should be unbrained. But, this is not the case if either a Guard or a Slayer is still in the room. That is, the 'Brain has detected Beethro' is only reset if not only are there no brains left, but there is no need for pathmaps anymore.

EDIT: Also, if all the Guards/Slayers are killed within the same turn but *after* the final brain was killed, then any remaining monsters will still be able to make a brained move. This is not the case if all Guards/Slayers are killed before the brain was killed within the turn.

Again, this is as old as JtRH, so I have no idea how many rooms are affected by it. The fix for it would be easy:

CDbRoom::KillMonster
Click here to view the secret text

However, as stated, it's an old old bug, and those are always the most annoying when it comes to backcompatibility.

===

As an aside, while researching this topic, I found another post in the Bugs forum documenting another difference between AE and JtRH. I tracked down what I believe to be the culprit, and have updated my topic in the General board accordingly.

[Last edited by TFMurphy at 11-25-2010 11:47 PM]
11-25-2010 at 11:01 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: An extra Brained Step (0)  
TFMurphy wrote:
The bug, however, is that if something else kills the brain during the turn (Mimics, Guards, Adders, etc.), and that was the last brain in the room, then all remaining monsters still to take their turn should be unbrained.
It's possible I don't understand the actual bug, but I'm not sure I agree with "...then all remaining monsters still to take their turn should be unbrained". Where possible, we don't want monster movement order to influence play unduly. Applied here, to me this means if a brain was alive at the start of the monster movement phase, then all monsters should all use brained movement. When a monster kills the last brain, any monsters that haven't moved yet that turn should still move as if the brain were alive. If I'm misunderstanding, please help me out.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 12-28-2010 07:57 PM]
12-28-2010 at 07:56 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
icon Re: An extra Brained Step (0)  
mrimer wrote:
It's possible I don't understand the actual bug, but I'm not sure I agree with "...then all remaining monsters still to take their turn should be unbrained". Where possible, we don't want monster movement order to influence play unduly. Applied here, to me this means if a brain was alive at the start of the monster movement phase, then all monsters should all use brained movement. When a monster kills the last brain, any monsters that haven't moved yet that turn should still move as if the brain were alive. If I'm misunderstanding, please help me out.

Well, *currently*, all remaining monsters still to take their turn *are* unbrained if there are no brains left alive and there's nothing left to keep the pathmaps alive. A Guard or Slayer in the room changes that, forcing everything to be brained until the end of the turn.



=== Example Tests ===
Create a room with a brain, a guard and a roach. Place the roach in an enclosure such that it's obvious whether it's brained or unbrained.

Test #1: If Beethro kills the brain, then the roach will be unbrained starting immediately. (Changing this would be very *VERY* bad, so Beethro killing a brain must already cause the rest of the room to be unbrained now)

---

Now place a Mimic next to the brain, and remove the Guard.

Test #2: If the Mimic kills the brain, the roach will still be unbrained this turn. This may turn up in enough rooms that changing this will still be bad, but I can't think of an example off of the top of my head right now.

---

Now add in the Guard again and rerun Test #2.

Test #3: If the Mimic kills the brain, but the Guard is still alive, then the roach will not be unbrained this turn. This is the start of the unintuitiveness.

---

Now place a Mimic next to the Guard such that we kill the Guard and the Mimic on the same turn. Run two tests, with the Mimics having different movement orders (Guard-killing Mimic moving first one time, Brain-killing Mimic moving first the other).

Test #4: If the Guard dies before the Brain, even on the same turn, then the roach will be unbrained.

Test #5: If the Brain dies before the Guard, then the roach will *still* be brained.

=====================



That's the bug in a nutshell. The question you've brought up is "when is it too late to kill a brain such that the rest of the room can react to your existence". Should it be immediately after Beethro moves, immediately after all Clones/Mimics/Decoys moves, immediately after the *brain* moves, or just let brain maps die once the last brain is killed? At the moment, it's "once last brain is killed" *unless* a Guard exists before the last brain is killed, in which case the 'too late' part is "immediately after Beethro moves".

Does that clarify things?

EDIT: The report in this other thread is tangentally related, as it involves a Mimic killing a brain that has detected an invisible Beethro, causing a difference if there are other brains in the room. So whatever decision we make here also has to take into account the current behavior in the other topic. The bug that I'm reporting though is solely to do about Guards/Slayers alive in the room when the last brain is killed.

[Last edited by TFMurphy at 12-28-2010 08:38 PM]
12-28-2010 at 08:20 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: An extra Brained Step (0)  
TFMurphy wrote:
That's the bug in a nutshell. The question you've brought up is "when is it too late to kill a brain such that the rest of the room can react to your existence". Should it be immediately after Beethro moves, immediately after all Clones/Mimics/Decoys moves, immediately after the *brain* moves, or just let brain maps die once the last brain is killed? At the moment, it's "once last brain is killed" *unless* a Guard exists before the last brain is killed, in which case the 'too late' part is "immediately after Beethro moves".

Does that clarify things?
Ohh, I get it now. Thanks for explaining that. Hmm...I'd say we want to change the pathmap check logic so we move the check for no more brains being in the room to the following phases of a turn:

* Check once after Beethro takes a turn, like in CCurrentGame::ProcessTurn() before this code snippet:
				if (!bPlayerIsMonsterTarget && this->swordsman.IsTarget())
					this->pRoom->SetPathMapsTarget(this->swordsman.wX, this->swordsman.wY);

				ProcessMonsters(nCommand, CueEvents);


* Check again after all monsters take a turn, e.g. in ProcessSimultaneousSwordHits().

Hmm...on second thought, the second check isn't actually needed, is it, because this check will be done by the first check on the subsequent turn, before any monsters move again. So, possibly only the first check is needed. Thoughts?

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 12-28-2010 09:14 PM]
12-28-2010 at 09:11 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
icon Re: An extra Brained Step (+3)  
mrimer wrote:
* Check once after Beethro takes a turn, like in CCurrentGame::ProcessTurn() before this code snippet:
				if (!bPlayerIsMonsterTarget && this->swordsman.IsTarget())
					this->pRoom->SetPathMapsTarget(this->swordsman.wX, this->swordsman.wY);
SetPathMapsTarget is relatively harmless. The key factor in all this is the boolean "bBrainSensesSwordsman". Guards don't need to care about bBrainSensesSwordsman because they're their own brain (but they *do* need the PathMap, no matter what). Other monsters do care about it though.

bBrainSensesSwordsman is already set near the start of ProcessMonsters, providing at least one brain after Beethro has moved detects him. It's turned off during a turn if the last brain dies (so a Mimic can move and kill the last brain and cause the entire room to be brainless now).

If bBrainSensesSwordsman is *never* turned off, then we already achieve the effect that, should at least one brain detect Beethro after he moves, then the entire room is brained, no matter what happens. But if this is the case, then we definitely do *not* want to delete pathmaps when a brain dies; we may need a check later that does that, unless pathmaps are reset/deleted elsewhere.

The drawback here is that I don't know if there are many rooms that rely on killing a brain with a Mimic within a certain time limit: Mimics move before all monsters, so if kills from them no longer cause the room to become brainless, then we are very likely to see compatibility changes. This may be harmless though.

We *could* have bBrainSensesSwordsman wait until after all doubles are moved, just as things falling off Platforms wait. It's still a gamestate change, of course... just unsure which would be the better option.

EDIT: Another possibility is to set bBrainSensesSwordsman as usual at the start of ProcessMonsters, but then check wBrainCount after all Doubles have moved. If it has been reduced to 0 by the Doubles, then reset bBrainSensesSwordsman to false. This is a slightly more complicated interaction, but it seems like it would preserve the most backcompatibility whilst still removing monster movement order from the equation.

If it was coded this way, the rules would be expressed as such:
1. If no brain detects Beethro after he moves, then the room is unbrained.
2. If a brain does detect Beethro, then you have until all the Mimics have moved to kill all brains in the room. If successful, the room is still unbrained.
3. If unsuccessful (even if you manage to kill the single brain that detected Beethro), the room is brained. Even if all brains are killed later on in the turn by Guards, Adders, Hot Tiles, etc., the room will still be brained until next turn.

* Check again after all monsters take a turn, e.g. in ProcessSimultaneousSwordHits().
The only thing we may need to do at this point is check whether pathmaps are still needed, and if not, delete them. (Though there usually isn't much harm in them hanging around if they were already generated, is there?)

[Last edited by TFMurphy at 12-28-2010 10:56 PM]
12-28-2010 at 09:54 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: An extra Brained Step (0)  
Thanks for the explanation of ramifications. I concur this is an involved issue. I agree with one of your proposed fixes, specifically, how about:

Move the line
this->bBrainSensesSwordsman = this->pRoom->BrainSensesSwordsman();
below the platform falling check in ::ProcessMonsters(). Make sure it can only be called at most once per turn, using a bool functionally analogous to bDoublesMoved, but in this case, based off of IsBrainPresent(). Then we can yank resetting bBrainSensesSwordsman when a brain dies.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 12-29-2010 03:33 PM]
12-29-2010 at 03:32 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
icon Re: An extra Brained Step (+3)  
Fix submitted to SVN.

I've turned off bBrainSensesSwordsman after PreprocessMonsters, as well as placed the 'can we delete Pathmaps' check there. After doubles move, bBrainSensesSwordsman may be turned on if a brain detects the player. Killing a brain after this doesn't turn it off. Also, killing a Slayer doesn't run a Pathmap check (which could've led to crashes if we deleted the pathmaps before we were done with them).

I had briefly toyed with the idea of allowing Fegundos in the Doubles check, but that seemed like getting a bit too deep into it. So Mimics/Doubles are the current limit with regards to when the brains have to be killed by, as agreed.

Note that this does mean that a Mimic can kill a brain that would normally have detected an Invisible Beethro to save Beethro from being detected now. I don't think we'll run into many problems related to that, but again, we should keep an eye out.
12-29-2010 at 06:08 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : An extra Brained Step
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.