Skip to content

Instantly share code, notes, and snippets.

View codefever's full-sized avatar
🙃
alive

Nelson LIAO codefever

🙃
alive
View GitHub Profile
@codefever
codefever / main.py
Created October 7, 2019 09:03
Tic-Tac-Toe Game Play with MCTS
#!/usr/bin/env python
import numpy as np
# from github.com/int8/monte-carlo-tree-search.git
from mctspy.tree.nodes import TwoPlayersGameMonteCarloTreeSearchNode
from mctspy.tree.search import MonteCarloTreeSearch
from mctspy.games.examples.tictactoe import TicTacToeGameState, TicTacToeMove
initial_board = np.zeros((3,3))
@codefever
codefever / bfs.py
Created October 4, 2019 09:21
BFS with Q-Learning?
#!/usr/bin/env python
from enum import IntEnum
import math
import random
import logging
logging.basicConfig(level=logging.INFO)
@codefever
codefever / docker-compose.yml
Created August 24, 2019 09:43
Set up 3 nodes for CockroachDB cluster with Docker-Compose
version: "3"
services:
roach0:
image: cockroachdb/cockroach
container_name: roach0
command: start --logtostderr --insecure
ports:
- "26257:26257"
- "8080:8080"
networks:
@codefever
codefever / segment_tree.py
Created August 24, 2019 09:12
SegmentTree in python
#!/usr/bin/env python
# Inspired by: https://www.youtube.com/watch?v=Oq2E2yGadnU
# What i did was moving the first index to 0.
class SegmentTree(object):
def __init__(self, data):
n = len(data)
self.offset = n - 1
self.nodes = [0 for _ in range(n * 2 - 1)]
@codefever
codefever / rbt.py
Last active August 24, 2019 09:43
RBT in python
#!/usr/bin/env python
import sys
# RBT != 仙踪林
# https://en.wikipedia.org/wiki/Red%E2%80%93black_tree
class RBNode(object):
def __init__(self, val, is_red=False, left=None, right=None, parent=None):
self.val = val