Skip to content

Instantly share code, notes, and snippets.

import { CourseHelpers } from '../CourseData';
import { Strategy, Aptitude } from '../HorseTypes';
import { RaceSolver } from '../RaceSolver';
import { RaceSolverBuilder } from '../RaceSolverBuilder';
import courses from '../data/course_data.json';
import tracknames from '../data/tracknames.json';
const G1TRACKS = ['11101', '10504', '10506', '10501', '11503', '11401', '11403', '10804', '11402', '10906', '11301', '10606', '11501', '10903', '10602', '10708', '11303', '10611', '10701', '11504', '10811', '10810', '11302', '10604', '10905', '11102', '10808', '11103', '10807', '11502'];
const enum Strategy { Nige, Senkou, Sasi, Oikomi, Oonige }
const enum Surface { Turf, Dirt }
const enum Aptitude { S, A, B, C, D, E, F, G }
type Phase = 0 | 1 | 2;
interface HorseParameters {
speed: number
stamina: number
power: number
/**
* Use the PEXT instruction and perfect hash functions to store small integer maps
* inside a uint64_t (or smaller).
*
* Compile with `-Wno-multichar -mbmi2 -mlzcnt` (or -march=native on any recent x86 CPU).
*
* Modify `tbl` below to change the map.
*
* If it takes a long time and doesn't find a solution, fiddle with the hash function (`h`).
*
import { CourseHelpers } from '../CourseData';
import { Strategy, Aptitude } from '../HorseTypes';
import { Region } from '../Region';
import { Rule30CARng } from '../Random';
import { RaceSolver, SkillType, SkillRarity } from '../RaceSolver';
const base = {
speed: 1400,
stamina: 800,
power: 1000,
@alpha123
alpha123 / ipa.rb
Created June 30, 2017 05:17
Ruby IPA parser
# encoding: utf-8
require 'rubygems'
gem 'ruby-enum'
gem 'unicode'
require 'ruby-enum'
require 'unicode'
module IPA
@alpha123
alpha123 / wolfram30.hpp
Created August 8, 2016 05:32
Guts of a random number generator based on cellular automata
#pragma once
#include <inttypes.h>
#include <limits.h>
namespace w30 {
typedef uint64_t state;
typedef uint32_t uint;
@alpha123
alpha123 / utility.hpp
Last active August 1, 2016 04:27
Magic C preprocessor stuff
#pragma once
#include <memory>
#include <utility>
/**
* 𝕬𝖇𝖆𝖓𝖉𝖔𝖓 𝖆𝖑𝖑 𝖍𝖔𝖕𝖊, 𝖞𝖊 𝖜𝖍𝖔 𝖊𝖓𝖙𝖊𝖗 𝖍𝖊𝖗𝖊
*
*
* You have been WARNED
@alpha123
alpha123 / mal_grab.pl
Last active April 16, 2016 00:19
MAL Downloader
#!/usr/bin/env perl
use v5.16; # given/when
use strict;
use warnings;
use Getopt::Long::Descriptive;
use LWP::Simple;
use Mojo::DOM;
use Data::Dumper;
use Text::CSV::Slurp;
@alpha123
alpha123 / ssa-interp2.c
Created April 5, 2016 00:38
Minimal Interpreter for SSA Bytecode — Explicitly Track CFG Paths
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
typedef int64_t value_t;
typedef uint64_t instr_t;
@alpha123
alpha123 / ssa-interp.c
Last active April 24, 2023 04:27
Primitive SSA Bytecode Interpreter
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#define _WITH_GETLINE
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <assert.h>