User:Laura Macchini/prototyping/gameofthrones generator: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
<code lang="python"> | |||
#cleangame.py | |||
import random | |||
f = open ("cleangame.txt", "r" ) | |||
s = f.read() | |||
words = s.split() | |||
counter = 0 | |||
nextwords = {} | |||
for word in words: | |||
if counter < len(words)-1: | |||
nword = words[counter+1] | |||
if word in nextwords: | |||
nextwords[word].append(nword) | |||
else: | |||
nextwords[word] = [] | |||
nextwords[word].append(nword) | |||
counter+=1 | |||
first = random.choice(nextwords.items()) | |||
newText = [] | |||
newText.append(first[0]) | |||
current = first[0] | |||
while len(newText) < 500: | |||
currentList = nextwords[current] | |||
next = random.choice(currentList) | |||
newText.append(next) | |||
current = next | |||
game = "" | |||
for word in newText: | |||
game += " " + word | |||
print game | |||
</code> | |||
<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 | <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 | ||
</nowiki> | </nowiki> |
Revision as of 01:03, 24 May 2011
- cleangame.py
import random
f = open ("cleangame.txt", "r" )
s = f.read()
words = s.split()
counter = 0
nextwords = {}
for word in words:
if counter < len(words)-1:
nword = words[counter+1]
if word in nextwords:
nextwords[word].append(nword)
else:
nextwords[word] = []
nextwords[word].append(nword)
counter+=1
first = random.choice(nextwords.items())
newText = []
newText.append(first[0])
current = first[0]
while len(newText) < 500:
currentList = nextwords[current]
next = random.choice(currentList)
newText.append(next)
current = next
game = ""
for word in newText:
game += " " + word
print game
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