Skip to content

Instantly share code, notes, and snippets.

View luyao795's full-sized avatar

Luyao Tian luyao795

View GitHub Profile
@luyao795
luyao795 / AIReversi.cs
Created August 25, 2017 03:25
This class defines variable depth AI behavior by using MiniMax with Alpha-Beta Pruning.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class MoveStatus {
public int row, col;
public int score;
public MoveStatus(int Row, int Col, int Score)
@luyao795
luyao795 / GameController.cs
Created August 25, 2017 03:22
This class controls the flow of the game, both AI and Board will call functions from this class.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class GameController {
public int[,] boardState;
// 8 directions that we need to check
@luyao795
luyao795 / Board.cs
Created August 25, 2017 02:37
Game Board for Reversilation, including initialization, update, game rules implementation, reset, win condition check, etc.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Board : MonoBehaviour {
public GameObject piece;
@luyao795
luyao795 / MemoryOperator.h
Created August 24, 2017 07:09
Header file for Memory Operations
#ifndef MEMORYOPERATOR_H
#define MEMORYOPERATOR_H
#include "FixedSizeAllocator.h"
void* operator new(size_t size);
void* operator new(size_t size, bool allocation);
void* operator new(size_t size, const char* file, const char* func, const unsigned int line);
void* operator new[](size_t size);
void* operator new[](size_t size, bool allocation);
@luyao795
luyao795 / MemoryOperator.cpp
Created August 24, 2017 07:07
Implementation of functions about Memory Operation
#include <stdio.h>
#include <malloc.h>
#include "DebugPrint.h"
#include "MemoryOperator.h"
#include "BlockAllocator.h"
#include "FSAManager.h"
#include "FixedSizeAllocator.h"
#include "Point2D.h"
#define ALLOCATE_SIZE 1024
@luyao795
luyao795 / BitArray.h
Created August 24, 2017 07:03
Header file for Bit Array
#ifndef BITARRAY_H
#define BITARRAY_H
#include <stdint.h>
#include "BlockAllocator.h"
namespace Engine
{
#ifdef _WIN64
#define u_integer uint64_t
@luyao795
luyao795 / BitArray.cpp
Created August 24, 2017 07:00
Implementation of functions in Bit Array
#include <stdint.h>
#include <string.h>
#include <intrin.h>
#include "BitArray.h"
#include "MemoryOperator.h"
#include "BlockAllocator.h"
using namespace std;
#ifdef _DEBUG
@luyao795
luyao795 / FSAManager.h
Created August 24, 2017 06:56
Header file for Fixed Size Allocator Manager
#ifndef FSAMANAGER_H
#define FSAMANAGER_H
#include <vector>
#include "FixedSizeAllocator.h"
#define NUM_FSA 4
namespace Engine
{
@luyao795
luyao795 / FSAManager.cpp
Last active August 24, 2017 06:59
Implementation of functions in Fixed Size Allocator Manager
#include <vector>
#include <math.h>
#include "DebugPrint.h"
#include "Point2D.h"
#include "BlockAllocator.h"
#include "FixedSizeAllocator.h"
#include "FSAManager.h"
#include "MemoryOperator.h"
#ifdef _DEBUG
@luyao795
luyao795 / FixedSizeAllocator.h
Created August 24, 2017 06:52
Header file for Fixed Size Allocator
#ifndef FIXEDSIZEALLOCATOR_H
#define FIXEDSIZEALLOCATOR_H
#include "BitArray.h"
namespace Engine
{
class FixedSizeAllocator
{
public: