Skip to content

Instantly share code, notes, and snippets.

View Larkenx's full-sized avatar
💭
LispGameJam2020!

Steven Larkenx

💭
LispGameJam2020!
View GitHub Profile
@Larkenx
Larkenx / TimeScheduler.kt
Last active June 30, 2018 00:36
A priority queue based turn scheduling system in Kotlin based on this article http://roguebasin.com/index.php?title=A_priority_queue_based_turn_scheduling_system
import java.util.*
import kotlin.collections.HashMap
/**
* An interface for "actors" or entities to implement so that all actors have a speed property
*/
interface Actor {
abstract var speed: Int
}
/**
@Larkenx
Larkenx / EventHandler.js
Last active September 10, 2020 09:06
JavaScript Goal Driven AI with Event Streams, based on socket.io's API & Caves of Qud goal driven AI https://youtu.be/4uxN5GqXcaA
export default class EventHandler {
constructor(eventStream) {
this.eventStream = eventStream
}
on(topic, fn) {
this.eventStream.addEventListener(topic, fn)
return this
}
}
const key = (x, y) => {
return x + ',' + y
}
const unkey = k => {
return k.split(',').map(s => parseInt(s))
}
/* Given an x, y coordinate and a hashmap "x,y" => boolean values that indicate whether or not the tile at that
coordinate is blocked, this function will calculate the bitmask sum of the given coordinate. */
function computeBitmask(x, y, blockedCells) {
@Larkenx
Larkenx / Perl6CrashCourse.md
Last active December 5, 2018 20:45
A crash course guide on how to program in Perl 6

Perl 6 Crash Course

I struggled immensely with trying to understand the Perl 6 documentation. I feel that it's almost impossible for folks who aren't familiar with Perl to learn, and it fails to properly communicate some of the basic features of the language in a pleasant & easy to understand way. I did a crash course through the docs to finish a programming challenge for Day 4 in Advent of Code 2018. You can find my solution to that problem here. Here's my tips and tricks after staying up til 3AM to finish the advent challenge.

Perl 6 Setup

You can find some good instructions on setting up perl here.

Be sure to add #!/usr/bin/perl and use v6; to the top of your .p6 or .pl file.

Text Editor Recommendations

I don't recommend to go without some sort of syntax checker, or else you'll waste a lot of time. Perl 6's error messages are prett

@Larkenx
Larkenx / Item.js
Last active December 27, 2018 05:18
JavaScript multiple inheritance / mixins for game development (entity component systems inspired) - mixin implementation from http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
import { Entity } from '#/entities/Entity.js'
import { itemTypes, equipmentSlots, ammoTypes } from '#/utils/Constants';
import { mix } from '#/utils/Mixins'
import { Stackable, Equippable, AmmunitionTyped, Fireable } from './ItemMixins';
export default class Item extends Entity {
constructor(options) {
super(options)
this.category = options.category || itemTypes.MISCELLANEOUS
this.description = options.description || []
@Larkenx
Larkenx / Program.cs
Created March 24, 2019 15:22
Space Engineers to script to calculate ratio between maximum effective thrust and the gravitational force applied to your ship
using Sandbox.Game.EntityComponents;
using Sandbox.ModAPI.Ingame;
using Sandbox.ModAPI.Interfaces;
using SpaceEngineers.Game.ModAPI.Ingame;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System;
using VRage.Collections;
@Larkenx
Larkenx / App.vue
Last active November 13, 2019 18:07
Abstraction for dialog / textfield based date selector https://vuetifyjs.com/en/components/date-pickers#examples
<template>
<v-container>
<v-row>
<v-col>
<DateSelectorTextField
label="Start Date"
hint="The start and end date can be used to filter results!"
@selectDate="date => this.startDate = date"
/>
@Larkenx
Larkenx / gist:95a13ed32f816160e2b7588e4cb04193
Created December 6, 2020 21:44
spaghetti k2 + AAI mall
0eNq8ve12HMmNtXsv/VvlFUB8+1be5eVFSdVqHlOkDkn1zJxZc+8nS227s8jMLDyA5v0jj8dSoBAZ2EBE7Nj4718+Pnw/f3u+f3z95a///cv9p6fHl1/++n/++5eX+y+Pdw+X/9/rf307//LXX+5fz19/+fDL493Xy3/79e7l9fT6fPf48u3p+fX08fzw+sv/fPjl/vHz+T9/+av8z4ebI9y9vJy/fny4f/xy+nr36bf7x/NJV0Po//ztwy/nx9f71/vzH7/ox3/5r78/fv/68fy82Pj3SP94Pt19/v3u8dP58+n78q+fvzw/Lf/5x4/68Mu3p5dlkKfHyy9ZBj41/Uv98Mt/Lf9XkfaXupj8fP98/vTHX9EP//q1T99fv32/OPXOsm5afjMZG3bzn3b7Yndj5BwfuW2PXNyzJabZun/cmazqdCndnKwWH3lnsrpv5Dpv/uYRH3nnN0/nyO36N1993rJhR1Lc0Pt1tGXozwA3LNNaY8tU1BsgNQfhRJxRX5XOaHEakpvrWmp86J2FLQ2tgxT9Gs7gL4N+DScWlEkNOaGh0IhVJzSUTg2J01ChhpypvlRqyIkBJVNDTgwoFGzUiQglUUPOOqAINeREhkyRQZ3IkCkyqBMZMg3Y7ESGTCEoO5Eh04DNTmTIFIJy9hYmOcdKouyEiqywpMzV7eIRKhWDi07syHLgYtsytI0dD093i49bBtKRAUMZkwczqMNkcH8m/4SSh6cv9y+v959On347v7yevi0b/fvfz6dvz0+/3+8Yn2+Nf7x73l4rxYkk2uEXK+7zBY1uCIoTW5Tm6OKsOpTm6OKEEqU5urihRIYJSg6+mhNLhGbt0gOhJtuhlrfsjOvTvvvHl/Pz6/aoR+ix6cM8PgfcMPGuFFgM3P/4Jl+ez48LrG2ePiVsJ+/aeb7/9eG8/OMvd//f8q83zQk2lyLmlJrrEWuZWisRawVP5a61u+evT8+nb/fn50+XQd4Y//DjYPrlMszLt/MSsl+fPn9/OF8W7tbvqvB
@Larkenx
Larkenx / blueprint.txt
Last active December 7, 2020 20:01
uranium fuel requester delivery cannons
0eNrtnVGP4kYWRv9K5McVRFSV7e8aKXncx1XeVyPkhuppK2CIMZ1tjfjva5ruoQdMBzg9iSLlZVqAuS7X/eqUQTrDl+RuvomrpqrbZPwlqabLep2M//slWVef63K+e659WsVknFRtXCSDpC4Xu0dlWQ33hwybOI3VY2yS7SCp6ln8XzJ228EfVljH4SzOd298Gk7Lul7Wbwr47adBEuu2aqu4H8/zg6dJvVncdacau3dHMkhWy3X33q5md/pdvdx+zAbJUzIehmz0Y9adqbvStlnOJ3fxoXysls3uyCaWs8l8+blat9W0O+99OV/H/bF1nO7qrXeHud0/n5sY67dDq2bdsHx3cNVMN1W7f7z9tN3uJuNo+P7r8GdxWs1iM5wuF3dVXbbLvtHraOyzqtkP57lS35W8lJ10r82qrwO/r5p1O/mjxrQxzoerednGZH/t67bcxWO0e7BYlc3zKMfJz917lpt2tbm+5OqpG9mmbif3zXIxqequRjJum03cktnuUtO93e87OTs+Oj1pzaC/bH6maeG97PY07RC5tHhuW9e0atX//uGqnP46/HaeTgaQ3pial9O/SU3+Aal5rJp20z1zmJX9Kozl9OHjgrOblqpex6bdE+ZMdvYr9Ux4esJwVXKyM4HIzo2zrxeHMNiF3Xgd4NduXLGET6fttRnuqBk/JVdMW3o6bX0Tk38dyStMh9OHuG47Qv+26f72T1F6PEXvTcpiOYuT5f1kuYrdlTyXcdeww192Jbp9zaeXrflNU9bVZjH0Ietb83Z5xswdTq6TfaKndnFLm8wfn+Xl6Ml9Ne/est+uX28E3pm+7s9qvZnHZNe1zXM0d6vwdKsf3Yq99B/sHe+Y7hruuXBmVTh3a0uy73//8u2C+pB+nJT8K+5fduvgshsYl57r2+G+s2yq9mERn9f8u60bHZa7/7Z1aX/rDpU/ZkGt467M5NDHYZe+N9hP/vVOH98vfl23Dt3pf90d92fw3o5z/LLTZR8dXLjtriP8fe86jpN/brN
@Larkenx
Larkenx / hauler.lua
Last active December 30, 2020 23:48
Space Exploration Hauler Moon Logic Lua Script
-- Useful Signal Constants
CRUSHED_NAQ_SIGNAL = "se-naquium-ore-crushed"
NAQ_ORE_SIGNAL = "se-naquium-ore"
ARCOSPHERE_SIGNAL = "se-arcosphere"
VOID_PROBE_SIGNAL = "se-void-probe-data"
DISTANCE_SIGNAL = "signal-distance"
ROCKET_FUEL_SIGNAL = "se-liquid-rocket-fuel"
ANTIMATTER_FUEL_SIGNAL = "se-antimatter-stream"
ACCUMULATOR_CHARGE_SIGNAL = "kr-energy-2"