Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created September 10, 2010 06:46
Show Gist options
  • Save yuroyoro/573213 to your computer and use it in GitHub Desktop.
Save yuroyoro/573213 to your computer and use it in GitHub Desktop.
object AAMaker {
import util.Random
val rnd = new Random
def asSeq[T](xs:Seq[Product]) = xs.map{_.productIterator.toSeq.asInstanceOf[Seq[T]]}
def choice[T](xs:Seq[T]):T = xs(rnd.nextInt(xs.size))
val rinkaku = asSeq[String](Seq(("(", ")"), ("(", ")"), ("|", "|"), ("|", "|")))
var otete = asSeq[String](Seq(("", "", "", "", ""), ("", "", "m", "", ""), ("", "", "ლ", "", ""), ("ლ", "", "", "ლ", ""), ("", "「", "", "", "「"), ("", " つ", "", "", "つ"), ("", " ", "", "", "o彡゚"), ("", "n", "", "", "η"), ("", "∩", "", "∩", ""), ("∩", "", "", "", "∩"), ("ヽ", "", "", "", "ノ"), ("┐", "", "", "", "┌"), ("╮", "", "", "", "╭"), ("<", "", "", "", "/"), ("╰", "", "", " ", ""), ("o", "", "", "", "o"), ("o", "", "", "", "ツ"), ("", "", "", "", "ノシ")))
val omeme = asSeq[String](Seq(("\u25d5", "\u25d5"), ("╹", "╹"), (">", "<"), ("^", "^"), ("・", "・"), ("´・", "・`"), ("`・", "・´"), ("´", "`"), ("≧", "≦"), ("゚", "゚"), ("\"", "\""), ("・ิ", "・ิ"), ("❛", "❛"), ("⊙", "⊙"), (" ̄", " ̄"), ("◕ˇ", "ˇ◕")))
var okuti = Seq("ω", "∀", "▽", "△", "Д" , "□", "~", "ー", "ェ", "ρ", "o")
var hoppe = asSeq[String](Seq(("", ""), ("*", ""), ("", "*"), ("", "#"), ("#", ""), ("✿", ""), ("", "✿"), ("", ";"), (";", ""), ("。", "。"), ("。", ""), ("", "。"), ("▰", "▰"), ("", "▰"), ("▰", ""), ("๑", "๑"), ("", "๑"), ("๑", "")))
def generateAll =
for( rin <- rinkaku; ote <- otete; ome <- omeme; oku <- okuti; hop <- hoppe ) yield{
generate(rin, ote, ome, oku, hop)
}
def generate(
implicit rin:Seq[String] = choice(rinkaku),
ote:Seq[String] = choice(otete),
ome:Seq[String] = choice(omeme),
oku:String = choice(okuti),
hop:Seq[String] = choice(hoppe) ) =
{
case class StringCondition(s:String) {
def ||(v:String) = if(s.nonEmpty) s else v
def ?[T](v1: => T)(v2: => T) = if( s.nonEmpty) v1 else v2
}
implicit def str2cond(s:String) = StringCondition(s)
Seq( ote(0),
rin.head,
ote(1) || ote(3).?("")(hop.last),
ome.head,
ote(2) || oku,
ome.last,
ote(3) || ote(1).?("")(hop.last),
rin.last,
ote(4)).mkString
}
}
object Main {
def main(args:Array[String]) = {
args.headOption.filter{ "all" == }.map{ all =>
AAMaker.generateAll.mkString("\n") }.orElse( Some(AAMaker.generate) ).foreach{ println}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment