Login Register
Frontpage Code library Pastebin

Ristinolla

Author: KilledWhale
Added: 9. huhtikuuta 2011 kello 21.24
Edited: 15. huhtikuuta 2011 kello 22.19
Category: Sekalaiset

Description

Ristinollapeli joka on ahdettu niin pieneen tilaan kuin mahdollista. Asciita hyödyntämällä olisi mahdollista saada vielä yhtä riviä lyhyemmäksi. Aluksi koodi oli n. 50 riviä pitkä, josta lähdin sitä tiivistelemään.

Code

Select all
1
2
3
4
5
6
7
// Simple tic-tac-toe game made with CoolBasic and squeesed to as few lines as possible

For a = 0 To a + 1
	If (a Mod 23) < 22 Then Line (((a Mod 23) < 2) * ((a Mod 23) + 1) * ScreenWidth() / 3) + (((a Mod 23) < 4 And (a Mod 23) > 1) * 0) + (((a Mod 23) > 3 And ( ((a Mod 23) -4) / 9) = 1)*(((a Mod 23) - 4) Mod 3 * ScreenWidth() / 3)) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 0)*(((a Mod 23) - 4) Mod 3 * ScreenWidth() / 3 + (ScreenWidth() / 3  * (Mid(s$ + "0000000000", Int(Max(((a Mod 23) Mod 23 - 4) Mod 9 + 1, 1)), 1) = "2") * ((a Mod 23) > 3)))), (((a Mod 23) < 2) * 0) + (((a Mod 23) < 4 And (a Mod 23) > 1) * ((a Mod 23) Mod 2 + 1) * ScreenHeight() / 3) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 1)*(((a Mod 23) - 4) / 3 Mod 3 * ScreenHeight() / 3)) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 0)*(((a Mod 23) - 4) / 3 Mod 3 * ScreenHeight() / 3)), (((a Mod 23) < 2) * ((a Mod 23) + 1) * ScreenWidth() / 3) + (((a Mod 23) < 4 And (a Mod 23) > 1) * ScreenWidth()) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 1)*(((a Mod 23) - 4) Mod 3 * ScreenWidth() / 3 + (ScreenWidth() / 3 * (Mid(s$ + "0000000000", Int(Max(((a Mod 23) Mod 23 - 4) Mod 9 + 1, 1)), 1) = "2") * ((a Mod 23) > 3)))) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 0)*(((a Mod 23) - 4) Mod 3 * ScreenWidth() / 3)), (((a Mod 23) < 2) * ScreenHeight()) + (((a Mod 23) < 4 And (a Mod 23) > 1) * ((a Mod 23) Mod 2 + 1) * ScreenHeight() / 3) + (((a Mod 23) > 3 And (((a Mod 23)-4) / 9) = 1)*(((a Mod 23) - 4) / 3 Mod 3 * ScreenHeight() / 3 + (ScreenHeight() / 3 * (Mid(s$ + "0000000000", Int(Max(((a Mod 23) Mod 23 - 4) Mod 9 + 1, 1)), 1) = "2") * ((a Mod 23) > 3)))) + (((a Mod 23) > 3 And ( ((a Mod 23) -4) / 9) = 0)*( ((a Mod 23)  - 4) / 3 Mod 3 * ScreenHeight() / 3 + (ScreenHeight() / 3  * (Mid(s$ + "0000000000", Int(Max( ((a Mod 23)  Mod 23 - 4) Mod 9 + 1, 1)), 1) = "2") *  ((a Mod 23)  > 3))))Else DrawScreen
	If (a Mod 23) < 22 And (a Mod 23) > 3 Then Ellipse (((a Mod 23) - 4) Mod 3) * ScreenWidth() / 3, (((a Mod 23) - 4) / 3 Mod 3) * ScreenHeight() / 3, ScreenWidth() / 3 * (Mid(s$ + "0000000000", ((a Mod 23) Mod 23 - 4) Mod 9 + 1, 1) = "1"), ScreenHeight() / 3, 0
	If (Mid(s$ + "0000000000", ((a Mod 10) / 3) * 3 + 1, 1) = Mid(s$ + "0000000000", ((a Mod 10) / 3) * 3 + 2, 1) And Mid(s$ + "0000000000", ((a Mod 10) / 3) * 3 + 2, 1) = Mid(s$ + "0000000000", ((a Mod 10) / 3) * 3 + 3, 1) And Mid(s$ + "0000000000", ((a Mod 10) / 3) * 3 + 3, 1) <> "0") Or (Mid(s$ + "0000000000", ((a Mod 10) Mod 3 + 1), 1) = Mid(s$ + "0000000000", ((a Mod 10) Mod 3 + 1) + 3, 1) And Mid(s$ + "0000000000", ((a Mod 10) Mod 3 + 1) + 3, 1) = Mid(s$ + "0000000000", ((a Mod 10) Mod 3 + 1) + 6, 1) And Mid(s$ + "0000000000", ((a Mod 10) Mod 3 + 1) + 6, 1) <> "0") Or (Mid(s$ + "0000000000", 1, 1) = Mid(s$ + "0000000000", 5, 1) And Mid(s$ + "0000000000", 1, 1) = Mid(s$ + "0000000000", 9, 1) And Mid(s$ + "0000000000", 1, 1) <> "0") or (Mid(s$ + "0000000000", 3, 1) = Mid(s$ + "0000000000", 5, 1) And Mid(s$ + "0000000000", 3, 1) = Mid(s$ + "0000000000", 7, 1) And Mid(s$ + "0000000000", 3, 1) <> "0")Then MakeError Chr(79 + (Mid(s$ + "0000000000", 10, 1) = "0") * 9) + " VOITTI!" Else s$ = Left(StrInsert(StrRemove(StrInsert(s$ + "0000000000", (a Mod 10) + 1, Chr(49 + (Mid(s$ + "0000000000", 10, 1) = "1"))), (a Mod 10) + 1 + ((MouseHit(1) And MouseX() > ((a Mod 10) Mod 3) * (ScreenWidth() / 3) And MouseX() < ((a Mod 10) Mod 3 + 1) * (ScreenWidth() / 3) And MouseY() > ((a Mod 10) / 3) * (ScreenHeight() / 3) And MouseY() < ((a Mod 10) / 3 + 1) * (ScreenHeight() / 3) And Mid(s$ + "0000000000", (a Mod 10) + 1, 1) = "0") = 0), 1), 9, Chr(((Mid(s$ + "0000000000", 10, 1) = "1") * (48 + ((MouseHit(1) And MouseX() > ((a Mod 10) Mod 3) * (ScreenWidth() / 3) And MouseX() < ((a Mod 10) Mod 3 + 1) * (ScreenWidth() / 3) And MouseY() > ((a Mod 10) / 3) * (ScreenHeight() / 3) And MouseY() < ((a Mod 10) / 3 + 1) * (ScreenHeight() / 3) And Mid(s$ + "0000000000", (a Mod 10) + 1, 1) = "0") = 0))) + (Mid(s$ + "0000000000", 10, 1) = "0") * (49 - ((MouseHit(1) And MouseX() > ((a Mod 10) Mod 3) * (ScreenWidth() / 3) And MouseX() < ((a Mod 10) Mod 3 + 1) * (ScreenWidth() / 3) And MouseY() > ((a Mod 10) / 3) * (ScreenHeight() / 3) And MouseY() < ((a Mod 10) / 3 + 1) * (ScreenHeight() / 3) And Mid(s$ + "0000000000", (a Mod 10) + 1, 1) = "0") = 0)))) + "0000000000", 10)
Next a

Comments

#1 Sent by: Viltzu, 9. huhtikuuta 2011 kello 22.29

Tämä on kyllä aivan mahtava. Melkosen näköistä tuo koodi.

Leave a comment

You must be logged in to comment.