my python story generator

here is my python story generator I made.Just run it over and over in python and a different story is made.:slight_smile:

http://pasteall.org/697934/python

mystory should have more than a one choice.

I wanted to try too


import random


who = ['3D Artist','Blender Master','Houdini artist','After Effects idiot',
       'NukeX PRO','Maya Master','Fusion Artist']
constant = 'is'
space = ' '
doingWhat = ['drinking coffee','drinking juice','sleeping']
constantEnd = 'while rendering is done.'


print(random.choice(who)+space+constant+space+random.choice(doingWhat)+space+constantEnd)

mystory has two choices.Didn’t you see that.

this is fun isn’t?does anyone else want to post their random story generator.

Sorry about that, but yes, this is fun.

I added something else.

import random

print('man find himself in a strange place.with old delapedated buildings and a old road.then wonders where he is.')
mystoro = ['faints','cry','dies','bleed','night']
mystory = ['picks up a metal pipe hits monster with it.And it just laughs at him.Then picks him up and throws him up against a wall.','runs away from monster.Then gets in the car he finds.then hot wires it.then drives away real quick real quick.']
p = random.choice(mystory)  
x = random.choice(mystoro)

dead = 'die'
startled = 'faint'
sadness = 'cry'
blood = 'bleed'
time = 'night'
if dead in x:
    print('then the man sees green gas around him') 
    print(' then the man ' + x + ' of the poison five minutes later' )
    
elif startled in x:
    print('man finds his wife in a puddle of her own blood ')
    print('man ' + x + ' when he sees the blood')
elif sadness in x:
    print('then he sees monster engulfs then eats wife.')
    print('monster says i really enjoyed seeing you ' + x)
    print(p)
elif blood in x:
    print('a long nail shoots into the mans leg out of nowhere and he starts to ' + x)
    print('then he starts crying because of the pain') 
elif time in x:
    print('man realizes it is ' + x + ' then gets sleepy.')
    print('then he opens the door of one of the old delapedated buildings then goes then shuts the door behind him.Cuts on the light.')
    print('then searches three of the rooms finds a bed in one.then cuts on the light in the room.removes the cobwebs from the bed.')
    print('takes off his shoes,pants and shoes.then lays down.then sprains his groing muscle while laying on his front.')

here is game I made with python.
I mainly like making games with python.And I also made a rudimatry chatbot.I make chatbots on botlibre and personality forge.

