[ot|[spam][crazy] Struggles with OOP and Trees
let's _use_ an object-oriented data structure maybe to plot a graph. this is hard for me to do now. oh no what language. maybe python because i'm familiar with it. class Node: def __init__(self, parent = None): self.children = [] self.parent = parent y'know, this is so hard for me to do, maybe I should get to know a data structures library in every language.
Purportedly, https://networkx.org/ provides python data structure abstractions. Uncertain.
Maybe it's nice to assume I already implemented a data structure. Something I played with when an adolescent was simple particle systems. Local updates: # particle def update(self, ms): self.vel += self.accel * ms self.pos += self.vel * ms # container def update(self, ms): for particle in self.particles: particle.update(ms) Global updates: def update(self, ms): for particle in self.particles: particle.vel += particle.accel * ms particle.pos += particle.vel * ms How could we apply graphs to it? Maybe we could handle more particles at once by updating only those within a moving region. Would this use graphs? what would be needed ... - each particle would have a time of last update - the update function would use calculus - updates would generate and destroy batches of particles based on lifetime Seems more like lists than graphs. What if there are multiple windows? No, just makes multiple lists. We'd better make the particles have a hierarchy of reference frames, to use a graph structure I suppose. I'm happy I wrote the particle update code above. Quite hard for me.
Hierarchical particles. When I was an adolescent I made 3d graphics engines a lot, so I'm probably remembering the object and transformation hierarchies they have, a little. def update(self, ms): for child in self.children: child.update(ms) self.pos += I think I'd like to figure out how to integrate a constant acceleration. There are also libraries for symbolic integration, I understand. I guess for now I'll just write the same old thing. def update(self, ms): for child in self.children: child.update(ms) self.pos += self.vel * ms self.vel += self.accel * ms self.age += ms --- Maybe it could be nice to write some code to transform between graphs and property matrices. Trying to keep the code small and abbreviated enough to consider using it. I'm imagining maybe the properties of objects would refer to a matrix. @property def pos(self): return self.prop_matrix[self.particle_index, 0:3] Seems it could be helpful, if the code is reusable, to define a mapping between names and ranges of a property vector. Let's think about how this could be used. I could write the update function once on all the particles, if I used operators that broadcast over the particle index. I'm wondering whether to have the index be the first or second dimension. I'm considering trying the first because the transformers library uses the first dimensions as batch dimensions.
Another thing I made as an adolescent was text and point-and-click adventure games. I'm thinking on how one might make a very simple adventure game that used some kind of intelligence to provide for arbitrary creative actions of the user. It could be based on language models or property graphs or user suggestion or anything, but somehow we want to use graphs/tree structures. cause they're hard.
Back to graphs. Let's draw a graph! Like a map! Or maybe even just plot a single pixel. The plotting code could have a comment on it that's all "I wish I were a particle!" I've occasionally made systems that output interactive graphics since 2013 happened. I made a webgl renderer that draws an interactive environment of spheres by calculating the ellipses that form their edges. I worked a little on a genetic graph display system for the center for disease control of my country. Very rare work, done for free and fun. I haven't looked at these things for some time. Presently I'm near a raspberry pi and an android phone. Both of these seem difficult and different from each other, to do pixel plotting on, but I could be wrong. Usually graphics are done with a library with many api calls, and a number of verbose setup and teardown routines, that interfaces with graphics hardware and abstracts it. I'd like to plot some data interactively, ideally, and I'd like to reuse code I write, somehow.
On Fri, Mar 18, 2022, 9:05 AM Undiscussed Horrific Abuse, One Victim of Many <gmkarl@gmail.com> wrote:
Back to graphs.
Let's draw a graph! Like a map!
Or maybe even just plot a single pixel. The plotting code could have a comment on it that's all "I wish I were a particle!"
I've occasionally made systems that output interactive graphics since 2013 happened.
I made a webgl renderer that draws an interactive environment of spheres by calculating the ellipses that form their edges.
I worked a little on a genetic graph display system for the center for disease control of my country. Very rare work, done for free and fun.
To clarify, this was work I hunted down while searching for something that stimulated my issues the least. I became a brief patriot for relief.
I haven't looked at these things for some time. Presently I'm near a raspberry pi and an android phone. Both of these seem difficult and different from each other, to do pixel plotting on, but I could be wrong.
Usually graphics are done with a library with many api calls, and a number of verbose setup and teardown routines, that interfaces with graphics hardware and abstracts it.
I'd like to plot some data interactively, ideally, and I'd like to reuse code I write, somehow.
--- Maybe an easier idea is to make or use an ascii graphics library. Existing libraries probably use OOP and trees. --- Maybe it could be nice to think about making an ascii art library I could reuse, written in C. No, maybe it makes more sense to search for one. -- Maybe it's nice to think about cleaning up code I've already written. It would be nice to be stable enough to maintain a library.
Another concept near here is the idea of scraping ecommerce sites so as to make the "sort by price" button actually work. It's pretty satisfying I wrote the small particle code, though. Maybe I'll make a small personal display library.
What's a barebone's ascii display class in python? import os class Display: def __init__(self, cols = os.environ.get('COLUMNS', 80), lines = os.environ.get('LINES', 50): self.backbuffer = np.full((cols, lines), ' ') def clear(self): self.backbuffer = ' ' def plot(self, x, y, char='X'): self.backbuffer[x,y]=char def blit(self): for line in self.backbuffer: print(''.join(line)) It could be greatly improved.
to get screen size, use curses: import curses curses.setupterm() lines = curses.tigetnum('lines') cols = curses.tigetnum('cols') curses also has functions for other graphical operations
Look around
You are about to be slaughtered by a ridiculous ascii graphics python class. It looks like it was written by a high school student for introductory homework. Do you: 1. fight 2. run away ?
run away
You try to run but the ridiculous ascii graphics python class catches you with its giant maw and huge pointed claws.
fight
How will you fight such a monstrosity?
python classes do not have giant maws nor huge pointed claws. escape and come to terms with the code
You upload a silly ascii graphics python class to the internet. What now?
use the python class to animate a particle system and draw a graph
* android apps On Fri, Mar 18, 2022, 10:13 AM Undiscussed Horrific Abuse, One Victim of Many <gmkarl@gmail.com> wrote:
also, kivy has an sdl backend, and kivy can make python apps
On Fri, Mar 18, 2022, 10:12 AM Undiscussed Horrific Abuse, One Victim of Many <gmkarl@gmail.com> wrote:
note: sdl has an aalib backend. sdl can draw to ascii terminals.
OK. Let's make gfx into a python package so it can be installed. Then a particle generator or graph draw-er can be in some separate place. Or they could use symlinks.
participants (1)
-
Undiscussed Horrific Abuse, One Victim of Many