User:Pee/Sandbox

From Valve Developer Community
< User:Pee
Revision as of 17:45, 29 August 2025 by Pee (talk | contribs) (This section of the alias page is very badly worded and potentially inaccurate, I'm attempting to make it more readable.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Advanced uses

Ignoring the limitation that there can only be a predefined maximum number of aliases, the alias command alone makes the console Turing-complete. In other words, it is able to simulate any computer calculation, meaning a command can be run based on an arbitrarily complex way that aliased commands were invoked. For example, an alias can run another command if the amount of times the alias was invoked previously was prime. There are many uses that are more practical.

If the limit of a predefined maximum number of aliases is not ignored, the console is only able to simulate a finite-state machine. However, due to how the alias command can simulate a finite-state machine, it negates the typical drawback of mathematical operations requiring extremely large quantities of states. This is because unlike a traditional finite-state machine, the results of inputs (contents of aliases) are not changed by default upon a transition. The following example helps illustrate this:

alias state_A "alias input_1 state_B; alias input_2 state_C; alias input_3 state_D" alias state_B alias input_3 state_B

Here, after state A is activated, followed by input 1 firing, the functions of inputs 1 and 2 persist after state B becomes the current state. This attribute of inputs that may be defined independent of each other creates the possibility of encoding values in binary.

Compare the Source engine's ability to store a 32-bit value with 32 independent binary values to a traditional finite-state machine's requirement of 232 states to store an equivalent value.