def fighter():
    hitfitness = 90
    enemyfitness = 90
    print("you are walking in the semitary at night with your girlfriend ghosthunting.")
    print('vampire with long claws attacks you.', end='

')
   
    while hitfitness > 0 and enemyfitness > 0:
        print("your health is {0}.".format(hitfitness))
        print("the vampire's health is {0}.".format(enemyfitness), end='

')
        print('The vampire claws you with its claw!', end='

')
        print('how do you attack the vampire? Garlic, Holywater, Stake, sunlamp, fire')
        attack = input('>> ').strip().lower()
        if attack == 'stake':
               
             hitfitness -= 10  
             print("you staked it through the heart it does not die!")
            
        elif attack == 'garlic':
             
             hitfitness -= 10     
             enemyfitness -= 30
        elif attack == 'holy water':
             hitfitness -= 10
             enemyfitness -= 23
        elif attack == 'sunlamp':
             hitfitness -= 20
             enemyfitness -= 80             
        elif attack == 'fire':
             hitfitness -= 20
             enemyfitness -= 100                  
        else:
            hitfitness -= 10 
            print("wrong choice") 


    if hitfitness <= 0 and enemyfitness <= 0:
        print("Draw!")
    if hitfitness <= 0:
        print("the vampire changes you into a vampire")
    else:
        print("the vampire dies on fire!")
fighter()
def fightmonster():
    hitme = 90
    enemyslime = 150
    print("you are walking in the semitary at night with your girlfriend ghosthunting.")
    print('a giant red slimy slug shoots slime attacks you.', end='

')
   
    while hitme > 0 and enemyslime > 0:
        print("your health is {0}.".format(hitme))
        print("the giant red slimy slug health is {0}.".format(enemyslime), end='

')
        print('The giant red slimy slug shoots pink slime at you!', end='

')
        print('how do you attack the red slimy slug? gun, Holywater, Stake, sunlamp, fire')
        attack = input('>> ').strip().lower()
        if attack == 'stake':
               
             hitfitness -= 10  
             print("you stake it and it does not die!")
             print("you feel a short pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")
        elif attack == 'Holywater':
             hitme -= 10     
             print("you feel a short pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")             
        elif attack == 'holy water':
             hitme -= 10
             print("you feel a short pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")             
        elif attack == 'gun':
             hitme -= 10
             enemyslime -= 80             
             print("you feel a short pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")
        elif attack == 'fire':
             enemyslime -= 100                  
             print("you feel a even worse pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")
        elif attack == 'stake':
             hitme -= 30   
             print("you feel a even worse pain when the large slimy slug shoots slime at you!")
             print("but you realise you are not hurt when it wears off!")
             print("you feel a little disorientated!")
        else:
             hitme -= 10 
             print("wrong choice") 


    if hitme <= 0 and enemyslime <= 0:
        print("Draw!")
    if hitme <= 0:
        print("you feel even greater pain before you die")
    else:
        print("the giant red slimy slug dies!")
fightmonster()
from random import choice
fighter()
fights = [fighter, fightmonster]
choice(fights)()

here is a guessing game i made.I am going to modify it to limit the amount of guesses you will.
have

import random
mystoro = ['faints','cry','dies','bleed','night']
x = random.choice(mystoro)
correct = False
while not correct:
    guess = input("What could it be? choices are faints,cry,dies,bleed ot night. ")  # ask as long as answer is not correct
    if guess in x:
        print ("you finally guessed it")
        correct = True
    
    else:
        print ("guess again")

I would like to see more of your programs.

here is a improved guesses game i made.You can try it.

import random
timethis = 100
mystoro = ['faints','cry','dies','bleed','night']
x = random.choice(mystoro)
correct = False
while not correct and timethis > 0:
    guess = input("What could it be? choices are faints,cry,dies,bleed ot night. ")  # ask as long as answer is not correct
    print("you get ten chances 10 and have a {0} points.".format(timethis))
    if guess in x:
        print ("you finally guessed it")
        correct = True
    
    else:
        timethis -= 10
        if timethis <= 0:
                   print ("no more guesses")

:slight_smile:

here is another guessing game with a different out come every time you loose.

import random
timewalk = 100
myrooms = ['room1','room2','room3','room4','room5']
deathend = ['you fall through the floor and get eaten by zombies','zombie dogs run up behind you then eat you','you open the wrong door and twenty zombies rush in and then eat you']
o = random.choice(deathend)
x = random.choice(myrooms)
youright = False
while not youright and timewalk > 0:
    whichone = input("Which room should you open to escape from the zombies? choices are room1,room2,room3,room4,room5. ")  # ask as long as answer is not correct
    print("you get ten chances 10 and have a {0} points.".format(timewalk))
    if whichone in x:
        print ("you see a room with another door.you open that door get your car and drive off")
        youright = True
    
    else:
        timewalk -= 10
        if timewalk <= 0:
          

           print (o)

here is how to store what the user types into a list.but if it is already in the list the program tells you.It temporarily store the information only while you run it.Storing the information in a text file would be permanent.

store=[]
b=0
while 5:
            b+=5
            objecter=input('Enter objecter %d: '%b)
            if objecter=='':
               break
            if objecter not in store:store.append(objecter)
            else: print("Already in list!")
            print(store)

:yes:

this script puts what a user types into a list and if bob is in the list it displays the message bob is here.
It also stores what the user types into a text file.there is one problem with this.it will
make the text file blank every time you run it.That is undesirable to me.I want the strings to be stored permanently.

more = []
s=0
while 1:
            
            isfile = open('remembermy.txt', 'w')
            s+=5
            objecta=input('Enter objecta %d: '%s)
            if objecta=='':
               break
            if objecta not in more:more.append(objecta)

            else: print("Already in list!")
            
            for item in more:
                isfile.write("%s
" % item)   
            
            print (more)
            if 'bob' in str(more):
                   print("bob is here")

isfile.close()

:slight_smile:

Which ide are you using ?

I use just idle

python idle.what i am trying to do is to make a chatbot that remembers permanently what it randomly
chooses.Eventually i want figure out how to have a chatbot have it’s own lifestory.

I don’t know…
I have had it in a different kind of program,
but it was something like

  1. make list
  2. load everything from file to list
  3. add to list
  4. save the list into the same file
  5. close the list
    and it would run it like every time the program runs through a loop
    “with” keyword makes it so that file automatically closes

still waking up… coffee and fast

The python program i posted in post 14 does all of those except the last one.The only problem i have is when i run it again it erases the text file.could you tell me what the problem is?

isfile = open('remembermy.txt', 'w')

This is the problem. You are opening a file for writing which will overwrite the existing file. If you just want to add lines to a file you should open it for appending with:

isfile = open('remembermy.txt', 'a')

thankyou I will try that.