Skip to content

Instantly share code, notes, and snippets.

View samtalki's full-sized avatar

Samuel Talkington samtalki

View GitHub Profile
using Distributions
using Random
# der_set = .....
# L C U M NO
class_costcomp = [1, 2, 4, 8, 1e4] # cost to compromise for each class
class_prob = 1/5 * ones(5) # probability of a single node being in that class -- equal for now
"""
Given a set of ders `der_set`, a vector of probabilities `class_prob` and costs to compromise `class_costcomp`:
@samtalki
samtalki / load_trip.jl
Last active July 15, 2025 18:58
Combinatorial Bandits for Load Tripping
using LinearAlgebra
using Random
using CairoMakie
"""
ucb_attack(demand::Matrix, k; α = 1.2)
Run top‐k UCB on a demand matrix of size (n, T).
Returns a binary matrix of chosen attacks at each time step.
private class miniMax extends AI {
public ArrayList<Integer> moves;
public int getBestColumn(Player[][] state, Player player) {
for (int c: range(0, GRID_COLUMNS-1)) {
ArrayList<Integer> nodes = new ArrayList<Integer>();
nodes.add(minimax(state, 0, true, player));
System.out.println(nodes.toString());
}
return 0;
protected Player getWinner(Player[][] state, int rowHint, int columnHint) {
//VERTICAL CHECK
int verticalWin = 1 + RayCast(state, rowHint, columnHint, 1, 0) + RayCast(state, rowHint, columnHint, -1, 0);
//HORIZONTAL CHECK
int horizontalWin = 1 + RayCast(state, rowHint, columnHint, 0, 1) + RayCast(state, rowHint, columnHint, 0, -1);
//POSITIVE DIAGONAL CHECK
int posDiagonalWin = 1 + RayCast(state, rowHint, columnHint, -1, 1) + RayCast(state, rowHint, columnHint, 1, -1);
private void insertionSort() {
final int length = bars.size();
int j;
int hole;
for(int i = 1; i < length ; i++) {
j = i-1;
hole = retrieve(i);
ToggleGroup speeds = new ToggleGroup();
RadioButton fifty = new RadioButton("50 Milliseconds");
fifty.setToggleGroup(speeds);
RadioButton twoFifty = new RadioButton("250 Milliseconds");
twoFifty.setToggleGroup(speeds);
RadioButton sevenFifty = new RadioButton("750 Milliseconds");
sevenFifty.setToggleGroup(speeds);
RadioButton fifteen100 = new RadioButton("1500 Milliseconds");
fifteen100.setToggleGroup(speeds);