This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |