Skip to content

Instantly share code, notes, and snippets.

View morgankenyon's full-sized avatar
💭
Program program program!

morgankenyon

💭
Program program program!
View GitHub Profile
module App
open Elmish
open Elmish.React
open Feliz
type State =
{ Username: string
Password: string
LoggedIn: bool }
> Executing task: C:\Users\morga\.platformio\penv\Scripts\platformio.exe run <
Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.4.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
//Compiled on 9/17/2021 7:46:51 PM
#include <inttypes.h>
#include <stdbool.h>
#ifndef JUNIPER_H
#define JUNIPER_H
#include <stdlib.h>
namespace juniper
import copy
class Choice():
def __init__(self, move, value, depth):
self.move = move
self.value = value
self.depth = depth
def __str__(self):
return (str(self.move) + ": " + str(self.value))
import copy
class Choice():
def __init__(self, move, value, depth):
self.move = move
self.value = value
self.depth = depth
def __str__(self):
return (str(self.move) + ": " + str(self.value))
# https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning#Pseudocode
# gist is saved as a .py file, but that's just for highlighting
# this isn't valid python code.
function alphabeta(node, depth, α, β, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
from ttt.player import Player
from ttt.game import Game
from ttt.random_bot import RandomBot
from ttt.invincibot import InvinciBot
from datetime import datetime
def main():
dateTimeObj = datetime.now()
print(dateTimeObj)
xbot = InvinciBot(Player.x)
import copy
class Choice():
def __init__(self, move, value, depth):
self.move = move
self.value = value
self.depth = depth
def __str__(self):
return (str(self.move) + ": " + str(self.value))
from ttt.player import Player
from ttt.game import Game
from ttt.random_bot import RandomBot
from ttt.two_layer_bot import TwoLayerBot
def main():
xbot = RandomBot(Player.x)
obot = TwoLayerBot(Player.o)
game = Game(1000)
print ("randombot (x) vs twolayerbot (o)")
import random
import copy
class TwoLayerBot():
def __init__(self, player):
self.player = player
def select_move(self, board):
losing_move = None
first_candidates = board.get_legal_moves()