Пікаланг, 868068 байт
Це було занадто гарною ідеєю, щоб пропустити. ( Спасибі, mbomb007. )
Це в основному неоптимальна таблиця пошуку. Я спочатку кодую кожен тип як
((first_char + second_char * 2 + third_char * 3) mod 256) - 0x3c
Це призводить до унікальних уявлень для кожного типу. Порожній тип (коли захисний покемон має лише один тип) кодується як 0x00
.
Після цього я просто використовую безлад if-else
еквівалентів, щоб перевірити всі ~ 5800 комбінацій.
Код
Stack Exchange не дозволив мені публікувати код в цілому, ось ось він gzipped + base64'd.
H4sICBA56FUAC3N1cGVyZWZmZWN0aXZlLWdvbGZlZC5wb2tlYmFsbADt2MGOHcdyreG5Ab+DXu3AEws90cTvb1utRrEOuzf3bmZV/mvFD+jyHotkxReRkclF/fXn27/++vOPv/78+4d//vfbv/74v3/++vO//vt//vj7X7z//Pv/+eDX/PjLfv7nx9/x/r+/+uf8mb//xd9VH/+u99/wYx/Qnt47+aexj//j/ad+4Pzqc49//op/DvE/P/zE/jiGj//34y8+T/b99x+/+3QOq8/tR95B/7mF0wb98RP4/NM/9vtT6d9ekMdfPX/7i5/++jd+9c+j37bkX29W3VU+9Gs/7tyeH//9zTj98Mm6//Xnv92fr3/L17/u03/z1b+kTOqH9/+zPwoe/vFwvByf//+v/Mnz6+KPfsVPP/c14dcffe1TPw7TOf7K6bRemdajOX7xuD3/w/vX/jmIz7LCmjLPIvIhTb0IKYdQXRiIrpvqOVkh97jezv8BxeT5xG/46WeWnpfLLETILAimF11ChAi5E2JANaBmb7AQrmssBNO4riiXc1hWDzNKIS+5TKQm0rSFHguxXunB6ip3YSCbXc5ByDP1jKXGUuii8iG6RtbjQ6guDETXyHpCWPVMn4z0eZxK+8ZtvNpUFwaSvyiOMgWSv2voekJm1zPYMYLdbx/moBvKh1BdQnZDMI1TXRgI1ZW/sWNHiYFAGzeMJoTR48wwi/MtCPQSCBkMwTQewsRAQphNkKZehNwBMV+aL6sW+nrI2MbjXEJ06Yp4AjGTFRICMbluSq7HMWB2QYgQIUJqmUKECGl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1PaxwDaa8nZHe9JyFG0OgIehwmZqO+BYHeDiGDIZjGnQPb1QRp6kXIHRATpAlyxqZfDxnbeJxLiJAYyGZXez0h6RAz7KYMexwDZheECBHCg2Aadw5CslxCUlxniLF0UyxdfZjXb9TdG4y5MboQ9aguzByECNElZCTEIGuQnbHp10Pa68W5MBCqCwOhusZCbHxa43zIQ5dBNjrIfnm21H3zQgoRIsR60w5WSB6E6jpDzLDRGfY4TF9fr/h4yNjGhQgRQq8n5JsQU6optXS1B0Ha6wkRIoReDwPBNK5rocuoalSt2XQhQnRlQ9rrCdld70pIUy9XQIybxs3S1RYCgugSImSGCwOhuoTshpzr/Xvd4xf9/w/v9d85//kf/wsHs6nq5j4NAA==
Приклад
Мабуть, офіційний перекладач Pikalang ще не готовий, але оскільки це тривіальна заміна Brainfuck, я перевірив його за допомогою перекладача Brainfuck.
$ base64 -d supereff.pokeball.gz.b64 > supereff.pokeball.gz
$ gunzip supereff.pokeball.gz
$ pikalang supereff.pokeball
Normal
Rock/Dragon
0.5x
Введення розділено новим рядком і вимагає додаткового нового рядка.
Програма використовує місце пам'яті -1, тому якщо ваш перекладач забороняє виходити з лівої сторони стрічки, додайте код з а pipi
або a >
(для Pikalang та Brainfuck відповідно).
Brainfuck, 193708
Ось та сама програма у Brainfuck (також gzipped + base64'd).
H4sICGI+6FUAC3N1cGVyZWZmZWN0aXZlLWdvbGZlZC5iZgDtXQt2GzkOPJDjOYEeL6Ln+19jbHmsyKNPgwSqUCDpfTuTqBokgC4WAEab/dP+nN9Pb2/t4/vfn794u/x8/u79+vP54fnP399+tD9Gs/Z+bu+n043t+d3yc27t7XQ6v398fLR2Pr21t4/Tx4NNPx9pb1+PfrSvjz43PH8anR778vP5F9K+f9Hefv+035//7ynb00ePDX9+evjzmaDPn/eviNpXnN+/+f7V29d/v//xzPz880quL+b8339+v7Pz3a/Ot1bn91+v9vrx6YRZH7Xuz7/b7c8npd6/2PP70ytmBnuepYBQ4xf4/ec4N+0rv1fklByI4kxR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1ZU2QZMNR5+PcCT5lELMEsQjR/sgKWiG4vOWka1zASt5b+iqNoCwnxLDdLdSVSjl3UdkBMXduuuxhQwAWJbVdjF2RlJeHrXHTrVgAYWkzkwDzjhe48HDiPZfzLDu5ZzeDUEzrx+1D7pjzuULNQhTE3+6upfT4z4ldMCLhCbVNqUyClJ9LTPdkFRFVJ03AOi7RRV5BIsYTrghmETPHcWIzVxAtSRQDrKhE6BJ9Dve42Tx9gXJslG4sPE7e46oyIC1wJrNJHLVEqY6JVOd9K4Go1Ml8oaoHUcaQHX4RdTtCL55O+x2jrVQjoxRV9FgvowrdPpJ3/aR//ArQnatCs9AIA
Програма містить чотири частини:
- Вхід. Читання типів та обчислення їх ідентифікаторів.
- Покоління тексту. Створення рядків для кожного з можливих виходів.
- Таблиця пошуку. Ця частина була створена комп'ютером (див. Нижче). Переміщує покажчик на правильний результат.
- Вихід. Просто друк результату.
Основна структура програми
,>,[-<++>],[-<+++>] read first type id
++++++[-<---------->] subtract 3c
+[,----------] skip until newline
>,>,[-<++>],[-<+++>] read second type id
++++++[-<---------->] subtract 3c
>- set @LOOPFLAG@ to get into loop
[
>-< set @CHARFLAG@
<,---------- get character; newline is 00 slash is 25
[ was not newline
------------------------------------- slash is now 00
[ was not slash
>>+<< reset @CHARFLAG@
[-] clear character
]
]
>>[ was newline or slash (@CHARFLAG@ set)
<+>+ reset @LOOPFLAG@ and @CHARFLAG@
]<
]
,>,[-<++>],[-<+++>] read third type id
<[->+>+<<]>[-<+>] copy third to @CHARFLAG@
>[ if @CHARFLAG@ is set
[-] clear @CHARFLAG@
<++++++[-<---------->]> subtract 3c from third
]<
++++++++[- do 8 times
>++++++ put a 0 here
>+++++++++++++++ put an x here
>>++++++ put a 0 here
>++++++ put a 0 here
>++++++ put a 0 here
>+++++++ put a 8 here
>+++++++++++++++ put an x here
>>++++++ put a 0 here
>++++++ put a 0 here
>+++++++ put a 8 here
>+++++++++++++++ put an x here
>>++++++ put a 0 here
>+++++++++++++++ put an x here
>>++++++ put a 0 here
>+++++++++++++++ put an x here
>>++++++ put a 0 here
>+++++++++++++++ put an x here
<<<<<<<<<<<<<<<<<<<<<< go back
]
>>>>>-- change 0 to dot
>++ change 0 to 2
>--- change 8 to 5
>>>>-- change 0 to dot
>--- change 8 to 5
>>>+ change 0 to 1
>>>++ change 0 to 2
>>>++++ change 0 to 4
<<<<<<<<<<<<<<<<<<<<<< go back
(lookup table here)
>[.>] print result
Ось сценарій, який генерує таблицю пошуку:
typemap = [[int(value, 16), name] for value, name in [
["00", "(Nothing)"],
["02", "Ice"],
["07", "Fairy"],
["0f", "Dragon"],
["10", "Electric"],
["11", "Fighting"],
["12", "Grass"],
["1d", "Rock"],
["20", "Dark"],
["25", "Bug"],
["28", "Ghost"],
["2d", "Poison"],
["2e", "Steel"],
["32", "Fire"],
["39", "Water"],
["3c", "Ground"],
["46", "Normal"],
["4d", "Flying"],
["65", "Psychic"]
]]
multipliers = {
0: 5,
0.25: 8,
0.5: 14,
1: 19,
2: 22,
4: 25
}
types = [
"Normal", "Fighting", "Flying", "Poison", "Ground", "Rock", "Bug", "Ghost", "Steel",
"Fire", "Water", "Grass", "Electric", "Psychic", "Ice", "Dragon", "Dark", "Fairy"
]
results = [
[2, 2, 2, 2, 2, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2],
[4, 2, 1, 1, 2, 4, 1, 0, 4, 2, 2, 2, 2, 1, 4, 2, 4, 1],
[2, 4, 2, 2, 2, 1, 4, 2, 1, 2, 2, 4, 1, 2, 2, 2, 2, 2],
[2, 2, 2, 1, 1, 1, 2, 1, 0, 2, 2, 4, 2, 2, 2, 2, 2, 4],
[2, 2, 0, 4, 2, 4, 1, 2, 4, 4, 2, 1, 4, 2, 2, 2, 2, 2],
[2, 1, 4, 2, 1, 2, 4, 2, 1, 4, 2, 2, 2, 2, 4, 2, 2, 2],
[2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 4, 2, 4, 2, 2, 4, 1],
[0, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2, 1, 2],
[2, 2, 2, 2, 2, 4, 2, 2, 1, 1, 1, 2, 1, 2, 4, 2, 2, 4],
[2, 2, 2, 2, 2, 1, 4, 2, 4, 1, 1, 4, 2, 2, 4, 1, 2, 2],
[2, 2, 2, 2, 4, 4, 2, 2, 2, 4, 1, 1, 2, 2, 2, 1, 2, 2],
[2, 2, 1, 1, 4, 4, 1, 2, 1, 1, 4, 1, 2, 2, 2, 1, 2, 2],
[2, 2, 4, 2, 0, 2, 2, 2, 2, 2, 4, 1, 1, 2, 2, 1, 2, 2],
[2, 4, 2, 4, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 0, 2],
[2, 2, 4, 2, 4, 2, 2, 2, 1, 1, 1, 4, 2, 2, 1, 4, 2, 2],
[2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 4, 2, 0],
[2, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2, 1, 1],
[2, 4, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 4, 4, 2]
]
def getMultiplier(first, second, third):
id1 = types.index(first)
id2 = types.index(second)
if third in types:
id3 = types.index(third)
return results[id1][id2] * results[id1][id3] / 4;
else:
return results[id1][id2] / 2
def genFirstType(second, third, remain, removed):
mul = getMultiplier(remain[0][1], second, third)
if len(remain) == 1:
result = "[ first is not " + removed[1] + "\n"
result += "thus first must be " + remain[0][1] + "\n"
result += ">" * (multipliers[mul] - 1) + "[-]-> " + str(mul).replace(".", "").rstrip("0") + "x multiplier\n"
result += "]\n"
return result
elif not removed:
result = "<<" + "-" * remain[0][0] + " " + remain[0][1] + " is now 00\n"
result += genFirstType(second, third, remain[1:], remain[0])
result += "<+[ first is " + remain[0][1] + "\n"
result += ">" * multipliers[mul] + "[-] " + str(mul).replace(".", "").rstrip("0") + "x multiplier\n"
result += "]->\n"
return result
else:
result = "[ first is not " + removed[1] + "\n"
result += "-" * (remain[0][0] - removed[0]) + " " + remain[0][1] + " is now 00\n"
result += genFirstType(second, third, remain[1:], remain[0])
result += "<+[ first is " + remain[0][1] + "\n"
result += ">" * multipliers[mul] + "[-] " + str(mul).replace(".", "").rstrip("0") + "x multiplier\n"
result += "]->\n"
result += "]\n"
return result
def genSecondType(third, remain, removed):
if len(remain) == 1:
result = "[ second is not " + removed[1] + "\n"
result += "thus second must be " + remain[0][1] + "\n"
result += genFirstType(remain[0][1], third, typemap[1:], False)
result += "]\n"
return result
elif not removed:
result = "<<" + "-" * remain[0][0] + " " + remain[0][1] + " is now 00\n"
result += genSecondType(third, remain[1:], remain[0])
result += "<+[-> second is " + remain[0][1] + "\n"
result += genFirstType(remain[0][1], third, typemap[1:], False)
result += "<+]->\n"
return result
else:
result = "[ second is not " + removed[1] + "\n"
result += "-" * (remain[0][0] - removed[0]) + " " + remain[0][1] + " is now 00\n"
result += genSecondType(third, remain[1:], remain[0])
result += "<+[-> second is " + remain[0][1] + "\n"
result += genFirstType(remain[0][1], third, typemap[1:], False)
result += "<+]->\n"
result += "]\n"
return result
def genThirdType(remain, removed):
if len(remain) == 1:
result = "[ third is not " + removed[1] + "\n"
result += "thus third must be " + remain[0][1] + "\n"
result += genSecondType(remain[0][1], [item for item in typemap[1:] if item[1] != remain[0][1]], False)
result += "]\n"
return result
elif not removed:
result = "-" * remain[0][0] + " " + remain[0][1] + " is now 00\n"
result += genThirdType(remain[1:], remain[0])
result += "<+[-> third is " + remain[0][1] + "\n"
result += genSecondType(remain[0][1], [item for item in typemap[1:] if item[1] != remain[0][1]], False)
result += "<+]->\n"
return result
else:
result = "[ third is not " + removed[1] + "\n"
result += "-" * (remain[0][0] - removed[0]) + " " + remain[0][1] + " is now 00\n"
result += genThirdType(remain[1:], remain[0])
result += "<+[-> third is " + remain[0][1] + "\n"
result += genSecondType(remain[0][1], [item for item in typemap[1:] if item[1] != remain[0][1]], False)
result += "<+]->\n"
result += "]\n"
return result
def genLookup():
return genThirdType(typemap, False)
def compact(code):
import re
return re.sub(r"[^+\-<>\[\],.]", "", code)
def golfStep(code):
return code.replace("><", "").replace("<>", "").replace("+-", "").replace("-+", "")
def golf(code):
previous = golfStep(code)
while previous != code:
previous, code = code, golfStep(code)
return code
if __name__ == "__main__":
import sys
result = genLookup()
if "-g" in sys.argv:
print(golf(compact(result)))
elif "-c" in sys.argv:
print(compact(result))
else:
print(result)
До речі, ця відповідь займає 29817 байт. :)