Skip to content

Instantly share code, notes, and snippets.

View stackdump's full-sized avatar

stackdump stackdump

View GitHub Profile
@stackdump
stackdump / tic-tac-toe-coding.md
Last active September 30, 2018 03:09
Modeling Computational Complexity of Tic-Tac-Toe using Information Theory and Sets
@stackdump
stackdump / tic-tac-toe-dependent-types.md
Last active June 13, 2024 13:41
Describing Tic-Tac-Toe Using Dependent Sum Types

Problem

Can we use Type Theory to show that a given Petri-Net correctly models a game of Tic-Tac-Toe?

EDIT: removed a bad attempt to grapple with this problem originally in 2017

Explaining Tic-Tac-Toe using Entropy

  • The state space of a game is 9!
  • there are 9 moves per game
  • on average there are 5 degrees of freedom for any given move
  • on average there are 4 previous actions before the 'current turn'

Defining the Board

@stackdump
stackdump / socketio-auth-error.log
Created May 21, 2018 13:11
builtins.RecursionError when using socketio + flask-github
builtins.RecursionError
RecursionError: maximum recursion depth exceeded while calling a Python object
Traceback (most recent call last)
File "/home/ork/.local/share/virtualenvs/bitwrap-io-0mehGRkI/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/ork/.local/share/virtualenvs/bitwrap-io-0mehGRkI/lib/python3.6/site-packages/flask_restful/__init__.py", line 273, in error_router
return original_handler(e)
File "/home/ork/.local/share/virtualenvs/bitwrap-io-0mehGRkI/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
@stackdump
stackdump / grpc_asyncio.py
Created August 9, 2018 16:40 — forked from mmellison/grpc_asyncio.py
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):
# started w/ cli
factomd -factomhome=./ -count=5 -blktime=20 -net=alot -network=LOCAL -startdelay=10 -sim_stdin=true > out.txt
...
Switching to Node 4
t
There are no available identities in this node. Type 'g1' to claim another identity
g1
package main
import "time"
func main() {
stop := make(chan struct{})
go func() {
//wait := time.After(500 * time.Millisecond)
//<-wait

TicTacToe contract

Contract Declaration

{
    "inputs": [
        {
            "address": "|DEPOSITOR|",
Set Implicit Arguments.
Inductive vector (X : Type) : nat -> Type :=
| vnul : vector X 0
| vcons {n : nat} (h : X) (v : vector X n) : vector X (S n).
Arguments vnul [X].
Definition vhd (X : Type) n (v : vector X (S n)) : X :=
match v with
| vcons _ h _ => h
(* Introduction to dependent types using vectors.
Venanzio Capretta, February 2011. *)
(* This tells Coq to implicitely deduce some arguments. *)
Set Implicit Arguments.
(* Family of finite types: (Finite n) has exactly n elements. *)
Inductive Finite: nat -> Set :=