Marco Azimonti Personal Blog

Learning Lab
My Journey Through Books, Discoveries, and Ideas

Blog Search


[LinkedIn投稿] AI付き ナランダーゲーム

このブログ記事では、私が最新作として開発したLunar Landerゲームを紹介します。Pythonで作成し、高性能なC++製ニューラルネットワークライブラリを活用しています。自作したMLPを遺伝的アルゴリズムで学習させ、多様でカスタマイズ可能なシナリオでAIパイロットが安全に着陸できるよう設計しました。プロジェクトには手動操作とAI制御の両モード、詳細なトレーニング環境も盛り込みました。今回の取り組みでPython/C++の連携、ニューラルネットワーク実装、ゲームAIのための遺伝的アルゴリズムを幅広く取り扱いました。全コードはGitHubで公開しており、AIは異なる環境に合わせて再学習可能です。

[LinkedIn post] Lunar Lander con AI

In questo blog post presento il mio ultimo progetto, un gioco lunar lander creato in Python e supportato da una mia libreria C++ per reti neurali ad alte prestazioni. Ho implementato una rete neurale MLP addestrata con algoritmo genetico che permette all'AI di eseguire atterraggi stabili in scenari configurabili. Il progetto offre sia modalità di gioco manuale che guidata dall'NN, e comprende un sistema di training dettagliato. Mi sono concentrato su interoperabilità Python/C++, reti neurali e applicazione di algoritmi genetici all'AI di gioco. Il codice completo è su GitHub ed è facilmente adattabile a nuovi scenari.

[LinkedIn post] Lunar Lander with AI

In this blog post, I present my latest project, a lunar lander game developed in Python, powered by a high-performance C++ neural network library designed and written by me. My implementation uses a multi-layer perceptron trained with a genetic algorithm to develop an AI pilot capable of stable landings in configurable environments. The project incorporates manual play and NN-driven play, and provides a comprehensive training setup. Throughout, I explored Python/C++ interop, neural networks, and genetic algorithms for game AI. The complete code is available on GitHub, and the training routines can be adapted for new gameplay scenarios.

Lagrangian mechanics example: the pendulum

In this blog post, I demonstrate the application of Lagrangian mechanics to another classic problem, the pendulum. I define the system as a mass m on a massless rod of length r swinging under gravity g. I choose the angle \theta as the single generalized coordinate. I then calculate the kinetic energy T and potential energy V in terms of \theta and \dot\theta. Using these, I construct the Lagrangian \mathcal L = T - V and apply Lagrange's equation. This process systematically yields the well-known nonlinear equation of motion for the pendulum, \ddot\theta + (g/r)\sin\theta = 0.

Lagrangian mechanics example: rectilinear motion

In this post, I apply the Lagrangian method derived previously to an example, the rectilinear motion of a particle. I consider a particle of mass m moving along the x-axis under a potential V(x). I identify the single generalized coordinate as x. Then, I construct the kinetic energy T and the Lagrangian \mathcal L = T - V. By calculating the necessary partial derivatives \partial \mathcal L / \partial \dot x and \partial \mathcal L / \partial x and substituting them into Lagrange's equation, \frac{\mathrm d}{\mathrm d t} (\frac{\partial \mathcal L}{\partial \dot q_j}) - \frac{\partial \mathcal L}{\partial q_j} = 0, I demonstrate how this formalism naturally yields Newton's second law, m\ddot{x} = F_x.

Deriving Lagrange's equations and introducing the Lagrangian

In this blog post, I continue from d'Alembert's principle to derive Lagrange's equations of motion. I start by transforming the kinetic term \sum_i m_i \mathbf a_i \cdot \delta \mathbf r_i using calculus manipulations involving partial derivatives of the kinetic energy T with respect to generalized coordinates q_j and velocities \dot q_j. This leads to the first form of Lagrange's equations, \frac{\mathrm d}{\mathrm d t} (\frac{\partial T}{\partial \dot q_j}) - \frac{\partial T}{\partial q_j} = Q_j. For conservative systems where generalized forces derive from a potential energy V as Q_j = -\frac{\partial V}{\partial q_j}, I introduce the Lagrangian \mathcal L = T - V. This allows writing the equations in their standard, compact form, \frac{\mathrm d}{\mathrm d t} (\frac{\partial \mathcal L}{\partial \dot q_j}) - \frac{\partial \mathcal L}{\partial q_j} = 0.

Lagrangian mechanics: generalized coordinates and forces

In this blog post, I introduce an alternative approach to classical mechanics, the Lagrangian method. I begin by defining holonomic constraints and explaining how they reduce the number of coordinates needed to describe a system to its degrees of freedom, n. These n coordinates are called generalized coordinates, q_j. I then discuss the concept of virtual displacements, \delta \mathbf r_i, which are infinitesimal changes in position consistent with the constraints. Using d'Alembert's principle, which states \sum_i (\mathbf F_i - m_i \mathbf a_i) \cdot \delta\mathbf r_i = 0, I show how constraint forces can be eliminated from the equations of motion. Finally, I define the generalized force Q_j associated with each generalized coordinate q_j.

JavaScript integration for chess Mérida font displays

In this blog post, I present a JavaScript solution for dynamically generating chess diagrams using the Chess Mérida font. Instead of manually writing the HTML for each board, I use a script that reads a Forsyth–Edwards Notation (FEN) string provided in a `data-fen` attribute. The JavaScript parses this FEN string, identifies each piece or number of empty squares, and determines the correct Mérida glyph based on the piece type and whether it sits on a light or dark square. It then constructs the necessary HTML `div` structure for the board, including optional coordinate borders, and injects it into the designated placeholder element.

Displaying chess boards with the chess Mérida font

In this blog post, I explain my process for integrating the Chess Mérida font to effectively represent chess diagrams and notation online. I cover the specific glyphs used for pieces on both white and black squares, along with characters for figurine notation, border elements, and coordinate markers. I provide the necessary CSS setup to use this font and demonstrate how to style the board appearance with different color themes, including examples showing standard and alternative coordinate representations. This approach helps in creating clear visual representations of chess positions suitable for web content.

Building a PWA Template: Dropbox sync, i18n and offline

This post continues the development of a reusable PWA template. We dive into implementing robust file synchronization with the Dropbox API, including authentication, conflict resolution, and offline handling. We also cover adding multi-language support using i18next and enabling offline functionality through Service Worker caching strategies.

Building a PWA Template: structure, styling and core UI

This post details the initial steps in creating a reusable Progressive Web Application template. We cover setting up the HTML structure using Bootstrap 5 components like offcanvas sidebars and modals, applying custom CSS themes, implementing the core application logic, managing local storage for file data, and integrating common UI elements like datepickers and switches.

More ...