Skip to content

Instantly share code, notes, and snippets.

//1-neuron N-inputs 1-output perceptron in c++ (Binary classifier)
//Training data is for AND but you edit it to what you want the Perceptron to learn
//Short and sweet with lots of comments
#include <stdio.h>
#define dataLenght 4
#define numOfInputs 2
#define trainTimes 100
@lukakostic
lukakostic / Perlin_Tiled.cs
Created August 23, 2018 07:31 — forked from Flafla2/Perlin_Tiled.cs
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
@lukakostic
lukakostic / Source.c
Created August 22, 2018 22:38
Print digits of pi using the Leibniz formula: pi = 4 * (1 -1/3 +1/5 -1/7 ....)
//Print digits of pi using the Leibniz formula: pi = 4 * (1 -1/3 +1/5 -1/7 ....)
#include <stdio.h>
#define NumType long double
int main(){
NumType d = 1.0;
NumType f = 0.0;
// Images, example and guide at : https://github.com/lukakostic/Random-Infinite-2DTerrain
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(PolygonCollider2D))]
[RequireComponent(typeof(LineRenderer))]
public class RandomTerrain2D : MonoBehaviour {
@lukakostic
lukakostic / MoreRandom.cs
Last active August 22, 2018 22:39
Better UnityEngine.Random, replace "Random" with this "MoreRandom" in your code and thats it
//More random version of UnityEngine.Random
//Just replace Random with MoreRandom in your code and thats it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
#Solving this:
#https://www.youtube.com/watch?v=uCsD3ZGzMgE
#by iteration and not math
def JosephusProblem(n):
people = list(range(1,n+1))
i = 0