Skip to content

Instantly share code, notes, and snippets.

View billowdood's full-sized avatar

Rodolfo Islas billowdood

View GitHub Profile
public class HiloSemaforo extends Thread{
//Cuando se llega a 0 carros ya no cambia a ambar D:
private Semaforo semaforosCrucero;
private boolean estadoInicial = true;
public void setHilo(Semaforo SA){
semaforosCrucero = SA;
}
@billowdood
billowdood / Automata.java
Created September 18, 2012 14:28
Creacion de Regla
public void generacionReglaBinario(){
int i,j = 7,valorTemporalRegla = numeroRegla;
//Temporal array
int[] arrayTemporal = new int[8];
//pasar el numero de regla a binario
for(i = 0; i < 8; i++){
arrayTemporal[i] = valorTemporalRegla % 2;
valorTemporalRegla = valorTemporalRegla / 2;
}
//Acomodar el numero binario
@billowdood
billowdood / GeneracionG.java
Created September 18, 2012 14:30
Generaciones
private void primerGeneracionGeneral(){
int i;
for(i = 0;i < largo;i++){
//Si es la celda central,pon 1[celda encendida]...modificarlo para que encuentra le celda media
// System.out.println("["+i+"]");
if(i == (largo /2)){
//System.out.println("["+i+"]");
generacionAnterior[i] = 1;
//System.out.println("Valor "+generacionAnterior[i]);
}
import numpy as np
import cv2
#Training!
def training(contoursObj):
samples = np.empty((0,100))
#Empty array for the corresponding value
valueDigit = []
#Loop over all the images,in this case we have 9 images per digit,so in total we have 90 images(we included 0 as a digit)
#Training!
#For the training,the image of the digit is displayed and it is expected that the user press on his keyboard the digit is shown on screen
def training(contoursObj):
#Empty array for the labels
samples = np.empty((0,100))
#Empty array for the corresponding value
valueDigit = []
#Loop over all the images,in this case we have 9 images per digit,so in total we have 90 images(we included 0 as a digit)
for num_image in range(1,91):
#Get the image and find the contours of the number(rectangle)
import math
from random import randint
from aspirante import aspirante
class mejorAspirante:
def __ini__(self):
print
## self.aspirantes = aspirantes
## self.centroides = centroides
public void setOnOff(int environmentTemp){
System.out.println("SETONOFF");
if(environmentTemp <= 20){
this.onOff = false;
}
if(environmentTemp > 20 && environmentTemp < 25){
this.onOff = true;
/*Set the speed to slow*/
this.speed = false;
i = 0
j = 0
suma = 0
suma2 = 0
grados = []
while(i<33):
while(j<33):
suma += mat[i][j]
suma2 += mat[i][j]
j = j + 1
@billowdood
billowdood / Client.java
Created November 20, 2012 02:36
Contract net
public class Client{
/*Class which will represent the client who wants to send a package*/
private float budget;
private int xValue,yValue;
public void setClient(float budget,int xValue,int yValue){
this.budget = budget;
this.xValue = xValue;
this.yValue = yValue;
@billowdood
billowdood / decr.py
Last active December 19, 2015 01:09
One Time Pad
#Descifrado del mensaje
def D(c,key):
#Alfabeto para descifrar,se utilizo la ref(2)
alf = ascii_lowercase
alf += ' .'
deStr = ''
for partC in c:
for car in range(len(partC)):
deStr += alf[int(partC[car]) - int(key[c.index(partC)][car])]
return deStr