Browse Source

Tabula Rasa

Henry Jameson 6 years ago
parent
commit
af6ba02012

+ 0
- 7
build.sbt View File

@@ -1,7 +0,0 @@
1
-name := "Weeapass"
2
-
3
-version := "1.0"
4
-
5
-scalaVersion := "2.10.1"
6
-
7
-libraryDependencies += "com.beust" % "jcommander" % "1.30"

+ 0
- 1
project/plugins.sbt View File

@@ -1 +0,0 @@
1
-addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")

+ 0
- 38
src/main/scala/org/hjiri/weapass/Launcher.scala View File

@@ -1,38 +0,0 @@
1
-package org.hjiri.weapass
2
-import com.beust.jcommander.{JCommander, Parameter}
3
-
4
-
5
-/**
6
- * Created with IntelliJ IDEA.
7
- * User: jcd
8
- * Date: 4/25/13
9
- * Time: 9:46 PM
10
- */
11
-object Launcher extends App{
12
-  object Args {
13
-    // Declared as var because JCommander assigns a new collection declared
14
-    // as java.util.List because that's what JCommander will replace it with.
15
-    // It'd be nice if JCommander would just use the provided List so this
16
-    // could be a val and a Scala LinkedList.
17
-    @Parameter(
18
-      names = Array("-l"),
19
-      description = "When genelatingu wolds use L instead of R")
20
-    var lefto: Boolean = false
21
-
22
-    @Parameter(
23
-      names = Array("-s"),
24
-      description = "When generating wordsh ushe S instead of SH")
25
-    var shisi: Boolean = false
26
-  }
27
-
28
-  if (args != null){
29
-    new JCommander(Args, args.toArray : _*)
30
-  }
31
-  val s:SyllableGenerator = new SyllableGenerator(!Args.shisi, !Args.lefto)
32
-	val w:WordGenerator = new WordGenerator(s)
33
-	for (i <- 1 to Randomizer.pickInt(2,5)){
34
-		System.out.print (w.generateWord.toString+" ")
35
-	}
36
-
37
-
38
-}

+ 0
- 24
src/main/scala/org/hjiri/weapass/Randomizer.scala View File

@@ -1,24 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-import scala.util.Random
4
-
5
-/**
6
- * Created with IntelliJ IDEA.
7
- * User: jcd
8
- * Date: 4/25/13
9
- * Time: 11:54 PM
10
- */
11
-object Randomizer {
12
-
13
-	val secuRnd: Random = Random.javaRandomToRandom(new java.security.SecureRandom())
14
-
15
-	def pickWithProb(prob:Double):Boolean = {
16
-		secuRnd.nextDouble() <= prob
17
-	}
18
-	def pickFrom[T](prob:List[T]): T = {
19
-	    prob(secuRnd.nextInt(prob.size))
20
-	}
21
-	def pickInt(min:Int,max:Int):Int = {
22
-		min + secuRnd.nextInt(max - min)
23
-	}
24
-}

+ 0
- 12
src/main/scala/org/hjiri/weapass/Rarity.scala View File

@@ -1,12 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-/**
4
- * Created with IntelliJ IDEA.
5
- * User: jcd
6
- * Date: 4/26/13
7
- * Time: 12:14 AM
8
- */
9
-object Rarity extends Enumeration{
10
-	type Rarity = Value
11
-	val Common, Uncommon, Youon, Epic, EpicAlt = Value
12
-}

+ 0
- 14
src/main/scala/org/hjiri/weapass/Syllable.scala View File

@@ -1,14 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-/**
4
- * Created with IntelliJ IDEA.
5
- * User: jcd
6
- * Date: 4/25/13
7
- * Time: 9:49 PM
8
- */
9
-class Syllable (val consonant: String, val vowel: String, val isYouon: Boolean){
10
-	val value: String = consonant + vowel
11
-	val consonantOnly : Boolean = vowel == "n"
12
-	val vowelOnly : Boolean = consonant == ""
13
-	override def toString:String = value
14
-}

+ 0
- 83
src/main/scala/org/hjiri/weapass/SyllableGenerator.scala View File

