`void NCipher()
{
nLetters = new List();
nLet = new List();
for (int n = 0; n < 6; n++)
{
nLetters.Add(nWord[n]);
}
nRotators = "";
// Rotate n4, n5, and n6
char temp;
List indices1 = new List() { n4, n5, n6 };
indices1.Sort(); // Sort the indices in ascending order
List originalIndices1 = new List(indices1); // Store the original indices for rotation
for (int i = 0; i < indices1.Count; i++)
{
int newIndex = Rnd.Range(0, 6);
while (indices1.Contains(newIndex))
{
newIndex = Rnd.Range(0, 6);
}
indices1[i] = newIndex;
}
// Rotate the letters while preserving the original order of rotation
temp = nLetters[indices1[0]];
nLetters[indices1[0]] = nLetters[originalIndices1[0]];
nLetters[originalIndices1[0]] = temp;
nRotators += "FJNSVX"[indices1[0]];
temp = nLetters[indices1[1]];
nLetters[indices1[1]] = nLetters[originalIndices1[1]];
nLetters[originalIndices1[1]] = temp;
nRotators += "FJNSVX"[indices1[1]];
temp = nLetters[indices1[2]];
nLetters[indices1[2]] = nLetters[originalIndices1[2]];
nLetters[originalIndices1[2]] = temp;
nRotators += "FJNSVX"[indices1[2]];
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}{2}{3}", _moduleID, indices1[0], indices1[1], indices1[2]);
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after first rotation are {1}{2}{3}{4}{5}{6}", _moduleID, nLetters[0], nLetters[1], nLetters[2], nLetters[3], nLetters[4], nLetters[5]);
// Rotate n1, n2, and n3
List indices2 = new List() { n1, n2, n3 };
indices2.Sort(); // Sort the indices in ascending order
List originalIndices2 = new List(indices2); // Store the original indices for rotation
for (int i = 0; i < indices2.Count; i++)
{
int newIndex = Rnd.Range(0, 6);
while (indices2.Contains(newIndex))
{
newIndex = Rnd.Range(0, 6);
}
indices2[i] = newIndex;
}
// Rotate the letters while preserving the original order of rotation
temp = nLetters[indices2[0]];
nLetters[indices2[0]] = nLetters[originalIndices2[0]];
nLetters[originalIndices2[0]] = temp;
nRotators += "FJNSVX"[indices2[0]];
temp = nLetters[indices2[1]];
nLetters[indices2[1]] = nLetters[originalIndices2[1]];
nLetters[originalIndices2[1]] = temp;
nRotators += "FJNSVX"[indices2[1]];
temp = nLetters[indices2[2]];
nLetters[indices2[2]] = nLetters[originalIndices2[2]];
nLetters[originalIndices2[2]] = temp;
nRotators += "FJNSVX"[indices2[2]];
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}{2}{3}", _moduleID, indices2[0], indices2[1], indices2[2]);
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after second rotation are {1}{2}{3}{4}{5}{6}", _moduleID, nLetters[0], nLetters[1], nLetters[2], nLetters[3], nLetters[4], nLetters[5]);
string nNewWord = "";
for (int p = 0; p < 6; p++)
{
nNewWord += nLetters[p];
}
string indices;
indices = "";
for (int w = 0; w < 6; w++)
{
if (w < 3)
{
indices += indices1[w].ToString();
}
else
{
int q;
q = w % 3;
indices += indices2[q].ToString();
}
}
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}", _moduleID, indices);
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Rotators are {1}", _moduleID, nRotators);
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after rotating are {1}", _moduleID, nNewWord);
}
`
Он выполняет цикл, а затем меняет местами n1/n4 на первую букву. В какой строке допущена логическая ошибка? Я просто хочу это исправить. Это для модового модуля Keep Talking and Nothing Explodes под названием Copper-9. Медь-9 — это планета, на которой происходят действия дронов-убийц, и буквы на дисплее будут похожи на дроны-убийцы.
Ротаторы неправильные Я пытался попросить ChatGPT исправить это, но это не сработало Кстати, вот код: [code]`void NCipher() { nLetters = new List(); nLet = new List(); for (int n = 0; n < 6; n++) { nLetters.Add(nWord[n]); }
nRotators = "";
// Rotate n4, n5, and n6 char temp; List indices1 = new List() { n4, n5, n6 }; indices1.Sort(); // Sort the indices in ascending order List originalIndices1 = new List(indices1); // Store the original indices for rotation
for (int i = 0; i < indices1.Count; i++) { int newIndex = Rnd.Range(0, 6); while (indices1.Contains(newIndex)) { newIndex = Rnd.Range(0, 6); } indices1[i] = newIndex; }
// Rotate the letters while preserving the original order of rotation temp = nLetters[indices1[0]]; nLetters[indices1[0]] = nLetters[originalIndices1[0]]; nLetters[originalIndices1[0]] = temp; nRotators += "FJNSVX"[indices1[0]];
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}{2}{3}", _moduleID, indices1[0], indices1[1], indices1[2]); Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after first rotation are {1}{2}{3}{4}{5}{6}", _moduleID, nLetters[0], nLetters[1], nLetters[2], nLetters[3], nLetters[4], nLetters[5]);
// Rotate n1, n2, and n3 List indices2 = new List() { n1, n2, n3 }; indices2.Sort(); // Sort the indices in ascending order List originalIndices2 = new List(indices2); // Store the original indices for rotation
for (int i = 0; i < indices2.Count; i++) { int newIndex = Rnd.Range(0, 6); while (indices2.Contains(newIndex)) { newIndex = Rnd.Range(0, 6); } indices2[i] = newIndex; }
// Rotate the letters while preserving the original order of rotation temp = nLetters[indices2[0]]; nLetters[indices2[0]] = nLetters[originalIndices2[0]]; nLetters[originalIndices2[0]] = temp; nRotators += "FJNSVX"[indices2[0]];
Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}{2}{3}", _moduleID, indices2[0], indices2[1], indices2[2]); Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after second rotation are {1}{2}{3}{4}{5}{6}", _moduleID, nLetters[0], nLetters[1], nLetters[2], nLetters[3], nLetters[4], nLetters[5]);
string nNewWord = ""; for (int p = 0; p < 6; p++) { nNewWord += nLetters[p]; } string indices; indices = ""; for (int w = 0; w < 6; w++) { if (w < 3) { indices += indices1[w].ToString(); } else { int q; q = w % 3; indices += indices2[q].ToString(); } } Debug.LogFormat("[Copper-9 #{0}] N Cipher: Numbers are {1}", _moduleID, indices); Debug.LogFormat("[Copper-9 #{0}] N Cipher: Rotators are {1}", _moduleID, nRotators); Debug.LogFormat("[Copper-9 #{0}] N Cipher: Letters after rotating are {1}", _moduleID, nNewWord); } [/code] ` Он выполняет цикл, а затем меняет местами n1/n4 на первую букву. В какой строке допущена логическая ошибка? Я просто хочу это исправить. Это для модового модуля Keep Talking and Nothing Explodes под названием Copper-9. Медь-9 — это планета, на которой происходят действия дронов-убийц, и буквы на дисплее будут похожи на дроны-убийцы.