How does the ring settings of enigma change wiring tables? EDIT: The model I'm trying to make is "Enigma 1". I learned initially about it from a book called "Code Book" and then looked at it in detail from its wikipedia page. The site wont allow me too add more links but google "enigma rotor details" and see the wikipedia page

There is a similarly worded question here but it doesn't answer mine.

I am trying to make an enigma simulator. I have finished doing everything except the ring settings. How do they affect the substitutions?

For example suppose the initial rotor settings are:

abcdefghijklmnopqrstuvwxyz
ekmflgdqvzntowyhxuspaibrcj


I think by applying the ring setting of B or 2, the settings should become:

abcdefghijklmnopqrstuvwxyz
kmflgdqvzntowyhxuspaibrcje


I think all I should have to do is add the ring positions to the rotor positions. But that doesn't seem to be the case.
I tried decrypting the first sample message from here that way but didn't succeed. I even tried to make the program run in a loop till it finds the intended answer so I could deduce the relation between ring settings and rotor positions, but it never found it.

But using the same settings on an online enigma simulator worked. Everything seems to be the same except that according to the online simulator, the rotor wirings on a ring setting of b or 2 should be:

abcdefghijklmnopqrstuvwxyz
kflngmherwaoupxziyvtqbjcsd 


How on earth did it turn into that?
There's two missing pieces.  First, the ring setting changes the output letter, it doesn't rotate the whole exit pattern.  Second, the rotors are advanced before the letter is encrypted.

If your rotor (Enigma I Rotor I) is set up like this with the ring at A.

abcdefghijklmnopqrstuvwxyz
ekmflgdqvzntowyhxuspaibrcj


Then if you advance the ring to B all the outputs will be shifted up the alphabet by one.  A will become F instead of E.  B will become L instead of K.  And so on.

abcdefghijklmnopqrstuvwxyz
flngmherwaoupxziyvtqbjcsdk


This almost matches the simulator, but why is the simulator's output shifted over one?

abcdefghijklmnopqrstuvwxyz
kflngmherwaoupxziyvtqbjcsd



  Remember that, when depressing a key, the rotors advance before the electrical signal runs through the rotors. Therefore, to examine the current flow through the rightmost rotor in A position, the rotor must be set in the Z position before depressing the key (this also counts for the other rotors if they are due to step).


Source: Technical Details of the Enigma Machine

When you press A the rotor advances to B and encrypts the letter according to B.  Your simulator has to first advance the rotor and then encrypt the letter.