User:Laura Macchini/prototyping/gameofthrones generator: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
<nowiki> hand: stay away , summon a hundred swords here right one by name . The rest of the breed anyway . Cersei has been on her own voice , while Jon Snow turned away from the likes the guard . He'd lost . They had hanged the rest of yours , Ser Barristan had to the banner . My father and more easily . Arrogance and fell . The balcony , in the hillsides , she broke suddenly Jon to the bloody carcass . I am sorry , announced . I won't stop it , beneath . Cayn whirled around them all of the Eyrie and it was just as though he huddled in a child as his raven black bread stores before , Father , with lions , the flickering spark in the maegi and hugged him . They set him . I have been , armored in a hand touched it in linen is Lord Beric to have names in the old gods are all the torch to steal our fire , kneeling to answer , brusque sentences with curiosity . Chapter 31 Tyrion felt a snake . My lords . Loras Tyrell , Tyrion understood in , he moved quiet as he boasts of us when I will be curious . Illyrio , Lord Gyles covered with every muscle and night . I fear Gregor Clegane first time to fight ? Dareon dashed his life . She stuck in anything ? No , sadly . Bran side . Everywhere ? he kept his beard did you , but they stepped aside . Otherwise he just outside the first time . The time , sharpening his uncle Kevan , the Kingsguard have only watch his empty , Mikken melt into the arm . The rest of cold bed , one else could get his belt of voices , and his dolls away to Riverrun . She was done . Lord Tywin is all people . The ascent on , to south . When he did him very room that milk , biting up swearing as well , big man might be done with a fortnight we took three . Tyrion Lannister , Lysa raised his father before he sounded more . Surely you as Rakharo chose a blade was born a young boy had been jumbled around his face . The shifting torchlight , across the castle went down and she hunched over her nipples , each other words to Flea Bottom was his fingers on this bruise there were safely home , watch every step . Stop it! Before he heard the ridge , just like this puts a thousand things I have had pockets with Jeyne father was very hall . He seemed disappointed him in pain . Sister , Ser Jaremy Rykker filled with smokeberry vines; they going to the road of darkness , he wants to the damp , by your lord father and rang . My sister wanted to forsake all so much
== The Code ==
</nowiki>
<source lang="python">
import random
 
f = open ("cleangame.txt", "r" )
s = f.read()
words = s.split()
nextwords = {}
 
for (i,w) in enumerate(words):
if i < len(words)-1:
nword = words[i+1]
if w in nextwords:
nextwords[w].append(nword)
else:
nextwords[w] = []
nextwords[w].append(nword)
 
first = random.choice(nextwords.items())
newText = []
newText.append(first[0].capitalize())
current = first[0]
 
while len(newText) < 500:
currentList = nextwords[current]
next = random.choice(currentList)
newText.append(next)
current = next
 
game = ""
punctuation = ['.',';',',','?','!',':']
for w in newText:
if w in punctuation:
if w == ".":
game += w + "\n"
else:
game += w
else:
game += " " + w
print game
</source>
 
==The Result==
<source lang="text">
Lowering his broad grassy horse made anew.
Nymeria.
The wildlings and lowered his brother.
My thanks, I feel it or corn, no more anxious.
I Ser Willis mounted up, no doubt he killed him, echoed.
And the young princes were true, she said of his furs and smoking star charts hung at him be curious look a stupid sister, the gate.
As soon as his sister, working at the ship made her bare to Aegon high on them get a moment that understood that would do.
This man strange and the empty.
Another snared his up those daughters.
Wine? I thought, and pleaded with a triangular shield, striped horses that it cling to the sharp enough coin.
I were bannermen on it, with Lady Lysa Arryn was fighting with both you think I'd rather than it, and looked behind a steward told Arya liked the size of the sun.
He wondered whether he smelled the armor were soft knock you? Ser Rodrik went through the poppy.
She was lapping of your mild.
Oh, the Wall behind him jump, could dance here.
No, grievously wounded and honored for a black bog where the drape of shadowcats behind masks.
My lord.
Syrio, my hands bleeding from the smell, thanks I carry Drogo in the torch, Ser Alliser saw only seven hells was a nimbus of the flapping overhead from the brothel.
I remember, she knew times, that I'd imagine that happen this time of children? Yes, three acres of sight Tyrion gazed at once.
And now? Lord Vance are enough when Arya began to boiling on Stark.
Go? the bowels, tucked them myself.
The bogs of the silver.
The world.
Another voice was a hundred tourneys.
The hospitality of blood flew to.
They came whistling.
She touched your head had closed his forked yellow pages of mail like a weight of the flush with an eyebrow.
Too old gods are ofttimes wonder.
The arm and the day with the words have some cook boy was running down his voice that halfbored, around, filled and Jhiqui would be all.
Spit on all.
Ser Rodrik or Syrio stepped up at his throat.
Why shouldn't be better man was something here.
He wrote one made him, bleed off gently.
She still his eyes to be salt sea, I am the Night Watch.
I counseled patience.
Sister, Arya said they know what she has already dead? Mormont apologized to come to hear them privately, Tyrion waddled over a loss.
Praying that it.
All that much to return to be sure stroke.
Oh, he answered.
</source>
 
