Skip to content

Instantly share code, notes, and snippets.

@UrosOgrizovic
UrosOgrizovic / connected_components.py
Created April 21, 2022 10:25
Connected components in Python
import enum
class Connectivity(enum.Enum):
"""
4-connectivity or 8-connectivity
"""
FOUR = 1
EIGHT = 2
@UrosOgrizovic
UrosOgrizovic / graph-shortest-path.py
Last active December 5, 2020 09:20
Find the shortest path in a graph using Bellman-Ford.
"""
find shortest path in graph via Bellman-Ford
Uros Ogrizovic
"""
import numpy as np
import matplotlib.pyplot as plt
def get_neighbors_of_node(node, adjacency_matrix):
@UrosOgrizovic
UrosOgrizovic / blackjack.py
Last active December 11, 2020 13:41
A bot that plays blackjack. Three policies are available: greedy, epsilon greedy and softmax.
"""
bot that plays blackjack
Uros Ogrizovic
"""
import numpy as np
from numpy.random import rand, randint
def greedy_policy(q):
"""
tic-tac-toe using minimax
Uros Ogrizovic
"""
from time import sleep
empty_space_sign = 'E'
spaces = [[empty_space_sign, empty_space_sign, empty_space_sign],
[empty_space_sign, empty_space_sign, empty_space_sign],