The Castle Doctrine Forums

Discuss the massively-multiplayer home defense game.

You are not logged in.

#1 2014-01-15 03:20:25

arakira
Member
Registered: 2013-12-01
Posts: 176

lag in Morel's house

There is something strange happening in Morel's house. Every time I reach the vault (it happened 4 or 5 times), I get stuck at least 30/40 seconds at the black exit screen, with the three white (then orange, then red) dots blinking, and often the exclamation mark. Twice, I even got killed by timeout after being stuck at that screen for too long. I never had this in any other house, and it happens every time I reach Morel's vault. It is fine if I just enter and immediately leave his house.
This may be related to the heavy electronic stuff that is in this house? On my old dual core 2,4Ghz computer from 2008, the game gets sluggish when I walk around all his electronic stuff.
(same problem in v28 and v29)

Offline

#2 2014-01-15 05:49:50

joshwithguitar
Member
Registered: 2013-07-28
Posts: 538

Re: lag in Morel's house

I'm pretty sure it is because of his electronics, the lag at the end would be at the server side as it has to run through your entire move sequence and figure out the electronics for each step. With the new time-out I think you could possibly stop people from brute forcing by adding electronics lag that can only be removed with a correct code that otherwise slows things down too much for you to make it all the way to the vault.

It used to be the case that it was quite easy to set up electronics so that you could basically crash the game with electronics lag with a big enough counter chain. I reported this possibility to Jason and he limited the maximum number of steps per turn (I think to 256) but this doesn't stop heavy concurrent electronics from lagging the system, at least enough that 10 mins could become a real problem.

It is interesting that you could get stuck at that screen long enough for you to die of timeouts despite having already let the server know that you have completed it all. This sounds really open to lag exploitation.

Offline

#3 2014-01-15 07:45:24

Antiblitz
Member
Registered: 2013-12-31
Posts: 32

Re: lag in Morel's house

why we are talking about Mr. Morel's house, why do his dogs not move past the pit, even though they are completely free to move?  They refuse to move past the sight of a crippled cat in a pit.  I dont understand the logic behind that, however, if you move close to the dog, within one square to kill it, it will attack you and of course kill you.

Offline

#4 2014-01-15 08:46:55

arakira
Member
Registered: 2013-12-01
Posts: 176

Re: lag in Morel's house

The rule is that an animal doesn't want to step next to a dead animal, unless it is a dog who has the possibility to jump on you.

Offline

#5 2014-01-15 12:34:07

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,235

Re: lag in Morel's house

Dammit.... hmmm...

A few things.

FIrst, the client retries after 16 seconds no matter what, basically assuming that the first request was lost or something.  Most of the time, it's just the server being slow, so these extra requests don't help the situation.  Of course, because of data locks, these later requests tend to pile up and don't actually do anything on the server until the first request finally goes through.  In fact, in the case of a robbery end, what's happening is that the first request goes through, eventually, but the client has already given up on that request.  A later request goes through and the server gives it a cached copy of the last robbery result (so the sim isn't run for each retried request).

Also, I just realized that the endRobHouse call checks the robbery time FIRST before doing anything else, including in the case where the successful robbery result is cached from a non-timed out request.  So, I can at least fix that pretty easily.  If the first request to end the robbery was on time, the server should go by that.

But... it's clear that a house like this can really bog down simulation on the server, which isn't good.  Those simulators will be blocked, preventing other robberies from ending too.  Ugly.


Any thoughts about reducing that max electronic step count even further?

Offline

#6 2014-01-15 18:35:19

pottage
Member
Registered: 2013-07-01
Posts: 37

Re: lag in Morel's house

Could you clarify what exactly that means please Jason? What is the step count?

Offline

#7 2014-01-16 13:11:14

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,235

Re: lag in Morel's house

Some electronics that feed back into themselves take many full-propagation steps to finally loop and be resolved by the game engine.  When the game engine sees electronics looping, it catches them and "settles them down" into the lowest seen state for each tile that is playing a part in the loop.

Someone else will have to jump in here if we're going to have examples, because I'm feeling a bit fuzzy brained right now, but the simplest looping thing is an inverted voltage-controlled switch that feeds back into itself.  On step 1, it passes current through itself, which ends up throwing itself open.  On step 2, the fact that it's open blocks the current flowing through, which ends up throwing itself back closed.  On step 3, it throws itself open again.  Loop detected.

By "steps," this is not steps the robber takes, but steps taken in resolving the electronics after the robber takes a step.  You know, should a light be on or off now?  Should a door be open or closed now?  If electronics are feeding back into themselves, they are potentially looping and not settling down to a fixed state.

In more complicated electronics (like, multiple voltage-controlled switches feeding into each other), it can take many steps for them to finally loop.  Or maybe they don't loop at all, and it takes many steps to figure out where they end up.

Right now, the game performs 256 simulation steps max to resolve electronics, meaning that pretty complicated electronics are possible, and they can fully function.  But more complicated electronics get "cut off" before they every get to resolve.

I'm wondering if that number 256 should be reduced down to 16 or something.

Also wondering how many steps Morel's house is taking to resolve.

Offline

#8 2014-01-16 13:30:04

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,235

Re: lag in Morel's house

Oh man!

Just tested Morel's house, and it's only taking 16 steps max to resolve the electronics after each robber step.  Hmm...

I wouldn't want to cut it down below that.

Maybe I need to optimize that electronics code.

Offline

#9 2014-01-16 14:31:08

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,235

Re: lag in Morel's house

Oops... a simple optimization just sped up the power propagation code by a factor of 10x...  :-)

Still, while this makes Morel's house doable to simulate on the server (We can now do 16-power-step houses as fast as we used to do 1-power-step houses), 160-power-step houses could still be a problem.

Offline

Board footer

Powered by FluxBB 1.5.8