慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
吾如何自无始至终筑实时机器人战阵之模拟器——逻辑竞技场
Ali Haggag · 2026-05-24 · via DEV Community

一计算机学子自空荡之代码库至生产平台之征途,以特制脚本语言、60帧物理引擎,及逾三千行实战型TypeScript为器.

吾欲创物,令竞技编程之乐.非又一力扣之摹本.欲使汝之算法非仅过试案——欲令其搏战.

其理:士撰码以驭机。机实时相搏。尔智对天下.

此乃逻辑之场.

自零始 — 引擎

初难,乃自构引擎。无Unity,无Phaser — 纯TypeScript耳。

版本0.2.0,初仅二机械行于素帛之上。然欲达此境,必先解首度之真技痼:

独占之困。二NestJS之务共御游戏之机——此乃吾之误也。各持其本,故状全然失谐。其解:@Global()饰以一器,令全模共御一机。

@Global()
@Module({
  providers: [GameService],
  exports: [GameService],
})
export class GameModule {}

入全景模式 出全景模式

一匠饰之。三时寻错.

营阿利斯克——一制之脚本语也

此乃吾最狂之决。非择JavaScript或Lua以驭机之脚本,乃自营一语.

何哉?吾欲使玩家思之如算法,非徒抄录代码而已。AliScript须简明,俾初学者易解;亦须刚健,以赏专家之智。

此管也:

String Script → Lexer → Tokens → Parser → AST → Server Evaluator → Robot Actions

入全景模式 出全屏模式

初版支持基本条件语句:

IF CAN_SEE_ENEMY
  FIRE
END
MOVE

入全景模式 出全屏模式

自二点四版本始,渐近图灵完备之境:

WHILE TRUE DO
  IF CAN_SEE_ENEMY AND MY_ENERGY > 30 DO
    BROADCAST(NEAREST_VISIBLE_X)
    BURST_FIRE
  ELSE IF IN_STASIS DO
    WAIT
  ELSE DO
    SCAN
    PATHFIND
  END
END

入全屏模式 出全屏模式

至难之弊,运算优先级之失也。

2 + 3 * 4本应求20,反得14。凡繁重乘除之算,皆默然得谬值。其解,须析之。parseBinaryExpression()分为二等,各别而序。parseAddition()parseMultiply().

表現之危機

至v1.3.0,竞技场运行约15帧。剖析得罪者:

三千八百六十二毫秒脚本瓶颈主线程窒碍难行useState每秒更新六十次。

此修复乃双态之架构也。

// Before: useState causes re-render on every tick
const [gameState, setGameState] = useState(null);

// After: useRef for game logic, throttled state for UI only
const gameStateRef = useRef(null); // updates at 60fps, zero re-renders
const [uiState, setUiState] = useState(null); // updates at 10fps, DOM only

入全景模式 出全景模式

脚本耗时自3,862毫秒降至近乎零

一次发布,六项性能修复

至v2.5.0时,吾行全然剖析,得六处同时之窒碍:

其一,WebSocket负载之阻 — 静态数据无故每秒发送十次。修复:初始化一次,自后续有效载荷中剥离。

2. 障碍物 WebGL 绘制调用三十次 — 改写为 THREE.InstancedMesh。三十绘制调用 → 四绘制调用。

3. 十 useFrame JS 回调用于障碍物动画 — 将所有脉冲数学移至 GPU,通过片段着色器实现。每帧零 JS 回调。

四、服务器内存泄漏 — 回放快照进行无限制深度克隆。增加环缓冲区,限制300个对象

五、幽灵匹配大屠杀 — 玩家关闭浏览器时,物理引擎持续高速运行。数百幽灵匹配默默积聚CPU资源。修复:将有线断开生命周期与引擎关联,玩家全部离场时立即停止。

部署之梦魇

自 localhost 至 logicarena.dev 之途,实为险阻。

2.57GB 之 Docker 上下文炸弹 — 初建时,2.57GB 之数据传送至 Docker 守护者,盖因 node_modules 未被排除。修正 .dockerignore,上下文减至 15MB。

Prisma 幽灵引擎阿尔卑斯林拒行Windows所编之普里马二进制。增之。linux-muslbinaryTargets.

WebSocket 跨域之障— 每一Socket.IO之连接皆被拒,盖因网关硬编码所致也localhost:3000CORS数组扩展,修复Nginx WebSocket代理头。

静默之邮吏— DigitalOcean默然阻新Droplets之SMTP出站。无错误,无送达,徒留虚空。

今之建筑

logic-arena/
├── apps/
│   ├── client/     # Next.js 16, React Three Fiber, PWA
│   └── server/     # NestJS 11, Socket.io, JWT
└── packages/
    ├── engine/     # Custom TypeScript physics engine
    └── logic-parser/ # AliScript lexer, parser, evaluator

入全景模式 出全屏模式

吾所习得

1. 建筑之决,积重难返。每以速效之法绕过模块系统者,其后必生三弊。

二、优化前之画像三千八百六十二毫秒之瓶颈,未测则隐,既测乃现

三、定制语言可行抽象语法树之评估者,实乃递归之树行者——名虽可怖,实则径直

四、早发其行,速迭其变 逻辑竞技场,四月之内,独力研创,自方寸之画载二机械,渐至于六十层之算法征途。

试之

直播: logicarena.dev — 无需账户,客可入。

GitHub: Ali-Haggag7/logic-arena

书尔初篇脚本,观尔机械搏战,于注脚中言尔所思!