Minecraft wiki entry for Redstone_components, associated text: When placed, rail configures itself to line up with adjacent rails, powered rails, and detector rails, as well as such adjacent rails one block up. If there are two such adjacent rails on non-opposite sides, the rail curves from one to the other. If there are three or four such adjacent rails, the rail curves between two of them (when choosing which directions to curve between, a rail prefers south over north, and east over west). If there are no such adjacent rails, the rail lines up in the north-south direction. If a rail it would line up with is one block up, a rail slants upward toward it without curving (with multiple options to slant upward to, a rail prefers, in order: west, east, south, and north). Other configurations can be created by placing and removing various rails.