TODO
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
| import java.sql.Connection | |
| import java.sql.DriverManager | |
| import java.sql.CallableStatement | |
| import java.sql.PreparedStatement | |
| import java.sql.ResultSet | |
| import java.sql.Types | |
| if (args.length < 2) { | |
| println "Usage: groovy main.groovy SCHEMA ROUTINE_NAME" | |
| System.exit(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
| **FREE | |
| Ctl-Opt NoMain Option(*SrcStmt:*NoDebugIo); | |
| // ----------------------------------------------------------------- | |
| // Subprocedure: CalculateInterest | |
| // Computes simple interest: (Principal * Rate * Years) | |
| // ----------------------------------------------------------------- | |
| Dcl-Proc CalculateInterest Export; | |
| Dcl-Pi CalculateInterest Packed(15:2); | |
| pPrincipal Packed(15:2) Const; |
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
| package org.vanillaweb; | |
| import java.io.*; | |
| import java.net.ServerSocket; | |
| import java.net.Socket; | |
| import java.net.URLDecoder; | |
| import java.nio.charset.StandardCharsets; | |
| import java.util.concurrent.*; | |
| public class FullDuplexRelay { |
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
| import java.io.*; | |
| import java.net.ServerSocket; | |
| import java.net.Socket; | |
| import java.net.URLDecoder; | |
| import java.nio.charset.StandardCharsets; | |
| import java.util.concurrent.ArrayBlockingQueue; | |
| import java.util.concurrent.BlockingQueue; | |
| public class BrowserRelay { |
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
| import com.ibm.as400.access.AS400 | |
| import com.ibm.as400.access.DataQueue | |
| import com.ibm.as400.access.DataQueueEntry | |
| import com.ibm.as400.access.KeyedDataQueue | |
| import java.nio.charset.Charset | |
| fun main() { | |
| // Connect to IBM i | |
| val system = AS400( |
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
| /// Selects the best legal move for the current player using a trained NeuralNetwork. | |
| public enum AIPlayer { | |
| /// Returns the move that maximises P(currentPlayer wins) according to the network. | |
| public static func bestMove(for state: GameState, network: NeuralNetwork) -> Move { | |
| let moves = uniqueByResult(MoveGenerator.legalMoves(for: state), from: state) | |
| let player = state.currentPlayer | |
| return moves.max { a, b in | |
| score(move: a, state: state, network: network, player: player) | |
| < score(move: b, state: state, network: network, player: player) |
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
| (ns backgammon.ai | |
| "TD-Gammon inspired reinforcement learning AI for backgammon. | |
| Architecture: | |
| - Neural network: input(198) → hidden(40) → output(1) | |
| - Input: Tesauro's 198-feature encoding of board state | |
| - Output: estimated probability that White wins | |
| - Training: TD(λ) temporal difference learning | |
| - Eligibility traces for credit assignment across moves |
I'm using the Calva extension in IntelliJ IDEA and sometimes I run the game from the REPL.
(play-until-winner initial-game-state)
Sometimes I run it from the bash command line.
java -cp "lib/spec.alpha-0.6.249.jar:lib/core.specs.alpha-0.5.81.jar:lib/clojure-1.12.0.jar:src/main/clojure" clojure.main -i src/main/clojure/backgammon/core.clj -e "(in-ns 'backgammon.core)" -e "(play-until-winner initial-game-state)"
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
| (ns my-project.core | |
| (:require [clojure.spec.alpha :as s])) | |
| ;; Define a simple spec for a 'User' map | |
| (s/def ::name string?) | |
| (s/def ::age int?) | |
| (s/def ::user (s/keys :req [::name ::age])) | |
| (defn -main [& args] | |
| (let [valid-data {::name "Greg" ::age 30} |
NewerOlder