@@ -1,83 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-/**
4
- * Created with IntelliJ IDEA.
5
- * User: jcd
6
- * Date: 4/25/13
7
- * Time: 9:54 PM
8
- */
9
-class SyllableGenerator (val sInsteadOfsh: Boolean = false, val righto: Boolean = true){
10
-	val sh = if (sInsteadOfsh) "s" else "sh"
11
-	val r = if (righto) "r" else "l"
12
-	val j = "j" // add option to replace with z?
13
-
14
-	val commonConsonants   = "k" :: sh :: "t" :: "h"        :: "n" :: "m" :: r ::Nil
15
-	val uncommonConsonants = "g" :: j  :: "d" :: "p" :: "b" ::Nil //gojūon
16
-	val youonConsonants = "y"::Nil //or youon
17
-	val epicConsonants = "w"::Nil
18
-	val epicConsonantsAlt = "v"::Nil
19
-
20
-	//if (useX) consonants = consonants :+ "x"
21
-
22
-	val forW = "a"::"o"::Nil // wa\wo
23
-	val forWRare = "i"::"e"::Nil //wi\we
24
-	val forAll = "u"::Nil
25
-
26
-	val forCommon = forW:::forWRare:::forAll
27
-	val forYouon = forW:::forAll
28
-
29
-	/**
30
-	 * Generates full syllable, consonant+vowel
31
-	 * @param youonForce force creating ya\yo\yu syllable
32
-	 * @param youonProhibit don't create ?ya\?yo\?yu syllables, for word creation.
33
-	 * @return resulting syllable
34
-	 */
35
-	def generateSyllableF(youonForce:Boolean, youonProhibit:Boolean):Syllable = {
36
-		val rarity =
37
-		if (youonForce){
38
-			Rarity.Youon
39
-		} else if (Randomizer.pickWithProb(0.80)){
40
-			Rarity.Common
41
-		} else if (Randomizer.pickWithProb(0.70)){
42
-			Rarity.Uncommon
43
-		} else if (Randomizer.pickWithProb(0.60)){
44
-			Rarity.Youon
45
-		} else if (Randomizer.pickWithProb(0.75)){
46
-			Rarity.Epic
47
-		} else {
48
-			Rarity.EpicAlt
49
-		}
50
-
51
-		val consonants = rarity match {
52
-			case Rarity.Common => commonConsonants
53
-			case Rarity.Uncommon => uncommonConsonants
54
-			case Rarity.Epic => epicConsonants
55
-			case Rarity.Youon => youonConsonants
56
-			case Rarity.EpicAlt => epicConsonantsAlt
57
-		}
58
-		val consonant = Randomizer.pickFrom(consonants)
59
-		val probOfYouon = if (consonant == j) 0.05 else 0.15
60
-		var generatedYouon = false
61
-		val vowel =
62
-		if (!youonForce && !youonProhibit && rarity != Rarity.Youon && Randomizer.pickWithProb(probOfYouon)){
63
-			generatedYouon = true
64
-			generateSyllableF(youonForce = true, youonProhibit = false).toString
65
-		} else {
66
-			val vowels = rarity match {
67
-				case Rarity.Uncommon | Rarity.Common => forCommon
68
-				case Rarity.Epic => if (Randomizer.pickWithProb(0.65)) forW else forWRare
69
-				case Rarity.Youon => forYouon
70
-				case Rarity.EpicAlt => forAll
71
-			}
72
-			Randomizer.pickFrom(vowels)
73
-		}
74
-		new Syllable(consonant,vowel,generatedYouon)
75
-	}
76
-	def generateSyllableF:Syllable = generateSyllableF(youonForce = false, youonProhibit = false)
77
-
78
-	def generateSyllableV(useN:Boolean):Syllable = {
79
-		val letters = if (useN) "n"::Nil else forCommon
80
-		new Syllable("",Randomizer.pickFrom(letters),false)
81
-	}
82
-
83
-}

+ 0
- 33
src/main/scala/org/hjiri/weapass/Word.scala View File

@@ -1,33 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-/**
4
- * Created with IntelliJ IDEA.
5
- * User: jcd
6
- * Date: 4/26/13
7
- * Time: 11:04 AM
8
- */
9
-class Word (val lentgh:Int){
10
-	var numOfN = 0
11
-	var numOfYouon = 0
12
-	var numOfFSyllables = 0
13
-	var numOfVSyllables = 0
14
-	private val value:StringBuilder = new StringBuilder()
15
-	def append(syllable:Syllable){
16
-		value.append(syllable.toString)
17
-	}
18
-	override def toString:String = {
19
-		value.toString()
20
-	}
21
-	def n():Int = {
22
-		numOfN / lentgh * 100
23
-	}
24
-	def youyon():Int =  {
25
-		numOfYouon / lentgh * 100
26
-	}
27
-	def fsyl():Int = {
28
-		numOfFSyllables / lentgh * 100
29
-	}
30
-	def vsyl():Int = {
31
-		numOfVSyllables / lentgh * 100
32
-	}
33
-}

+ 0
- 27
src/main/scala/org/hjiri/weapass/WordGenerator.scala View File

@@ -1,27 +0,0 @@
1
-package org.hjiri.weapass
2
-
3
-/**
4
- * Created with IntelliJ IDEA.
5
- * User: jcd
6
- * Date: 4/26/13
7
- * Time: 11:03 AM
8
- */
9
-class WordGenerator(val sg:SyllableGenerator) {
10
-	def generateWord:Word= {
11
-		val word = new Word(Randomizer.pickInt(3,6))
12
-		var lastYouon = false
13
-		for (i <- 0 to word.lentgh){
14
-			val syllable =
15
-			if ((0 to 5 contains(word.n())) && Randomizer.pickWithProb(0.25)){
16
-				sg.generateSyllableV(useN = true)
17
-			} else if ((0 to 15 contains(word.vsyl())) && Randomizer.pickWithProb(0.25)){
18
-				sg.generateSyllableV(useN = false)
19
-			} else {
20
-				sg.generateSyllableF(youonForce = false, youonProhibit = lastYouon)
21
-			}
22
-			lastYouon = syllable.isYouon
23
-			word.append(syllable)
24
-		}
25
-		word
26
-	}
27
-}