Skip to content

Instantly share code, notes, and snippets.

View carlos-aguayo's full-sized avatar

Carlos Aguayo carlos-aguayo

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
The Project Gutenberg EBook of The Republic, by Plato
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.org
Title: The Republic
@carlos-aguayo
carlos-aguayo / .block
Created February 23, 2019 17:25 — forked from mbostock/.block
Heatmap (2D Histogram, CSV)
license: gpl-3.0
@carlos-aguayo
carlos-aguayo / Loading MNIST.ipynb
Last active February 13, 2020 21:36
Loading MNIST
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carlos-aguayo
carlos-aguayo / MCTS.py
Last active November 4, 2020 23:58
Run a Monte Carlo Tree Search (MCTS) Simulation
# https://github.com/suragnair/alpha-zero-general/blob/5156c7fd1d2f3e5fefe732a4b2e0ffc5b272f819/MCTS.py#L37-L48
for i in range(self.args.numMCTSSims): # self.args.numMCTSSims, the number of MCTS simulations to compute
self.search(canonicalBoard) # "search" is a MCTS simulations
s = self.game.stringRepresentation(canonicalBoard)
# Count how many times we have visited each node
counts = [self.Nsa[(s, a)] if (s, a) in self.Nsa else 0 for a in range(self.game.getActionSize())]
if temp == 0:
@carlos-aguayo
carlos-aguayo / MCTS.py
Last active November 6, 2020 01:47
Part A - Select the node with the highest Upper Confidence Bound (UCB)
# https://github.com/suragnair/alpha-zero-general/blob/5156c7fd1d2f3e5fefe732a4b2e0ffc5b272f819/MCTS.py#L105-L121
cur_best = -float('inf')
best_act = -1
# pick the action with the highest upper confidence bound
for a in range(self.game.getActionSize()):
if valids[a]:
if (s, a) in self.Qsa:
u = self.Qsa[(s, a)] + self.args.cpuct * self.Ps[s][a] * math.sqrt(self.Ns[s]) / (
1 + self.Nsa[(s, a)])