Skip to content

Instantly share code, notes, and snippets.

View InterestingBrainPoops's full-sized avatar
🎯
Focusing

BrokenKeyboard InterestingBrainPoops

🎯
Focusing
View GitHub Profile
@InterestingBrainPoops
InterestingBrainPoops / triplevector.py
Created April 2, 2020 19:41 — forked from davidnuon/triplevector.py
Class for a 3D vector in Python
class TripleVector:
x = 0
y = 0
z = 0
def __init__(self, x, y, z):
self.x = float(x)
self.y = float(y)
self.z = float(z)
@InterestingBrainPoops
InterestingBrainPoops / Page1.md
Last active July 30, 2020 03:23
The math for warping images.

The first solution

At first it was kind of obvious that you can just use basic trig to get the hight of the triangle. But that comes into error when you have a z offset, or a y offset.
The code here is very simple, so I'll just break it down as such:
First you just see the trig function that this is based of off.

var length = 10; // basically the hypotenuse of the triangle.  
var theta = 45; // the angle of elevation, between the base and the hypotenuse  
  
var newheight = sin(theta)*length;//   This is the projected height, and as you can see, really primitive.  
@InterestingBrainPoops
InterestingBrainPoops / 1Page1.md
Last active August 4, 2020 19:37
Making a Camera(In software of course.)

Goals

So in this project specifically, I have a couple of goals in mind:

  • Being able to render a scene with a camera
    • This is a long term goal.(So expect it to get happened in the future.)
    • out of the scope of this gist
  • Making it gpu based, and not cpu based
    • oooooooh this is one of those things that is really useful

Steps

So the table of contents for this whole thing is basically as follows:

  1. Get the math worked through
@InterestingBrainPoops
InterestingBrainPoops / Puzzle.txt
Created August 15, 2020 20:31
A small puzzle I made , and One hint: Sebald
30 30 31 31 30 31 30 31 20 30 30 31 31 30 31 30 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 30 31 31 20 30 30 31 31 30 30 31 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 30 31 31 20 30 30 31 31 31 30 30 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 31 31 20 30 30 31 31 30 30 31 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 30 30 20 30 30 31 31 31 30 30 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 30 30 20 30 30 31 31 30 31 30 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 31 30 20 30 31 31 30 30 30 31 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 31 30 20 30 30 31 31 30 31 31 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 31 30 20 30 30 31 31 30 31 30 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 30 31 31 20 30 30 31 31 30 30 31 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 30 30 20 30 30 31 31 30 31 31 30 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 31 31 20 30 31 31 30 30 30 30 31 20 30 30 31 30 30 30 30 30 20 30 30 31 31 30 31 30 30 20 30 30 31 31 31 30 30 31 2
@InterestingBrainPoops
InterestingBrainPoops / Beep.sh
Created August 31, 2020 17:14
Java project Builder and executor.
#!/bin/bash
bin/mkdir -p /tmp/.java/classes 2> /dev/null
# Compile the program.
#
javac -d /tmp/.java/classes $0
# Run the compiled program only if compilation succeeds.
#
@InterestingBrainPoops
InterestingBrainPoops / (1)USAGE.md
Last active September 9, 2020 18:43
Project Builder, Probably going to work on it more.

Usage:

All you have to do is run

sh builder.sh [PATH] [FILENAME]

There are 2 cmd line args.
Path [PATH] and file name [FILENAME].
path is relative to the location of the script, and filename is the filename of the java file w/thout the extension.

@InterestingBrainPoops
InterestingBrainPoops / Heuristics.md
Created January 11, 2021 17:14
BattleSnake Heuristics

The start

The main thing here, is that when you start making snakes, you tend to flounder around for a week or 2 before realizing what the correct strategy for you is. By this I mean something implementable for you in the language that you're using.

Survive

The main thing about battlesnake is that you need to survive longer than your opponents.
This is the running principle behind any snake, no matter how aggresive.
When you have an aggressive snake, all you do is cut the amount of snakes left to give you a faster win. When you have a peaceful snake, you actively avoid other snakes, and eating food is your priority, because you know you can outlast the other snakes.
Area control snakes attempt to box off as much area for themselves, and as such control the food spawns within that area. An amazing example of this is Tofu and Milktea.

Move generation

There are many methods of getting the move beyond the heuristic, ranging from minmax to Monte-Carlo search trees, to random, to using some for

@InterestingBrainPoops
InterestingBrainPoops / main.spcl
Created May 10, 2021 00:38
sample program that should theoretically work
main {
thing = 6 $ this is a comment
a = 2 $ int by default.
print thing $ by default all programs have access to this function.
thing += a thing $ thing = a + thing
print thing $ prints the new thing (should be 8)
drop thing $ thing is no longer usable after this point
drop a $ same thing w/ this one.
}
@InterestingBrainPoops
InterestingBrainPoops / main.py
Created July 4, 2023 04:33
Servo controller code for robot dog project
# The following code is under public domain, feel free to use this how you will.
from machine import PWM, Pin
import utime
from math import cos, sin, radians, sqrt, atan, degrees, acos
left = PWM(Pin(14))
left.freq(50)
right = PWM(Pin(15))
right.freq(50)
MIN_DUTY = 1128
import machine
import time
# Set up UART1 with the appropriate baud rate and pins.
uart1 = machine.UART(1, baudrate=9600, tx=machine.Pin(4), rx=machine.Pin(5))
def read_char_from_uart(uart):
while not uart.any():
pass
return uart.readline()