Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import sys
- import math
- import random as rand
- # The end result is intended to look like a list name House
- # that contains objects inside representing each floor. These
- # objects should also contain the rooms, which should contain
- # k-v pairs representing the type of room, as well as where
- # the windows and doors are positioned in the walls of the room
- # as shown below.
- # House = [Floor1, Floor2, Floor3]
- # Floor1 = [Room_1, Room_2, Room_3, Room_4, staircase_1]
- # Room_1 = {rType : Kitchen, door_1 : middle,
- # door_2 : outside, window : center}
- # staircase_1 = (bottom)
- door_pos = ['inside', 'middle', 'outside']
- window_pos = ['left', 'center', 'right']
- stair_pos = ['top', 'left', 'bottom', 'right']
- room_type = ['Bathroom_1', 'Bathroom_2', 'Kitchen', 'Livingroom', 'Bedroom_1', 'Bedroom_2', 'Master_Bedroom', 'Master_Bathroom']
- House = []
- Floor1 = []
- Floor2 = []
- Floor3 = []
- Room_1 = {}
- Room_2 = {}
- Room_3 = {}
- Room_4 = {}
- def Room1Gen():
- rtype = rand.sample(room_type, 1)
- door_1 = rand.sample(door_pos, 1)
- door_2 = rand.sample(door_pos, 1)
- window = rand.sample(window_pos, 1)
- Room_1['rtype'] = rtype[0]
- Room_1['door_1'] = door_1[0]
- Room_1['door_2'] = door_2[0]
- Room_1['window'] = window[0]
- for i in Room_1:
- yield Room_1[i]
- def Room2Gen():
- rtype = rand.sample(room_type, 1)
- door_1 = rand.sample(door_pos, 1)
- door_2 = rand.sample(door_pos, 1)
- window = rand.sample(window_pos, 1)
- Room_2['rtype'] = rtype[0]
- Room_2['door_1'] = door_1[0]
- Room_2['door_2'] = door_2[0]
- Room_2['window'] = window[0]
- for i in Room_2:
- yield Room_2[i]
- def Room3Gen():
- rtype = rand.sample(room_type, 1)
- door_1 = rand.sample(door_pos, 1)
- door_2 = rand.sample(door_pos, 1)
- window = rand.sample(window_pos, 1)
- Room_3['rtype'] = rtype[0]
- Room_3['door_1'] = door_1[0]
- Room_3['door_2'] = door_2[0]
- Room_3['window'] = window[0]
- for i in Room_3:
- yield Room_3[i]
- def Room4Gen():
- rtype = rand.sample(room_type, 1)
- door_1 = rand.sample(door_pos, 1)
- door_2 = rand.sample(door_pos, 1)
- window = rand.sample(window_pos, 1)
- Room_4['rtype'] = rtype[0]
- Room_4['door_1'] = door_1[0]
- Room_4['door_2'] = door_2[0]
- Room_4['window'] = window[0]
- for i in Room_4:
- yield Room_4[i]
- room1 = Room1Gen()
- room2 = Room2Gen()
- room3 = Room3Gen()
- room4 = Room4Gen()
- try:
- for i in range(5):
- next(room1)
- next(room2)
- next(room3)
- next(room4)
- except StopIteration:
- pass
- Floor1.append(Room_1)
- Floor1.append(Room_2)
- Floor1.append(Room_3)
- Floor1.append(Room_4)
- House.append(Floor1)
- print('These are the rooms in Floor 1:')
- print(Floor1, '\n \n')
- print('Here are the floors in the House:', end=' ')
- print(House)
Add Comment
Please, Sign In to add comment