- 1
Просто оффтоп #18
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Просто оффтоп #18
#1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
#2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
#3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
#4: (vanished) https://govnokod.xyz/_25472
#5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
#6: (vanished) https://govnokod.xyz/_26649
#7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
#8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
#9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
#10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
#11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
#12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
#13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
#14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
#15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
#16: https://govnokod.ru/27282 https://govnokod.xyz/_27282
#17: https://govnokod.ru/27319 https://govnokod.xyz/_27319
+1
(set-logic UF)
; https://smtlib.cs.uiowa.edu/logics.shtml
; UF for the extension allowing free sort and function symbols
(set-option :produce-proofs true)
(declare-sort M_wff)
; AND2
(declare-fun M_a2 (M_wff M_wff) M_wff)
; AND3
(declare-fun M_a3 (M_wff M_wff M_wff) M_wff)
; (AND2 a b) <=> (AND2 b a)
(assert
(forall ( (a M_wff) (b M_wff) )
(=
(M_a2 a b)
(M_a2 b a)
)
)
)
; (AND2 a a) <=> a
(assert
(forall ( (a M_wff) )
(=
(M_a2 a a)
a
)
)
)
; (AND2 a (AND2 b c)) <=> (AND3 a b c)
(assert
(forall ( (a M_wff) (b M_wff) (c M_wff) )
(=
(M_a2 a (M_a2 b c))
(M_a3 a b c)
)
)
)
; (AND3 a b c) <=> (AND3 b a c)
(assert
(forall ( (a M_wff) (b M_wff) (c M_wff) )
(=
(M_a3 a b c)
(M_a3 b a c)
)
)
)
; IMPL - implication
(declare-fun M_impl (M_wff M_wff) M_wff)
; http://us.metamath.org/ileuni/ax-1.html
; Axiom Simp
; (IMPL a (IMPL b a)) <=> (AND2 a b)
(assert
(forall ( (a M_wff) (b M_wff) )
(=
(M_impl a (M_impl b a))
(M_a2 a b)
)
)
)
...
Весь код не влазит.
https://rise4fun.com/Z3/GnfIH
https://paste.debian.net/hidden/38ef8493/ (запасная ссылка)
Переписывал Metamath на язык из SMT солверов https://smtlib.cs.uiowa.edu/language.shtml
Z3 даже умеет доказывать какую-то питушню там.
+1
%% This function is needed as a hack to guide dialyzer into inferring
%% the correct types.
-spec id(A) -> A.
id(A) ->
A.
%% Где-то в header'е....
-define(deftarget(RECIPE), {RECIPE, fun my_module:id/1}).
%% A horrible, horrible hack to make Dialyzer infer right type of the promise return value
-define(want(TARGET),
(fun() ->
case TARGET of
{_, ___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer} ->
___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer(my_module:want(TARGET))
end
end)()).
Пути статический типизации в Erlang неисповедимы.
+1
// Update is called once per frame
void Update () {
if (!isWin && !isFail && !isPaused)
{
if (timeForUnhit > 0) //Для состояния восстановления игрока
{
timeForUnhit -= Time.deltaTime;
//LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = hitPlayer;
}
else if (timeForInvc > 0)
//Для состояния непобедимости игрока
{
timeForInvc -= Time.deltaTime;
//LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = invcPlayer;
}
else
{
//LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = player;
LevelGenerate.Instance.player.GetComponent<Animator>().CrossFade(animNames[0], 0);
if (invc)
{
MusicManager.Instance.gameObject.GetComponent<AudioSource>().clip = MusicManager.Instance.music[1];
MusicManager.Instance.gameObject.GetComponent<AudioSource>().Play();
}
invc = false;
}
}
i = LevelGenerate.Instance.playerY;
j = LevelGenerate.Instance.playerX;
if (!isWin && !isFail) //Если уровень не завершен
{
collideEnemy(); //Обнаружение столкновения с врагом
collectItem(); //Обнаружения столкновения с собираемым предметом
genNthOrdColls(2); //Генерация предметов n-ого порядка после сбора предметов (n-1)-ого
genNthOrdColls(3);
genNthOrdColls(4);
if (colls[0] == 0 && colls[1] == 0 && colls[2] == 0 && colls[3] == 0 && LevelGenerate.Instance.resLoaded) isWin = true; //Если все предметы собраны, то уровень завершен с прохождением
}
if (isWin && animationSet == 0) //Меняем спрайт игрока при завершении уровня
{
//LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = winPlayer;
LevelGenerate.Instance.player.GetComponent<Animator>().CrossFade(animNames[1], 0);
animationSet++;
delayTime = 1.5f;
MusicManager.Instance.gameObject.GetComponent<AudioSource>().mute = true;
SoundManager.Instance.gameObject.GetComponent<AudioSource>().clip = SoundManager.Instance.sounds[0];
SoundManager.Instance.gameObject.GetComponent<AudioSource>().Play();
}
if (isWin && delayTime <= 0)
{
//path = Application.dataPath + "\\Levels\\SaveData1";
/*if (Application.platform == RuntimePlatform.WindowsEditor)
{
path = Application.dataPath;
path = Path.Combine(path, "Levels");
}
else if (Application.platform == RuntimePlatform.Android)
path = Application.persistentDataPath;
path = Path.Combine(path, "SaveData1");
fs = new FileStream(path, FileMode.Open);
bw = new BinaryWriter(fs);*/
levelNum = (byte)(Convert.ToByte(LevelGenerate.Instance.levelFile.Substring(5)) - 1);
levelNum++;
if (PlayerPrefs.GetInt("maxLevel") == levelNum)
{
PlayerPrefs.SetInt("maxLevel", (int)levelNum);
PlayerPrefs.Save();
}
PlayerPrefs.SetInt("level", (int)levelNum);
/*bw.Write(levelNum);
bw.Write("Level" + (levelNum+1).ToString());
bw.Close();
fs.Close();*/
SceneManager.LoadScene("Win");
} else if (delayTime > 0)
{
delayTime -= Time.deltaTime;
}
if (isFail && delayTime <= 0)
{
//path = Application.dataPath + "\\Levels\\SaveData1";
/*if (Application.platform == RuntimePlatform.WindowsEditor)
{
path = Application.dataPath;
path = Path.Combine(path, "Levels");
```
}
else if (Application.platform == RuntimePlatform.Android)
path = Application.persistentDataPath;
path = Path.Combine(path, "SaveData1");
fs = new FileStream(path, FileMode.Open);
bw = new BinaryWriter(fs);
fs.Seek(1, SeekOrigin.Begin);
bw.Write(LevelGenerate.Instance.levelFil e);
bw.Close();
fs.Close();*/
PlayerPrefs.SetString("levelFile", LevelGenerate.Instance.levelFile);
PlayerPrefs.Save();
SceneManager.LoadScene("Fail");
} else if (delayTime > 0)
{
delayTime -= Time.deltaTime;
}
}
```
Самый страшный метод из EventManager-а (модуль который отвечал за все события в игре - коллизию с врагом, таймаут непобедимости и пр.).
+1
//Генерация уровня из файла
void mapGenerate()
{
float x = 0.72f, y = -0.72f; //Координаты игрового объекта
byte i = 0, j = 0; //Цифровые координаты игрвоого объекта
while (y >= -5.76f)
{
while (x <= 5.76f)
{
if (map[i, j] % 8 == 1) //Если игровой объект - точка спавна игрока
{
player.transform.position = new Vector3(x, y, 0);
playerX = j;
playerY = i;
}
else if (map[i, j] % 8 == 5) //Если игровой объект - точка спавна врага
{
enemy.transform.position = new Vector3(x, y, 0);
enemyX = j;
enemyY = i;
//print("Enemy: " + enemyX + " " + enemyY);
} else if(map[i, j] % 8 == 6) //Если игровой объект - собираемый предмет
{
EventManager.Instance.colls[0]++; //Увеличивается количество собираемых монет на уровне
mapObj[i, j] = Instantiate(entities[map[i, j] % 8], new Vector3(x, y, 0), Quaternion.identity);
}
else if (map[i,j] % 8 != 0) { //Для остальных игровых объектов
mapObj[i,j] = Instantiate(entities[map[i, j] % 8], new Vector3(x, y, 0), Quaternion.identity);
}
x += 0.72f;
j++;
}
y -= 0.72f;
x = 0.72f;
j = 0;
i++;
}
}
//Считывание данных об уровне
void readLevelFile()
{
string path = "";
FileStream fs = null;
BinaryReader br = null;
if (Application.platform == RuntimePlatform.WindowsEditor)
{
path = Application.dataPath;
path = Path.Combine(path, "Levels");
path = Path.Combine(path, levelFile);
fs = new FileStream(path, FileMode.Open);
br = new BinaryReader(fs);
head = br.ReadBytes(8); //Чтение заголовка файла
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
map[i, j] = br.ReadByte(); //Чтение кода игрового объекта
}
}
br.Close();
fs.Close();
} else if (Application.platform == RuntimePlatform.Android)
{
byte[] file = null;
path = "jar:file://"+ Application.dataPath + "!/assets/Levels/"+levelFile;
www = new WWW(path);
while (!www.isDone) { }
if (!string.IsNullOrEmpty(www.error))
{
Debug.LogError("Can't read");
}
file = www.bytes;
for (int i = 0; i < 8; i++)
{
head[i] = file[i];
}
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
map[i, j] = file[j + i * 8 + 8]; //Чтение кода игрового объекта
}
}
www.Dispose();
}
Из кода собственной аркады на Unity 2017-ого года. Неоправданные байто*бские оптимизации, взаимодействие между модулями через десяток глобалов, магические константы не зафиксированные в именах кода, куча хардкода. И ето из модуля для генерации уровня. В модуле для управления событиями код страшнее.
+1
there are java.io.FileNotFoundException and java.nio.file.NoSuchFileException . Both are subclasses of IOException, neither of them is a subclass of the opposite.
+1
private List<CellControl[]> ComposeLines(List<CellControl[]> vertical, List<CellControl[]> horizontal)
{
List<CellControl[]> result = new List<CellControl[]>();
foreach (var vLine in vertical)
{
var cellsCount = vLine.Length;
List<CellControl[]> linesToCompose = new List<CellControl[]>();
foreach (var vCell in vLine)
{
foreach (var hLine in horizontal)
{
foreach (var hCell in hLine)
{
if (hCell.X == vCell.X && hCell.Y == vCell.Y)
{
linesToCompose.Add(hLine);
cellsCount += hLine.Length;
break;
}
}
if (linesToCompose.Count == 0)
{
result.Add(hLine);
}
}
}
if (linesToCompose.Count == 0)
{
result.Add(vLine);
}
else
{
linesToCompose.Add(vLine);
var newLine = new CellControl[cellsCount];
var i = 0;
foreach (var line in linesToCompose)
{
foreach (var cellControl in line)
{
newLine[i] = cellControl;
cellControl.Selected = true;
i++;
}
}
result.Add(newLine);
}
}
return result;
}
+1
import cowsay
cowsay.cow('Hello World')
___________
< Hello World >
===========
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
+1
Питушня #15
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
+1
11 апреля - всемирный день анимешника
Всех поздравляем!!!