Posts

Showing posts from May, 2018

bubbles pygame collision shading 2D

I'm sure I'll alter this a ton more times, but here's a video of the pygame code I wrote,  below it is the code.  It's on Github, use it, have fun!  Color pallette should be easy to manipulate. Just remember no negative values, and max is 255 for RGB in the (R, G, B) tuple. Code:   bubbles.py #!usr/bin/python3 # -*- coding: utf-8 -*- import pygame as pg (width, height) = (800, 800) background_color = (90, 100, 110) pg.init() screen = pg.display.set_mode((width, height)) pg.display.set_caption(('ClaustrOphobia')) screen.fill(background_color) animation_timer = pg.time.Clock() pg.display.flip() class Bubble (object):     def __init__(self, my_screen, R,G,B, pos_x, pos_y, radius, thickness, speed):         self.my_screen = my_screen         self.pos_x = pos_x         self.pos_y = pos_y         self....

pygame move collide circles

Image
6-2-2020: Update, removing the original code, and placing in a slightly refactored and cleaned up code block. I'm currently trying to play with the idea of a JavaScript collision detection piece of code for drawing on canvases and games, and came back to this piece to refresh my memory.   I ran the code, and it still just needs 'pygame' for it to run with Python 3 +.   The bubbles are set at high speed, so that I could test that the list cleared, and the screen started new when 200 bubbles were populating the screen area. The main idea of doing this code was discover how in a GUI environment the code can detect and alter an item based on where it is on the screen.   I will hopefully be updating this a bit more soon, but wanted to drop in and clean the code for this up a bit since I was looking through it anyways. The background color can be altered without any effect on the bubbles. The bubble colors are set to stay below 240 on the 0-255 RGB scale,...

Using most frequent letters used as root in TST

https://www.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html Still haven't worked on getting these links working. I really don't want to touch the blog html until I understand what I'm doing and to what #the most frequent letters used in english in order: ETAOINSR #average word length = 7.6 #using ETAOINSR as root, should result in a more balanced TST tree #make that 'ointesra' so that E and T are in the middle. Ok, I think if your making a search tree for strings, the best thing to do would be use these letters as a root in some way. I have to test it, but I'll update when I get some data. For the TSTree were using in class, It only compares the first letter of the root to decide equal, high and low. So basically, if I'm just analyzing english text, I'd want my root to be 'E', as most frequently used english letter, I'd think that would distribute the highs and lows most evenly. If its a whole string it's compa...

back to LMPTHW

Image
Started working on the next exercise for class again, ((signed back up after realizing how regardless of issues stopping me from going at the speed I was,  I should continue)) Ternary search trees.  In the process of memorizing some code for it, I always have to understand what it is I'm comiting to memory, or It will almost never stick in my head. Not sure WHAT I'm doing wrong... but if I figure it out I'll update. It's not working at all like I thought.... So here's a pic of what I'm getting, and the code for my print will be below it.   *I think I'm setting the key,value wrong* update: OHHHH.... ok figured it out.  the high lo isn't set until you add more strings...... and then we have a high low....  Updating print method at bottom. So... why set the root as all the eq's?  hrmmm.... The actual TSTree code is part of class, so I'm not going to put it in until I can get my own wacky version written to see if I can explain it. ...

testing list comprehension, iteration fail

Image
I added a few lines for testing, to try and sauce out what the hell the computer is doing to lock up, Just by adding these tools, it made it possible for me to CTRL C on my laptop easier,  I won't try anymore on my alienware, I've had to force shut it down too many times, I don't want to wreck it. I have a theory that python is eating up memory and processing so fast that CTRL^C can't stop it easily.  Maybe that's why the laptop is easier to stop?  It's slow ass anyways?  The alienware is faster and more memory though... Wish I knew what the hell this is,  I mean, I know it's an infinite loop, but it's just a damn string, isn't it?  ... Is it the for loop in the list maker that is storing up the mem?  I'll do more tests and try to update what I find.  Here's a couple of pictures,  if anyone could tell me why that stupid little itertooly I made is eating up the CPU space/process so bad I'd love to know.  ---  Nellie smashes CT...

trying to find loop nodes with iteration

Ok, so before you waste time, it was a fail. But i still think it can be done... I gotta walk away for a bit.  The things I looked up about iteration said it is faster on large data, and saves memory on large data... So there was this codewars to figure out how to get to a loop point in a linked list, and find out the size of the loop, that's what I was trying to do...(faster then my original solution or solutions with while loops) but I'm missing something.  Anyhoo!   If your playing with these just remember if you make an infinite loop in the IterTool class, you may lock your computer up.  Fair warning.  class NodeX(object):     def __init__(self, value, link):         self.value = value         self.link = link class IterToolNode(object):     def __init__(self, start):         self.start = start       ...

playing with iteration

Image
Ok, so today started with, I want to break some list comprehensions, but turned into, 'What is this bit of joy?' A stackOverflow post: https://stackoverflow.com/questions/19151/build-a-basic-python-iterator Totally seeing what I can make this do, cause... why not! UPDATE!  I locked up my computer trying to do this: DO NOT DO THIS.  lol....  here's what locked me up: (see yellow highlighted code) update: After much oh shitness,  I got the Itertooly fixed. I don't get why there isn't something built in to stop infinite loops from crashing Unix.  Once a running program eats up so much memory,  It seems like it should just stop whats running that's eating it... Update: 5-18-17 My good CPU is now crashing without any reason... I fired it up and opened up a few things to start working, and BOOP..... frozen... nothing. Picture of bootup I caught on camera: update: 5-23-18,  currently trying to find what ulimit to set to stop my alienware fro...

what to do

I need more stimulation. Do I play with Wiwa some more? Do I attempt my Doctorwho sci fi mashup game on tkinter? I hear pygame isn't used much anymore. What to do ...  I learn best if I have something to accomplish that is interesting to me, so I'm going to try brainstorming some ideas.  Maybe I'll look up how to call python, C, and SQL in a file... I'm just not sure.  Guess I'll go play some codewars until something pops into my head. Or go finish up my next assignment in the LMPTHW book.... Think I'll find a movie... SQUIRREL! ... nope false alarm. I'll come up with something.

disable autocomplete atom

Image
I had a bit of trouble finding exactly where to disable the autocomplete for Atom. It was driving me crazy always trying to fill in stuff. So for those who need visual aids like I do, Here's a pic to find and disable it. I disabled them all.  There were 5 in my list. It wanted to autocomplete regardless unless I disabled all, because it was an unsaved file.  (That's my theory)  I don't ever see a use for this.  Autocomplete just seems dangerous, what if you get a similar variable and don't notice, enter it, and have broken code because it's grabbing the wrong thing.  Seems like way more work then just typing it out. K, Picture: