Skip to content

Instantly share code, notes, and snippets.

View PsySecCorp's full-sized avatar
🎯
Focusing

Patrick Ryan PsySecCorp

🎯
Focusing
View GitHub Profile
@PsySecCorp
PsySecCorp / worldEngine.md
Created January 15, 2025 00:35
worldEngine.md

https://docs.phaser.io/api-documentation/class/physics-arcade-world

You're absolutely right! In a multiplayer setting, directly adjusting objects on the screen can lead to inconsistencies due to network latency, differing client states, and other issues. To resolve this, using a physics space (often referred to as a "simulation" or "world" state) to handle the authoritative logic and movement makes things much more predictable and synchronized. Here’s a breakdown of how you can structure this:

1. Separation of Logic and Rendering

  • Physics Space (Simulation): This is the authoritative "truth" of the game. All changes to object positions, velocities, and other states (health, status, etc.) happen here. Think of it as a snapshot of the game state that updates according to both local and network inputs.
  • Rendering Layer: The visual representation of the objects is based on interpolating between past and current physics states to smooth out any discrepancies caused by lag or packet loss.
@PsySecCorp
PsySecCorp / its2019AndWeCanFinallyDoPrivateVariables.js
Last active March 12, 2019 04:32
How to sanely make private variables in modern JavaScript
// Using the WeakMap approach, the variables are kept outside of public access and when the instance of
// SomeClass is no longer referenced, all of its variables will be GCed as well
const instances = new WeakMap()
class SomeClass {
constructor (privateVar1, privateVar2, privateVar3) {
instances.set(this, {
privateVar1,
privateVar2,
@PsySecCorp
PsySecCorp / FlowNote.md
Last active August 8, 2022 16:25
FlowNote

FlowNote

We're rapidly approaching a world where flow-based programming is taking the lead, but there isn't any useful notation to represent all of the complexities of flow management. Let's assume a basic flow that takes a click event, extracts the X and Y coordinates from it, and moves a player based on the extracted values.

+----------+     +-----------+               +------------+
| getClick +-----> extractXY +---------------> movePlayer |
+----------+     +-----------+   xyChannel   +------+-----+
                                                    |
 |
@PsySecCorp
PsySecCorp / emotion.md
Last active August 8, 2022 16:23
Create a new emotion

I wrote a book in 2005 that suggested the military wouldn't invent AI first. Instead, it would be the financial sector. I reasoned that as more and more humans come online through mobile devices, more and more data would be generated: video, audio, social, geospatial, and other domains yet to be popularized. (Looking at you, voxel clouds!)

Eventually, we would generate hundreds of exabytes per second. I reasoned that Moore's Law would hit a point where quantum problems with heat would slow it down, forcing transistor counts to scale horizontally (via clouds and specialization) instead of through innovation at the atomic scale.

This means while storage prices go down, processing costs to extract first move advantage shoot through the roof. Unlike their Soviet counterparts, the West would not be able to hire half of the population to analyze the data. It couldn't even hire 200% of the population to analyze that pipeline.

Thus, financial markets start to tackle the problem one bite at a time to find foo