Monday, July 31, 2023

How should we train men to be military officers?

    The service academies are now a national joke.  They teach very little aside from arrogance and woke Leftism.  They should teach future military officers to be leaders and thinkers.  How could we better go about this task?  What value does a 4 year degree, in this age of reduced (or eliminated) standards, bring to military leadership?  Remember, the ultimate purpose of officers is to lead men into battle and win wars.

    I like Heinlein's idea.  No man shall be eligible for officer training until after he has honorably served no less than two years nor more than ten as an enlisted man.  This weeds out a lot of undesirable candidates.  If you are unwilling to serve amongst the lowest of the low, to put up with the dirty end of the stick, you aren't what we need or want to lead troops into battle.  We also only want patriots.  Anti-American types need not apply.

    After two years enlisted duty, a young man may apply to officer candidate school.  I envision this school as lasting at least six months, at most two years.  The topics taught shall be leadership, psychology, advanced first aid and field hygiene, military history, geography (both physical and human), effective communications (oral and written), basic accounting, technology (heavy on the practical, light on the theoretical), tactics, logistics, military operations, and basic staff work.  Practical courses shall include rigorous physical training (daily), weapons handling (daily), marksmanship (monthly), a martial arts discipline (weekly), close combat (weekly, using airsoft guns), drone use (weekly), wargaming (weekly, starting with miniatures, eventually moving on to board games, and finally computerized staff games).  One week per month shall be spent training in the field or onboard ship.

    Graduation is to be conditional upon successful completion of all courses and activities, honorable and moral conduct throughout, as well as acceptable conduct during a six week final exercise in the field or onboard ship.  Upon graduation, these young men will be commissioned as junior officers, with a service obligation of six years.

    What about doctors and nurses?  They do not lead troops into combat, so they don't get to be officers.  Doctors could be Warrant officers, but honestly, most of them should just be DoD civilians under long term contracts.

    Those are my thoughts on the topic.  What are yours?

Friday, July 28, 2023

FRPG alternate rules

 Abstract wealth:

Wealth is measured in abstract coinage. If you want to buy something, you compare its price with your coinage. If the price equals your coinage, you buy it and lose a coin. If the price is one less, you buy it and lose a coin one third of the time. If the price is two or more coins less, you just buy it. You can't afford anything that costs more coins than you have.

Adding treasure works similarly. Anything worth less than one coin than you have doesn't add to your wealth. One coin less will add to your coinage one chance in six. Treasure equal to your coinage increases it half the time.  Treasure one coin higher than your current wealth is increased one chance in six.

When using slot based encumbrance, your coinage occupies 1/2/3/5/10 slots. When using pounds, your coinage weighs 1/3/10/30/100 pounds. More than that and you need a wagon or magical container.


Alternate spellcasting
Slots and checks in a d20 system.
(Spells have tiers instead of levels to avoid confusion.)
Use the spells per day charts. Casting those spells doesn't require a check, but does use the slots. Daily renewal of spell slots requires a minimum of 6 hours of sleep plus one hour of spellbook study or prayer.
To cast additional spells, the caster makes a spellcasting check at
DC 10 + twice the spell tier. Their casting bonus is their spellcasting level plus stat bonus.
If a caster fails a spellcasting roll by 5 or more, they cannot attempt to cast that spell again until after a full turn of uninterrupted spellbook study or prayer. If they fail by 10 or more, they can't attempt spellcasting checks of spells of that tier or higher until after an uninterrupted hour of spellbook study or prayer.
If a caster makes a roll by 10 or more, something good happens. Examples: Spell is upcast, damage/healing is rolled with advantage/maximized/doubled, spells affects triple the usual targets, spell duration is tripled, area of effect is doubled, allies/enemies in AOE are ignored, caster gets to choose instead of rolling on a random chart, caster regains a used spell slot of that tier or higher, caster heals the spell's tier in hit points...
Cantrips are tier 0 spells. Cantrip checks are made with advantage once the caster gains a tier 2 spell slot. Read Magic is a cantrip.
Caster can attempt to cast a known spell of one tier higher than their chart says they can, but the check is made with disadvantage. Failure by 5 results in the loss of half the spell's tier in hit points.  Failure by 10 results in the loss of the spell's tier in hit points.  These are in addition to the usual penalties.
To upcast a spell (when allowed), either use a higher tier slot, two equal slots, a slot and two of the next lower slots, a slot and a check, or disadvantage on the check.
Turn Undead is a cleric spell-like ability, where the DC is 10 + twice the target's hit dice. For every point the check exceeds the DC, one additional creature (of that DC or lower) is turned. Succeeding by 10 destroys the target, with an additional creature destroyed for every point higher. Failing by 5 or more results in the cleric not being able to attempt to turn that creature again until after an uninterrupted turn of prayer. Failing by 10 results in the cleric not being able to turn any creatures of that power or higher until after an uninterrupted hour of prayer.

Wednesday, July 26, 2023

Referencing and Dereferencing in Nim



Here is an executable guide to how referencing and dereferencing work in Nim. I made this to understand it myself, because there is no explanation in the online manual or either book on Nim.

******************


type
refInt = ref int
var
a: int = 1
b: refInt
c: refInt
d: refInt


# UPDATE
# Use this template to make referencing much easier!

template `-->` [T](receiver: ref T, target: T)=
receiver = cast[ref type(target)](target.addr)

