KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Recently, I've been attempting to defeat one of my main weaknesses in programming in general, random generation. I thought it would be an easy thing to do, but the lack of simple information is killing me on it. I don't want to sound dumb, but it feels to me like most of the information from places like this are written for mathematicians who went to college to graduate in theoretical mathematics. I just don't understand what I'm meant to do with that information in order to apply it to programming in a language such as python. I've been working a few days staring at equations and attempting attempt after attempt, but still after all those days, after ripping my code apart again and again, all that's been working properly this entire time is this noise generator to generate basic noise: import random import math random.seed(0) def generateWhiteNoise(width,height): noise = [[r for r in range(width)] for i in range(height)] for i in range(0,height): for j in range(0,width): noise[i][j] = random.randint(0,1) return noise noise = generateWhiteNoise(50,12) for i in noise: print() for o in i: if(o == 0): print('-',end='') else: print('#',end='') This code produces this result: ##-######--#--#-#--##-###-###---#-##-#-----#--##-# #-#-##-##-#----##------##--#####-#-##---#--#-##--- -------#-#------#---#-#---###--#--#-###-----##-#-- ######--#-#-#--####-###---#---###-##--#-#-##--#### -#----###--------##--##--##-#-#--#----###-####--## ---####-#--#--###-#-#--#--#####--####-#-##-##--#-- ----#--####-#-#-#-#-#---#--###------###--#-######- --###--#-###-------#-##--###---#-####----###-##### #----##--##-#--##-###--#----#-#-##--##-#-##---###- ##---##----##--##--#--#--###-###-#--#-##---#------ -##----#-###---######---#-#---#---###---#---###-## #--##-##-
Tags (comma-separated)
Save Edits
Cancel