This file contains 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
class Stack<T> implements Stackable<T> { | |
private Stack<T> previous; | |
private T value; | |
Stack() { | |
} | |
Stack(T value) { | |
this.value = value; | |
} |
This file contains 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
/** | |
* Interface for implementing Minimax algorithm in two-player zero-sum games | |
* <T> => Move data type | |
*/ | |
interface Minimax<T> { | |
// 1 or -1 | |
var currentPlayer: Int | |
/** | |
* Evaluate game state for current player. |
This file contains 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
import kotlin.math.pow | |
import kotlin.random.Random | |
// Article: https://medium.com/@larswaechter/zobrist-hashing-305c6c3c54d0 | |
/* | |
* Build the Zobrist table with random numbers. | |
* For 9 cells and 2 players we need 18 random numbers. | |
*/ | |
fun buildZobristTable(): Array<Array<Long>> { |
This file contains 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
public class Node { | |
int value; | |
Node next; | |
Node(int value) { | |
this.value = value; | |
} | |
public int get(int index) { | |
assert index >= 0 && index < this.length(); |
This file contains 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
int main(int argc, char *argv[]) | |
{ | |
int *arr; | |
arr = malloc(5); | |
arr[0] = 1; | |
arr[1] = 10; | |
arr[2] = 20; | |
arr[3] = 30; | |
arr[4] = 40; |
This file contains 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
# Medium Article: https://larswaechter.medium.com/a-decent-introduction-to-gradient-descent-in-python-846be2e41592 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# The model's output (prediction) | |
def predict(X, w, b): | |
return X * w + b |
This file contains 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
/** | |
* TicTacToe bitboard | |
*/ | |
class Board( | |
val map: LongArray = longArrayOf( | |
0b000_000_000, // X = player 1 | |
0b000_000_000 // O = player -1 | |
) | |
) { | |
companion object { |