#NEWLINE# def create_background( life ) : #NEWLINE# #INDENT# HISTORY = [ ] #NEWLINE# HAS_BIRTH_PARENTS = ( random . randint ( 0 , 1 ) == 1 ) #NEWLINE# WAS_ADOPTED = ( ( random . randint ( 0 , 1 ) * ( not HAS_BIRTH_PARENTS ) ) == 1 ) #NEWLINE# PARENTING_QUALITY = ( numbers . roll ( 2 , 3 ) * ( HAS_BIRTH_PARENTS or WAS_ADOPTED ) ) #NEWLINE# BULLIED = ( random . randint ( 0 , 1 ) == 1 ) #NEWLINE# FOUGHT_BACK = ( random . randint ( 0 , 1 ) == 1 ) #NEWLINE# GRADUATED = ( numbers . roll ( ( HAS_BIRTH_PARENTS + WAS_ADOPTED ) , 5 ) >= 5 ) #NEWLINE# STREET_SMART = ( ( random . randint ( 0 , 1 ) * ( not GRADUATED ) ) == 1 ) #NEWLINE# MAX_BOOK_SMART = ( 1 + ( not STREET_SMART ) ) #NEWLINE# MAX_STREET_SMARTS = ( 1 + STREET_SMART ) #NEWLINE# MATHEMATICS = numbers . roll ( MAX_BOOK_SMART , 5 ) #NEWLINE# READING = numbers . roll ( MAX_BOOK_SMART , 5 ) #NEWLINE# ENGINEERING = numbers . roll ( MAX_BOOK_SMART , 5 ) #NEWLINE# FIREARMS = numbers . roll ( MAX_STREET_SMARTS , 5 ) #NEWLINE# MELEE = numbers . roll ( ( FOUGHT_BACK + STREET_SMART ) , 5 ) #NEWLINE# TRADING = numbers . roll ( ( ( MAX_STREET_SMARTS + MAX_BOOK_SMART ) - ( MATHEMATICS < 5 ) ) , 2 ) #NEWLINE# IS_LEADER = ( numbers . roll ( ( ( ( 2 < PARENTING_QUALITY <= 4 ) or FOUGHT_BACK ) + ( GRADUATED or STREET_SMART ) ) , 4 ) >= 4 ) #NEWLINE# SELF_ABSORBED = ( numbers . roll ( ( ( PARENTING_QUALITY >= 5 ) + ( MAX_BOOK_SMART == 1 ) ) , 5 ) >= 7 ) #NEWLINE# LONE_WOLF = ( ( numbers . roll ( ( SELF_ABSORBED + STREET_SMART ) , 5 ) * ( not IS_LEADER ) ) >= 5 ) #NEWLINE# PATIENCE = numbers . roll ( ( ( GRADUATED or STREET_SMART ) + ( ( READING >= 5 ) or ( PARENTING_QUALITY >= 3 ) ) ) , 5 ) #NEWLINE# INTROVERSION = ( ( ( LONE_WOLF + ( ( not HAS_BIRTH_PARENTS ) and ( not WAS_ADOPTED ) ) ) + ( not STREET_SMART ) ) + ( BULLIED and ( not FOUGHT_BACK ) ) ) #NEWLINE# EXTROVERSION = ( 3 - INTROVERSION ) #NEWLINE# MOTIVE_FOR_CRIME = numbers . roll ( ( ( ( ( ( READING < 7 ) + ( ( FIREARMS > 6 ) or ( MELEE > 5 ) ) ) + ( ( TRADING > 5 ) or SELF_ABSORBED ) ) + ( not LONE_WOLF ) ) + ( BULLIED or IS_LEADER ) ) , 2 ) #NEWLINE# MOTIVE_FOR_WEALTH = numbers . roll ( ( ( ( TRADING > 4 ) + ( MATHEMATICS > 4 ) ) + ( ( PATIENCE > 5 ) or IS_LEADER ) ) , 3 ) #NEWLINE# MOTIVE_FOR_SURVIVAL = numbers . roll ( ( ( ( ( FIREARMS > 5 ) or ( MOTIVE_FOR_WEALTH < 5 ) ) + ( ( MELEE > 5 ) or ( PATIENCE > 5 ) ) ) + ( ( ENGINEERING > 5 ) or IS_LEADER ) ) , 3 ) #NEWLINE# SOCIABILITY = numbers . roll ( ( ( ( ( not SELF_ABSORBED ) + ( not LONE_WOLF ) ) + ( EXTROVERSION > 0 ) ) + ( IS_LEADER * 2 ) ) , 2 ) #NEWLINE# TRUSTINESS = numbers . roll ( ( ( ( ( LONE_WOLF + ( TRADING > 4 ) ) + ( MOTIVE_FOR_WEALTH > 4 ) ) + ( not SELF_ABSORBED ) ) + ( EXTROVERSION > 1 ) ) , 2 ) #NEWLINE# if ( not HAS_BIRTH_PARENTS ) : #NEWLINE# #INDENT# HISTORY . append ( 'Lost his parents in late childhood' ) #NEWLINE# #UNINDENT# if WAS_ADOPTED : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += ', but was later adopted' #NEWLINE# #UNINDENT# if ( PARENTING_QUALITY >= 3 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Was raised well' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if PARENTING_QUALITY : #NEWLINE# #INDENT# HISTORY . append ( 'Was raised poorly' ) #NEWLINE# #UNINDENT# #UNINDENT# if BULLIED : #NEWLINE# #INDENT# if ( 'well' in HISTORY [ ( len ( HISTORY ) - 1 ) ] ) : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += ', but was bullied' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'poorly' in HISTORY [ ( len ( HISTORY ) - 1 ) ] ) : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += ', and was bullied' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# HISTORY . append ( 'He was bullied' ) #NEWLINE# #UNINDENT# #UNINDENT# if FOUGHT_BACK : #NEWLINE# #INDENT# if ( ',' in HISTORY [ ( len ( HISTORY ) - 1 ) ] ) : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += ' (he fought back)' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if GRADUATED : #NEWLINE# #INDENT# HISTORY . append ( 'Graduated' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if STREET_SMART : #NEWLINE# #INDENT# HISTORY . append ( 'Is street smart' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( MATHEMATICS >= 5 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Is good at math' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( MATHEMATICS <= 2 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Is bad with numbers' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( READING >= 5 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Can read very well' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( READING <= 3 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Was not hooked on phonics' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ENGINEERING >= 5 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Is proficient at engineering' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ENGINEERING <= 3 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Has poor engineering skills' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( FIREARMS >= 5 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Knows his way around a gun' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( FIREARMS <= 3 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Has shaky aim' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( MELEE >= 5 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Can fight very well' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( MELEE <= 3 ) : #NEWLINE# #INDENT# if ( 'gun' in HISTORY [ ( len ( HISTORY ) - 1 ) ] ) : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += ", but can't hold his own in a fist fight" #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# HISTORY [ ( len ( HISTORY ) - 1 ) ] += " and can't fight" #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if IS_LEADER : #NEWLINE# #INDENT# if SELF_ABSORBED : #NEWLINE# #INDENT# HISTORY . append ( 'Would rather lead than follow' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# HISTORY . append ( 'Is a fine leader' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if LONE_WOLF : #NEWLINE# #INDENT# HISTORY . append ( 'Prefers to work alone' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( PATIENCE >= 7 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Patient' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( PATIENCE <= 3 ) : #NEWLINE# #INDENT# HISTORY . append ( 'Very impatient' ) #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# 'mathematics' : MATHEMATICS , #NEWLINE# 'reading' : READING , #NEWLINE# 'engineering' : ENGINEERING , #NEWLINE# 'firearms' : FIREARMS , #NEWLINE# 'melee' : MELEE , #NEWLINE# 'trading' : TRADING , #NEWLINE# 'is_leader' : IS_LEADER , #NEWLINE# 'self_absorbed' : SELF_ABSORBED , #NEWLINE# 'lone_wolf' : LONE_WOLF , #NEWLINE# 'patience' : PATIENCE , #NEWLINE# 'trustiness' : TRUSTINESS , #NEWLINE# 'sociability' : SOCIABILITY , #NEWLINE# 'psychotic' : False , #NEWLINE# 'description' : ( '. ' . join ( HISTORY ) + '.' ) , #NEWLINE# 'motive_for_crime' : MOTIVE_FOR_CRIME , #NEWLINE# 'motive_for_wealth' : MOTIVE_FOR_WEALTH , #NEWLINE# 'motive_for_survival' : MOTIVE_FOR_SURVIVAL , #NEWLINE# #UNINDENT# }