Skip to content

Instantly share code, notes, and snippets.

#include "move.h"
#include "data_types.h"
#include <math.h>
#define GRAVITY 0.6
#define OUTPUT_LENGTH 2
#define DIRECTION 0
#define DIR_LEFT -1
// Make the actual 2d array
map->mask = (bool**) calloc(map->width, sizeof(bool*));
for (int i=0; i<map->width; i++)
{
map->mask[i] = (bool*) calloc(map->height, sizeof(bool));
}
// Data is stored in the first 6 bits of every byte, and apparently bottom-right to top-left
int bitmask = 0x1;
char* index = end_position - 1;
void generate_view_matrix(GLfloat *matrix, point *cam_pos, point *cam_dir)
{
// http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
// f = cam_dir, up = (0|1|0)
// s = normalize(f X up)
// u = s X f
double x = cam_dir->x, y = cam_dir->y, z = cam_dir->z;
double l = sqrt(z*z + x*x);
double s_x = -z/l, s_z = x/l;
double u_x = -s_z*y, u_y = s_z*x - s_x*z, u_z = s_x*y;
float *grid_vertices;
int index = 0;
grid_vertices = calloc(9, sizeof(float));
grid_vertices[index++] = -5.0;
grid_vertices[index++] = 0.0;
grid_vertices[index++] = -1.0;
grid_vertices[index++] = 5.0;
grid_vertices[index++] = 0.0;
grid_vertices[index++] = -1.0;
// Create a VAO
GLuint gridVAO;
glGenVertexArrays(1, &gridVAO);
glBindVertexArray(gridVAO);
// Allocate and upload the VBO data
GLuint gridVBO;
glGenBuffers(1, &gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
glBufferData(GL_ARRAY_BUFFER, MAP_WIDTH * MAP_HEIGHT * sizeof(float) * 3, grid_vertices, GL_STATIC_DRAW);
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
// For profiling
#include <time.h>
// Size of each individual image
int image_width=0;
from __future__ import division, print_function
from PIL import Image
import sys
import math
IMAGE_WIDTH = int(sys.argv[3])
IMAGE_HEIGHT = int(sys.argv[4])
# sys.argv[5] is a string marking the shift parameter, we don't need that
CAMERA_DISTANCE = 20
from __future__ import division, print_function
from scipy import stats
import math
x_file = open("X", "r")
x_data = x_file.read().split()
x_file.close()
y_file = open("Y", "r")
from __future__ import division, print_function
def is_alive(x, y, board):
neighbours = 0
for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
neighbours += board[(y+j)%8][(x+i)%8]
# The value of the point itself is not important, and should be removed
neighbours -= board[y][x]
package GUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;