Skip to content

Instantly share code, notes, and snippets.

View Ravenslofty's full-sized avatar
💭
Black lives matter.

Lofty Ravenslofty

💭
Black lives matter.
View GitHub Profile
import json
import lzma
l = []
with open("staff.txt", "r") as infile:
with lzma.open("staff.txt.xz", "w") as outfile:
l = infile.read().split(",")
outfile.write(json.dumps(l).encode("utf-8")
@Ravenslofty
Ravenslofty / Makefile
Created November 27, 2016 18:01
WyldChess makefile
VERSION = 1.0
CC = gcc
CFLAGS = -std=c11 -O3 -pthread
SRC = src/*.c
OBJ = $(SOURCES:.c=.o)
NAME = wyldchess
BIN_PATH = binaries/v$(VERSION)
EXEC = $(BIN_PATH)/$(TARGET)/$(EXEC_BASE)$(VERSION)
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Dan Ravensloft <dan.ravensloft@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
Rank Name Elo +/- Games Score Draws
1 dorpsgek 163 32 400 71.9% 24.8%
2 faile 139 33 400 69.0% 17.5%
3 fmax 10 31 400 51.5% 17.5%
4 baislicka -8 31 400 48.9% 17.2%
5 pigeon -407 50 400 8.8% 11.0%
@Ravenslofty
Ravenslofty / mailbox.c
Last active August 29, 2017 18:10
mailbox movegen
int * vector = dirs[<piece>];
while (*vector != 0) {
int nextsq = currsq + *vector;
while (board[nextsq] != OFFBOARD) {
AddMove(currsq, nextsq, <whatever>);
if (board[nextsq] != EMPTY || !slide[<piece>])
break;
Board[dest sq] = Board[from sq]
Board[from sq] = valid empty sq
package main
const (
MoveQuiet byte = iota
)
type Move struct {
From byte
To byte
Kind byte
@Ravenslofty
Ravenslofty / attacks.c
Created December 22, 2016 14:50
Mailbox bitlist generator
const char Vector[5][8] = {
{ +10, +11, +1, -9, -10, -11, -1, +9 }, // K
{ +10, +11, +1, -9, -10, -11, -1, +9 }, // Q
{ +10, +1, -10, -1, 0, 0, 0, 0 }, // R
{ +11, -9, -11, +9, 0, 0, 0, 0 }, // B
{ +21, +12, -8, -19, -21, -12, +8, +19 } // N
};
const char Slide[5] = {
0, 1, 1, 1, 0
/* This is what I do at the moment for a knight. */
void GenKnightBitlist(struct Board * b, int tmp, int from)
{
int i, j, col;
i = from;
col = FILE (i);
j = i - 6;
if (j >= 0 && col < 6) {
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
23.62 12.68 12.68 125048905 0.00 0.00 RecalculateAttacks
15.57 21.04 8.36 _mcount_private
14.83 29.00 7.96 400 19.90 99.15 Perft.part.0.constprop.4
12.85 35.90 6.90 33815901 0.00 0.00 RecalculateAttacksFromScratch
11.14 41.88 5.98 749625666 0.00 0.00 GenBishopBitlist