Skip to content

Instantly share code, notes, and snippets.

View ringodin's full-sized avatar

Ringotron5000 ringodin

View GitHub Profile
@ringodin
ringodin / solution for Rocky Road Coder Z, straighten
Created May 23, 2021 23:56
used for straightening out your robot when driving on bumps
from robot import Robot
import time
robot = Robot({"communication":{"communication_manager_type":"js"}})
x = 0
while True:
time.sleep(0.001)
@ringodin
ringodin / Snackshop, Day 2
Created May 21, 2021 05:28
at the end of day 2 for Snackshop
items = ['pizza', 'veggie sticks', 'coffee', 'apple', 'candy bar' ]
prices = [150, 70, 90, 80, 75]
counter = 0
while counter < len(items):
print(f' {counter + 1} {items[counter]} {prices[counter]}')
counter += 1
done = len(items) + 1
print(f' {done} ------ Choose this number if you are done ordering. ')
@ringodin
ringodin / Snackshop Day 1, May 2021
Created May 19, 2021 06:13
This is where we ended Snackshop Day 1. Use this to start snackshop day 2.
items = ['pizza', 'veggie sticks', 'coffee', 'apple' ]
prices = [150, 70, 90, 80]
counter = 0
while counter < len(items):
print(f' {counter + 1} {items[counter]} {prices[counter]}')
counter += 1
choice = int(input('What food would you like to choose? '))
print(f' You chose {items[choice-1]}. That costs {prices[choice-1]}. Enjoy! ')
@ringodin
ringodin / 1 or 2
Created May 7, 2021 05:57
for guessing
import random, time
while True:
number = random.randint(1,2)
guess = int(input('Guess a number. Either 1 or 2 ' ))
while guess != number:
print("nope. Sorry.")
guess = int(input("Try a new guess. "))
print(f'Correct! The answer was {number}' )
time.sleep(1)
@ringodin
ringodin / Idle Loop, VEX V5, rangefinder, 3-wire
Created May 4, 2021 06:36
Use an idle-loop to allow your robot to "hang out" at a particular task until a condition is met.
// ----------------------------------------------------------------------------
//
// Project: 3-Wire Rangefinder Sensing
// Description: This example will show all of the available commands
// for using the 3-Wire Rangefinder Sensor
// Configuration: V5 Speedbot (Drivetrain 2-motor, No Gyro)
// Rangefinder in 3-Wire Ports A B
//
// ----------------------------------------------------------------------------
@ringodin
ringodin / VEX V5 and Rangefinder, right then Left
Created April 27, 2021 02:18
using VEXCode with v5 robot, and the rangefinder to turn right then left with a counter
#include "vex.h"
using namespace vex;
int main() {
int counter = 0;
Brain.Screen.print(counter);
Drivetrain.setDriveVelocity(30, percent);
wait(1,seconds);
// ----------------------------------------------------------------------------
//
// Project: Drivetrain Moves and Turns
// Description: This example uses the drivetrain
// to drive and turn in different directions
// Configuration: V5 Speedbot (Drivetrain 2-motor, No Gyro)
//
// ----------------------------------------------------------------------------
#include "vex.h"
@ringodin
ringodin / down_eye detection of color, vr.vex
Created January 24, 2021 13:40
This example shows you how to use the down eye detector for seeing colors (red, green, blue, and none). The front eye works similarly.
from vexcode import *
def main():
while True:
drivetrain.drive(FORWARD)
if down_eye.detect(GREEN):
drivetrain.turn_for(RIGHT, 180, DEGREES)
@ringodin
ringodin / Drawing all Red and Blue pieces
Created January 20, 2021 23:48
This code lets you draw all the pieces as red or blue, as played by player 1 or player 2. It does NOT detect a win yet.
from pyglet import app
from pyglet import clock
from pyglet import graphics
from pyglet import gl
from pyglet import text
from pyglet.window import Window
from pyglet.window import mouse
from pyglet.window import key
from math import sin, cos, pi
@ringodin
ringodin / snippet of code for win lines
Last active January 20, 2021 13:08
This defines a function called "get_winning_line" that looks for horizontal, vertical, and diagonal wins by either player
def get_winning_line():
for row in range (0, rows): # for horizontal line win
for col in range (0, 4): # start with leftmost columns
if all([matrix[row][col] == value and value != 0 for value in matrix[row][col:col+4]] ):
return (col, row), (col +1, row), (col +2, row), (col +3, row)
transpose = list(zip(*matrix))
for col in range (0, cols): # for vertical line win
for row in range (0, 3): # start with bottom on up
if all([transpose[col][row] == value and value != 0 for value in transpose[col][row:row+4]] ):
return (col, row), (col, row+1), (col, row+2), (col, row+3)