echo a
echo "a ", a.addr.repr
# Sadly, the Nim 2.0.0 update removed the physical addresses from repr
new(b)
b[] = a
echo b[]
echo "b ", b.addr.repr
a = 2
echo a
echo "a ", a.addr.repr
echo b[]
b = cast[ref int](alloc0(sizeOf(a))) # primitive, use new(b) instead
b[] = a
echo b[]
echo "b ", b.addr.repr
a = 3
echo a
echo b[]
b = cast[ref int](a.addr) # this works!
echo b[]
new(c)
c = b
echo "c ", c[]
a = 4
echo "a ", a
echo b[]
echo c[]
echo type(c)
echo "a ", a.addr.repr
echo "b ", b.addr.repr
echo "c ", c.addr.repr
echo ""

var x: array[5, int]
type ArrRef = ref array[5, int]
var y, z : ArrRef
x = [1, 2, 3, 4, 5]
y = cast[ArrRef](x.addr)
# addr provides a ptr type
# cast to convert ptr to ref
z = y
echo "x ", x, " is ", x.addr.repr
# repr is a lower-level version of the $ to-string operator
echo "y ", y[], " is ", y.addr.repr
# [] is dereference, so c[] --> b
echo "z ", z[], " is ", z.addr.repr
echo ""
z[4] = 10
echo "x ", x, " is ", x.addr.repr
echo "y ", y[], " is ", y.addr.repr
echo "z ", z[], " is ", z.addr.repr
new(z)
# use new() to allocate space for the value to be referenced
z[] = x
z[4] = 20
echo ""
echo "x ", x, " is ", x.addr.repr
echo "y ", y[], " is ", y.addr.repr
echo "z ", z[], " is ", z.addr.repr
# only z is now [1, 2, 3, 4, 20]

var q: ArrRef
q --> x



Friday, June 16, 2023

Why gravity is different

Gravity seems to act like a force, but has been shown to not be like the other forces.  It's different.

How?  Why?

Prerequisite knowledge:  Both momentum (mass times velocity) and kinetic energy (half mass times velocity squared) are conserved properties.

Forces act with energy.  They use energy to change things.  Two balls hitting each other exchange kinetic energy, thus altering their momentum.

Gravity directly affects a ball's momentum, thus altering its kinetic energy.  Gravity doesn't use energy to achieve its effects.

It's that simple.


Not quite so simple:  There are both objective and subjective time and, thus, velocity.  Objective time ticks along, moving things a certain distance in a certain time.  This is objective momentum, and is how photons move and change over time.  Subjective time ticks along faster or slower, stretching or shrinking perceived space along with itself.  This is subjective momentum (kinetic energy), and is how matter moves.  Photons don't have subjective time.

If momentum and kinetic energy are conserved, where do they come from when gravity accelerates something?  Space-time itself.  Space-time is a field of potential energy, from which all other fields and effects withdraw their energy.  In other words, kinetic energy + potential energy = constant, at every point.

Space-time is the field which governs motion, involving both time and distance.

Sunday, June 11, 2023

Thursday, June 8, 2023

Listack v0.4.0 is live

 I have spent the last few months creating and refining my own new computer language:  Listack.  Originally written in Python, I spent the last two months rewriting it in Nim, so it is now much, much faster.  What is Listack?  Besides a portmanteau of List and Stack, of course.

Listack is a concatenative, stack-based language inspired by Factor and False, among others.  It is interpreted.  It is flat - all functions are in-line functions.  Like all concatenative languages, it encourages the use of "higher" functions (called words) from "functional programming".  Listack has the concept of good/bad data baked into its core.  It has a very basic type system, but user created objects can use user-created types of arbitrary complexity.  

It is polymorphic with limited arity, meaning each command always uses the same number of arguments but the types of those arguments can differ through redefinitions of the word.  For example, '+' is used for both numbers and strings.  1 + 2 --> 3, where "abc" + "def" --> "abcdef".

The main problem with stack-based languages is that their syntax is weird.  Every command word depends on the data it needs to work upon already being on the stack, waiting for it.  This is postfix form:  1 2 +, instead of the more usual 1+ 2 or even + 1 2.  Listack gets around this by employing uniform function call syntax.  Every word except immediate ones can go in front of, between , or after its arguments.  The following are all equivalent in Listack:
+: 1 2        prefix form - before all arguments
1 + 2        infix form - after first argument
1 2 .+        postfix form - after all arguments
+(1, 2)        callable form - immediately before parenthesis surrounding all arguments

You can, to a degree, pick and choose how you want your program to look and feel.  Just keep in mind that every word actually executes in postfix form.  (Immediate words are essentially postfix without the leading period.)  Oh, and the commas are just syntactic sugar.  The parser converts them to spaces when they're not inside a quote.  The following snippets all add 1 to 2 and then multiply the result by 3.
1 2 .+ 3 .*
1 + 2 * 3
(1 + 2) * 3
*: (+: 1,  2) 3
(+: 1 2) 3 .*
*(+(1, 2) 3)
2.inc * 3

The following doubles and also squares a list of numbers to produce 6 10 20 9 25 100.
[3 5 10] {dup .+} {dup .*} bi_apply

This does a similar thing but compiles the numbers into lists [6 10 20] [9 25 100]
[3 5 10] {{dup .+} .map} keep {dup .*} .map


Listack has an interactive REPL.  After you compile it (nim c -d:release listack.nim), execute it by typing: 
./listack

You can run a program file as follows:
./listack filename
with options for -debug and -verbose

Don't have Nim?  Check out their website.