Skip to content

Instantly share code, notes, and snippets.

View JeffML's full-sized avatar
🏠
Barely working

Jeff Lowery JeffML

🏠
Barely working
View GitHub Profile
@JeffML
JeffML / diagonalMoves.js
Created June 14, 2017 19:16
calculating diagonal moves with friendly blockers
// m: proposed move
// blockers: blocking pieces
// pp: current piece position
function diagonalChecks(m, blockers, pp) {
let isGood = true;
for (const b of blockers) {
if (b.rank > pp.rank && b.file > pp.file) {
if (m.rank > pp.rank && m.file > pp.file) {
isGood = isGood && (m.rank < b.rank && m.file < b.file);
}
this.add({
role: "movement",
cmd: "legalSquares",
}, (msg, reply) => {
const isPawn = msg.piece.piece === 'P';
const isKnight = msg.piece.piece === 'N';
this.act({
role: "movement",
cmd: "rawMoves",
module.exports = function specialMovement(options) {
//...
this.add({
role: "movement",
cmd: "rawMoves",
isPawn: true
}, (msg, reply) => {
if (msg.piece.piece !== 'P') {
return ("piece was not a pawn")
}
var Ba1 = new ChessPiece('Ba1');
seneca.act({
role: "movement",
cmd: "rawMoves",
piece: Ba1
}, (err, msg) => {...});
this.add({
role: "movement",
cmd: "rawMoves",
}, (msg, reply) => {
var err = null;
var rawMoves = [];
var pos = msg.piece.position;
switch (msg.piece.piece) {
@JeffML
JeffML / letsbowl.final.groovy
Last active March 19, 2017 16:38
Bowling Ball ownership, final
import java.util.ArrayList
import java.util.List
interface IBowlingBall {
String getBrand();
String getSerialNumber();
}
abstract class BowlingBall implements IBowlingBall {
private String brand, serialNumber;
@JeffML
JeffML / BowlingBallFactory.groovy
Created March 18, 2017 21:13
BowlingBallFactory
class BowlingBallFactory {
static private class BowlingBall implements IBowlingBall{
private String petName;
BowlingBall() {
}
private void setPetName(String petName) {
this.petName = petName;
}
@JeffML
JeffML / letsbowl0.1.groovy
Last active March 18, 2017 20:33
BowlingBall, inner class
interface IBowlingBall {
String getPetName();
}
class Bowler {
static private class BowlingBall implements IBowlingBall{
private String petName;
BowlingBall() {
}
@JeffML
JeffML / letsbowl0.groovy
Last active March 18, 2017 20:06
BowlingBall, outer class
class BowlingBall {
private String petName;
BowlingBall() {
}
void setPetName(String petName) {
this.petName = petName;
}
var menu = require('./menu');
var Combinator = require('./Combinator-generator-naive');
function run() {
var threeCombos = new Combinator({
min: menu.threeItems.min,
max: menu.threeItems.max
})
.combine([], menu.threeItems.values);