[[Category:Prototyping]]
[[Category:Markov chants]]

Latest revision as of 11:42, 21 June 2011

The Code

import random

f = open ("cleangame.txt", "r" )
s = f.read()
words = s.split()
nextwords = {}

for (i,w) in enumerate(words):
	if i < len(words)-1:
		nword = words[i+1]
		if w in nextwords:
			nextwords[w].append(nword)
		else:
			nextwords[w] = []
			nextwords[w].append(nword)

first = random.choice(nextwords.items())
newText = []
newText.append(first[0].capitalize())
current = first[0]

while len(newText) < 500:
	currentList = nextwords[current]
	next = random.choice(currentList)
	newText.append(next)
	current = next

game = ""
punctuation = ['.',';',',','?','!',':']
for w in newText:
	if w in punctuation:
		if w == ".":
			game += w + "\n"
		else:
			game += w
	else:
		game += " " + w
print game

The Result

 Lowering his broad grassy horse made anew.
 Nymeria.
 The wildlings and lowered his brother.
 My thanks, I feel it or corn, no more anxious.
 I Ser Willis mounted up, no doubt he killed him, echoed.
 And the young princes were true, she said of his furs and smoking star charts hung at him be curious look a stupid sister, the gate.
 As soon as his sister, working at the ship made her bare to Aegon high on them get a moment that understood that would do.
 This man strange and the empty.
 Another snared his up those daughters.
 Wine? I thought, and pleaded with a triangular shield, striped horses that it cling to the sharp enough coin.
 I were bannermen on it, with Lady Lysa Arryn was fighting with both you think I'd rather than it, and looked behind a steward told Arya liked the size of the sun.
 He wondered whether he smelled the armor were soft knock you? Ser Rodrik went through the poppy.
 She was lapping of your mild.
 Oh, the Wall behind him jump, could dance here.
 No, grievously wounded and honored for a black bog where the drape of shadowcats behind masks.
 My lord.
 Syrio, my hands bleeding from the smell, thanks I carry Drogo in the torch, Ser Alliser saw only seven hells was a nimbus of the flapping overhead from the brothel.
 I remember, she knew times, that I'd imagine that happen this time of children? Yes, three acres of sight Tyrion gazed at once.
 And now? Lord Vance are enough when Arya began to boiling on Stark.
 Go? the bowels, tucked them myself.
 The bogs of the silver.
 The world.
 Another voice was a hundred tourneys.
 The hospitality of blood flew to.
 They came whistling.
 She touched your head had closed his forked yellow pages of mail like a weight of the flush with an eyebrow.
 Too old gods are ofttimes wonder.
 The arm and the day with the words have some cook boy was running down his voice that halfbored, around, filled and Jhiqui would be all.
 Spit on all.
 Ser Rodrik or Syrio stepped up at his throat.
 Why shouldn't be better man was something here.
 He wrote one made him, bleed off gently.
 She still his eyes to be salt sea, I am the Night Watch.
 I counseled patience.
 Sister, Arya said they know what she has already dead? Mormont apologized to come to hear them privately, Tyrion waddled over a loss.
 Praying that it.
 All that much to return to be sure stroke.
 Oh, he answered.