This file contains 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
class Player | |
attr_accessor :started, :firstkill | |
def play_turn(warrior) | |
if not @started | |
@started = true | |
warrior.pivot! | |
elsif warrior.look.select{|space| space.enemy?}.length > 0 | |
warrior.shoot! | |
elsif warrior.look.select{|space| space.enemy?}.length == 0 and not @firstkill | |
@firstkill = true |
This file contains 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
#!/usr/bin/env python2.7 | |
string = '' | |
def decodeWhiteChar(char): | |
if char == '\t': # tab | |
value = '00' | |
elif char == '\r': # cr | |
value = '01' | |
elif char == '\n': # lf |
This file contains 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
#!/usr/bin/env bash | |
set -euo pipefail | |
## Defaults | |
keepGensDef=10; keepDaysDef=7 | |
keepGens=$keepGensDef; keepDays=$keepDaysDef | |
## Usage | |
usage () { | |
printf "Usage:\n\t trim-generations.sh (defaults are: Keep-Gens=$keepGensDef Keep-Days=$keepDaysDef Profile=user)\n\n" |
This file contains 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 os | |
import sys | |
def unicode_to_surrogate_pair(codepoint): | |
# Convert a Unicode codepoint to a surrogate pair if necessary | |
code = int(codepoint, 16) | |
if code <= 0xFFFF: | |
return f"\\u{codepoint.lower()}" | |
# Calculation for surrogate pairs | |
code -= 0x10000 |