<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/rss/feed.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Carlos Requena</title><description>Ingeniero Informático</description><link>https://carlos-requena.github.io</link><language>en</language><item><title>Final Degree Project — Explainability (XAI) Platform for Machine Learning Models</title><link>https://carlos-requena.github.io/Web_Personal/en/post/tfg-xai-nets4learning</link><guid isPermaLink="false">en:tfg-xai-nets4learning</guid><description>Bachelor&apos;s thesis: an Explainable AI (XAI) module integrated into the Nets4Learning platform that produces visual explanations of Deep Learning models running entirely in the browser with TensorFlow.js (SHAP and LRP).</description><pubDate>Thu, 30 Jul 2026 22:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Bachelor’s thesis for the &lt;strong&gt;Computer Engineering degree&lt;/strong&gt; at the &lt;strong&gt;University of Jaén&lt;/strong&gt;, developed within the &lt;strong&gt;SIMIDAT&lt;/strong&gt; research group under the supervision of &lt;strong&gt;Antonio Jesús Rivera Rivas&lt;/strong&gt; and &lt;strong&gt;María Dolores Pérez Godoy&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The project adds an &lt;strong&gt;Explainable AI (XAI)&lt;/strong&gt; module to the educational platform &lt;strong&gt;Nets4Learning&lt;/strong&gt;, generating visual, interpretable explanations of Deep Learning predictions under one key constraint: &lt;strong&gt;all computation runs in the browser&lt;/strong&gt;, with no server (backend).&lt;/p&gt;
&lt;h2&gt; Live demo&lt;a href=&quot;#-live-demo&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://nets4learnings.netlify.app&quot;&gt;&lt;strong&gt;Try the platform → nets4learnings.netlify.app&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Runs from the browser, including mobile. Model training and inference execute on your own device via TensorFlow.js.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; &lt;strong&gt;&lt;a href=&quot;/Web_Personal/tfg/Carlos_Requena_TFG.pdf&quot;&gt;Download the full thesis (PDF)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt; Motivation and goal&lt;a href=&quot;#-motivation-and-goal&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Deep neural networks often behave like &lt;strong&gt;“black boxes”&lt;/strong&gt;: they deliver accurate predictions without a comprehensible justification. In an educational setting this is a barrier: for a student to truly understand &lt;em&gt;how&lt;/em&gt; a network works, it is not enough to see whether it is right or wrong, they need to know &lt;strong&gt;which features of the data drove the decision&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The overall goal was to &lt;strong&gt;design, implement and integrate&lt;/strong&gt; a module that provides visual explanations of Nets4Learning’s predictions, running &lt;strong&gt;entirely in the browser&lt;/strong&gt;. This constraint rules out the usual XAI libraries (built for Python on a backend) and forces the problem to be solved with what the client can offer.&lt;/p&gt;
&lt;h2&gt; What is Explainable AI (XAI)?&lt;a href=&quot;#-what-is-explainable-ai-xai&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;XAI groups the techniques aimed at making model decisions comprehensible. They are usually classified by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scope&lt;/strong&gt;: &lt;strong&gt;global&lt;/strong&gt; explanations (the model’s overall behaviour) vs &lt;strong&gt;local&lt;/strong&gt; ones (a single prediction).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Model dependence&lt;/strong&gt;: &lt;strong&gt;model-agnostic&lt;/strong&gt; methods (treat the model as a black box, relating inputs to outputs) vs &lt;strong&gt;model-specific&lt;/strong&gt; methods (analyse the network’s internal architecture).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To cover both, the module combines &lt;strong&gt;two complementary techniques&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;️ Implemented techniques&lt;a href=&quot;#️-implemented-techniques&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;Agnostic method — SHAP (via WebSHAP)&lt;a href=&quot;#agnostic-method--shap-via-webshap&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;SHAP&lt;/strong&gt; (&lt;em&gt;SHapley Additive exPlanations&lt;/em&gt;) is based on the &lt;strong&gt;Shapley values&lt;/strong&gt; of cooperative game theory: it fairly distributes each feature’s contribution to the prediction by comparing combinations of present and absent features to obtain their marginal contributions.&lt;/p&gt;
&lt;p&gt;Its main drawback is the &lt;strong&gt;high computational cost&lt;/strong&gt; (it requires many model evaluations per prediction), which is a challenge when the client itself provides the computing power. To solve it, &lt;strong&gt;WebSHAP&lt;/strong&gt; was integrated, a SHAP implementation designed to run exclusively on the client side over TensorFlow.js, preserving data &lt;strong&gt;privacy&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Specific method — LRP&lt;a href=&quot;#specific-method--lrp&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;LRP&lt;/strong&gt; (&lt;em&gt;Layer-wise Relevance Propagation&lt;/em&gt;) accesses the inside of the network and &lt;strong&gt;back-propagates “relevance”&lt;/strong&gt; layer by layer down to the input, revealing which elements contributed most to the prediction. It is far more efficient than SHAP (a single pass), at the cost of being tightly coupled to the model’s architecture.&lt;/p&gt;
&lt;h3&gt;Image explanations — superpixels&lt;a href=&quot;#image-explanations--superpixels&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For image models, explanations are computed over &lt;strong&gt;superpixels&lt;/strong&gt; —via the &lt;strong&gt;SLIC&lt;/strong&gt; algorithm— (regions grouped by proximity and colour similarity) instead of thousands of isolated pixels, complemented with &lt;strong&gt;facial segmentation&lt;/strong&gt; for face-based tasks. This yields interpretable heatmaps over a manageable number of visually meaningful regions.&lt;/p&gt;
&lt;h2&gt;️ System architecture&lt;a href=&quot;#️-system-architecture&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Nets4Learning is a &lt;strong&gt;React SPA&lt;/strong&gt; with client-side inference via TensorFlow.js. The explainability module is integrated as another layer, organised into &lt;strong&gt;three levels&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Model layer&lt;/strong&gt; — the existing models, grouped by task (tabular data, image classification and object detection).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Explainability layer&lt;/strong&gt; — the core developed in this work, &lt;strong&gt;independent of any specific model&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Presentation layer&lt;/strong&gt; — the UI components that let the user request an explanation and visualise the results (feature-importance charts or heatmaps over the image).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Design pattern: Template&lt;a href=&quot;#design-pattern-template&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The most important design decision was to &lt;strong&gt;decouple&lt;/strong&gt; explainability from the models. Each task type exposes a &lt;strong&gt;common interface&lt;/strong&gt; that all its models implement (enable the model, obtain a prediction from an input). The explainability layer works against that abstraction following the &lt;strong&gt;Template pattern&lt;/strong&gt;: adding a new model &lt;strong&gt;does not require modifying&lt;/strong&gt; the explainability module as long as it respects the interface, satisfying the &lt;strong&gt;extensibility&lt;/strong&gt; requirement.&lt;/p&gt;
&lt;h2&gt;⚙️ Tech stack&lt;a href=&quot;#️-tech-stack&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;React&lt;/strong&gt; — SPA interface&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TensorFlow.js&lt;/strong&gt; — in-browser training and inference (GPU via WebGL)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WebSHAP&lt;/strong&gt; — client-side SHAP implementation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LRP&lt;/strong&gt; — custom relevance-propagation implementation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JavaScript&lt;/strong&gt; — the ecosystem’s main language&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Methodology&lt;a href=&quot;#-methodology&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Development followed an &lt;strong&gt;incremental model&lt;/strong&gt;: each increment added explainability to a family of models —tabular data, image classification (&lt;strong&gt;MNIST / KMNIST&lt;/strong&gt;), object detection and LRP-based introspection—, with periodic reviews with the supervisors. Version control with &lt;strong&gt;Git/GitHub&lt;/strong&gt; (feature branches), &lt;strong&gt;VS Code&lt;/strong&gt; as the IDE and &lt;strong&gt;LaTeX/Overleaf&lt;/strong&gt; for the report.&lt;/p&gt;
&lt;h2&gt;✅ Conclusions and results&lt;a href=&quot;#-conclusions-and-results&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The overall goal was met: &lt;strong&gt;Nets4Learning now accompanies every prediction with a visual explanation computed entirely on the client&lt;/strong&gt;, with no server. The specific objectives were fulfilled:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SHAP (WebSHAP)&lt;/strong&gt; was integrated into every model except digit detection (KMNIST), which uses &lt;strong&gt;LRP&lt;/strong&gt; over an introspectable model.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;React UI components&lt;/strong&gt; were integrated: the user requests an explanation and visualises it as an importance chart or a heatmap.&lt;/li&gt;
&lt;li&gt;The module was &lt;strong&gt;validated&lt;/strong&gt; with &lt;strong&gt;unit tests&lt;/strong&gt; and functional validation on the real application, confirming that the explanations are consistent with the models’ behaviour.&lt;/li&gt;
&lt;li&gt;The biggest challenge was &lt;strong&gt;secure, private client-side execution&lt;/strong&gt;, which shaped the choice of techniques and forced compromises (e.g. the approximation in LRP’s &lt;em&gt;pooling&lt;/em&gt; layers).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The architecture was successfully integrated across &lt;strong&gt;object detection, image classification (MNIST/KMNIST) and tabular models&lt;/strong&gt;, respecting the &lt;em&gt;zero-server&lt;/em&gt; constraint and adapting to the multilingual interface (Spanish, English and Japanese).&lt;/p&gt;
&lt;h2&gt; Future work&lt;a href=&quot;#-future-work&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Add new techniques: &lt;strong&gt;Grad-CAM&lt;/strong&gt; for convolutional models or &lt;strong&gt;LIME&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Extend &lt;strong&gt;LRP&lt;/strong&gt; coverage to more architectures and complex layers.&lt;/li&gt;
&lt;li&gt;Leverage &lt;strong&gt;WebGPU&lt;/strong&gt; and the new client-side inference engines to overcome current performance limits.&lt;/li&gt;
&lt;li&gt;Move SHAP’s heavy computation to &lt;strong&gt;Web Workers&lt;/strong&gt; to keep the UI free during longer explanations.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Bachelor’s Thesis · Higher Polytechnic School of Jaén · University of Jaén (2026).&lt;/em&gt;&lt;/p&gt;</content:encoded><category>category:Projects</category><category>tag:Bachelor&apos;s Thesis</category><category>tag:Artificial Intelligence</category><category>tag:Deep Learning</category><category>tag:React</category><category>tag:TensorFlow.js</category></item><item><title>Plant Flow Optimization (QAP)</title><link>https://carlos-requena.github.io/Web_Personal/en/post/plant-flow-optimization</link><guid isPermaLink="false">en:plant-flow-optimization</guid><description>Implementation and analysis of Greedy, Local Search, Tabu Search, and Multistart algorithms to solve the Quadratic Assignment Problem (QAP) in an assembly line.</description><pubDate>Tue, 24 Feb 2026 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This project addresses the optimization problem of an assembly line for a factory (based on a FORD case study), seeking the optimal distribution of departments to minimize the cost of material flow. Developed by &lt;strong&gt;Carlos Requena Doña&lt;/strong&gt; and &lt;strong&gt;Yessin Mohamed&lt;/strong&gt; as part of Practice 1 of the Metaheuristics course.&lt;/p&gt;
&lt;p&gt;Various optimization techniques are implemented and compared, ranging from constructive heuristics to advanced local search metaheuristics.&lt;/p&gt;
&lt;h2&gt; Problem Definition (QAP)&lt;a href=&quot;#-problem-definition-qap&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The objective is to assign &lt;span&gt;&lt;span&gt;nn&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; departments to &lt;span&gt;&lt;span&gt;nn&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; locations to minimize the quadratic cost function:&lt;/p&gt;
&lt;span&gt;&lt;span&gt;&lt;span&gt;C(S)=∑i,j=1n∑k,p=1nfij⋅dkp⋅xij⋅xkpC(S) = \sum_{i,j=1}^{n} \sum_{k,p=1}^{n} f_{ij} \cdot d_{kp} \cdot x_{ij} \cdot x_{kp} &lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;C&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;S&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;j&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;p&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;∑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;f&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;ij&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;⋅&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;d&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;⋅&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;x&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;ij&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;⋅&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;x&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;Where the goal is to minimize the product of flow (&lt;span&gt;&lt;span&gt;ff&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;f&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;) of materials between departments by the distance (&lt;span&gt;&lt;span&gt;dd&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;d&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;) between assigned locations.&lt;/p&gt;
&lt;h2&gt; Implemented Algorithms&lt;a href=&quot;#-implemented-algorithms&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;1. Greedy Algorithm&lt;a href=&quot;#1-greedy-algorithm&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A constructive heuristic that generates a quick initial solution.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Uses priority queues (Heaps) to sort flows (highest to lowest) and distances (lowest to highest).&lt;/li&gt;
&lt;li&gt;Iteratively assigns departments with the highest flow to the closest available locations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2. Local Search First-Improvement&lt;a href=&quot;#2-local-search-first-improvement&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Improves the initial solution by exploring the neighborhood through permutations (swap) of two departments.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Strategy&lt;/strong&gt;: Accepts the first neighboring solution that improves the current cost.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DLB (Don’t Look Better)&lt;/strong&gt;: Implementation of a bit vector to optimize the search, marking those departments that have not generated improvements recently to avoid useless re-evaluations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;3. Tabu Search&lt;a href=&quot;#3-tabu-search&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An advanced metaheuristic that allows escaping local optima by accepting movements that worsen the solution, guided by short and long-term memories.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Short-Term Memory&lt;/strong&gt;: Tabu List prohibiting reversing recent moves or repeating visited solutions during a “tabu tenure”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Long-Term Memory&lt;/strong&gt;: Frequency of department assignment to locations to guide diversification/intensification.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Strategic Oscillation&lt;/strong&gt;: Alternates between &lt;strong&gt;intensification&lt;/strong&gt; (exploiting promising zones) and &lt;strong&gt;diversification&lt;/strong&gt; (exploring new zones) phases based on frequency memory.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4. Multistart (GRASP)&lt;a href=&quot;#4-multistart-grasp&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Combines randomized construction with local search to explore multiple regions of the solution space.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Constructive Phase&lt;/strong&gt;: A Randomized Greedy (GRASP) that does not always choose the best option, but one of the best ‘n’ options randomly (RCL - Restricted Candidate List).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Improvement Phase&lt;/strong&gt;: Applies Tabu Search to each generated solution, keeping the best global solution found after multiple executions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;️ Architecture and Design&lt;a href=&quot;#️-architecture-and-design&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;FileLoader (Singleton)&lt;/strong&gt;: Loading flow and distance matrices from files, allowing problem instances to be changed without recompiling.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Representation&lt;/strong&gt;: Integer vector &lt;code&gt;v&lt;/code&gt; where &lt;code&gt;v[i]&lt;/code&gt; is the location of department &lt;code&gt;i&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logging&lt;/strong&gt;: Detailed logging system to analyze the convergence and behavior of algorithms in each iteration.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Combinatorial optimization project implemented in C++.&lt;/em&gt;&lt;/p&gt;</content:encoded><category>category:Projects</category><category>tag:C++</category><category>tag:Metaheuristics</category><category>tag:Optimization</category></item><item><title>Evolutionary Optimization for TSP</title><link>https://carlos-requena.github.io/Web_Personal/en/post/tsp-evolutionary-optimization</link><guid isPermaLink="false">en:tsp-evolutionary-optimization</guid><description>Implementation and analysis of Genetic and Differential Evolution algorithms for the Traveling Salesperson Problem (TSP), comparing OX2 and MOC crossover operators.</description><pubDate>Tue, 24 Feb 2026 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This project documents the implementation and experimental analysis of metaheuristic algorithms to solve the &lt;strong&gt;Traveling Salesperson Problem (TSP)&lt;/strong&gt;. It was developed by &lt;strong&gt;Carlos Requena Doña&lt;/strong&gt; and &lt;strong&gt;Yessin Mohamed&lt;/strong&gt; as part of a university practice.&lt;/p&gt;
&lt;p&gt;The main objective is to compare the performance of &lt;strong&gt;Genetic Algorithms (GA)&lt;/strong&gt; and &lt;strong&gt;Differential Evolution Algorithms (EDA/EDB)&lt;/strong&gt; using different configurations and crossover operators.&lt;/p&gt;
&lt;h2&gt; Algorithms and Problem&lt;a href=&quot;#-algorithms-and-problem&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The problem consists of finding the shortest route that visits a set of cities exactly once and returns to the origin. The distance between points is calculated using the Euclidean distance formula.&lt;/p&gt;
&lt;p&gt;The project implements two main types of algorithms:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Genetic Algorithm (Generational)&lt;/strong&gt;: Simulates natural evolution with a population of individuals (routes).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Differential Evolution Algorithm&lt;/strong&gt;: Uses differential permutation-based mutation operators.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Key Components&lt;a href=&quot;#key-components&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;FileLoader (Singleton)&lt;/strong&gt;: Handles loading city coordinates from files and configuration parameters, avoiding “magic numbers” and allowing easy experimentation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Solution Representation&lt;/strong&gt;: Each individual in the population represents a route (vector of cities).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fitness Function&lt;/strong&gt;: Calculated as the total distance of the route. The goal is to minimize this cost.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Genetic Algorithm (GA)&lt;a href=&quot;#-genetic-algorithm-ga&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Generational Genetic Algorithm follows a classic cycle of selection, crossover, and mutation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Selection&lt;/strong&gt;: Tournament selection is used to choose parents.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Crossover&lt;/strong&gt;: Implemented operators include &lt;strong&gt;OX2&lt;/strong&gt; (Order Crossover 2) and &lt;strong&gt;MOC&lt;/strong&gt; (Maximal Preservative Crossover).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Elitism&lt;/strong&gt;: The best individuals (elites) are preserved for the next generation to ensure the quality of the solution does not decrease.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replacement&lt;/strong&gt;: The new generation completely replaces the old one.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt; Differential Evolution&lt;a href=&quot;#-differential-evolution&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Differential algorithm uses a ternary recombination strategy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It selects a “father”, two random individuals, and a “target” individual.&lt;/li&gt;
&lt;li&gt;It applies differential mutation operators (EDA/EDB) to generate new solutions.&lt;/li&gt;
&lt;li&gt;New individuals replace the old ones only if they improve the fitness (cost).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Experiments and Results&lt;a href=&quot;#-experiments-and-results&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Extensive tests were conducted using 5 different random seeds and multiple parameter configurations (population size, number of elites, probabilities).&lt;/p&gt;
&lt;h3&gt;Comparative Analysis&lt;a href=&quot;#comparative-analysis&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;MOC vs OX2&lt;/strong&gt;: The &lt;strong&gt;MOC&lt;/strong&gt; operator generally showed better results than OX2, especially in early convergence. MOC tends to improve very quickly at the beginning and then stabilizes, while OX2 maintains a more constant improvement improvement rate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;EDA vs EDB&lt;/strong&gt;: The &lt;strong&gt;EDA&lt;/strong&gt; selection strategy proved to be superior to EDB in both mean result and standard deviation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Overall Performance&lt;/strong&gt;: MOC significantly outperformed EDA in the performed tests, achieving better average costs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Conclusions&lt;a href=&quot;#conclusions&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The behavior of the algorithms suggests that &lt;strong&gt;MOC is ideal for scenarios with few iterations&lt;/strong&gt; due to its rapid initial convergence, while &lt;strong&gt;OX2 might be more robust in very long executions&lt;/strong&gt; where constant improvement is required without premature stagnation.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Project developed for the Metaheuristics course.&lt;/em&gt;&lt;/p&gt;</content:encoded><category>category:Projects</category><category>tag:C++</category><category>tag:Metaheuristics</category><category>tag:Optimization</category></item><item><title>Roguelike Chibi</title><link>https://carlos-requena.github.io/Web_Personal/en/post/roguelike-chibi</link><guid isPermaLink="false">en:roguelike-chibi</guid><description>A Roguelike video game developed in Unity featuring Context Steering AI, procedural dungeon generation, Object Pooling system, and Chibi character design.</description><pubDate>Mon, 23 Feb 2026 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Roguelike Chibi is a roguelike video game developed in Unity. The game features procedurally generated dungeons, characters and enemies with a Chibi aesthetic, an AI system based on Context Steering, and a modular architecture focused on object reuse and separation of concerns.&lt;/p&gt;
&lt;h2&gt; Key Features&lt;a href=&quot;#-key-features&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Context Steering AI&lt;/strong&gt;: Artificial intelligence for enemies based on weight vectors and danger/interest maps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Two Enemy Types&lt;/strong&gt;: Minions that chase directly and Warriors that maintain distance and flank the player.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Procedural Generation&lt;/strong&gt;: Dungeons generated from presets based on the chosen character and difficulty.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Object Pool&lt;/strong&gt;: Reuse system for weapon instances to optimize memory usage.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Animation System&lt;/strong&gt;: &lt;code&gt;IAnimatorUsaObjeto&lt;/code&gt; interface managing movement, attack, and item usage animations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Character &amp;amp; Difficulty Selection&lt;/strong&gt;: Available from the main menu before starting the game.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Controller Support&lt;/strong&gt;: Options menu with key remapping and controller support.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;️ Tech Stack&lt;a href=&quot;#️-tech-stack&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Engine&lt;/strong&gt;: Unity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Language&lt;/strong&gt;: C#&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Patterns&lt;/strong&gt;: Singleton, Object Pool, Observer (static events), State Machine (State Enum)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data Design&lt;/strong&gt;: Scriptable Objects for potion buffs and item configurations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI&lt;/strong&gt;: Context Steering (based on specialized game AI literature)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Artificial Intelligence — Context Steering&lt;a href=&quot;#-artificial-intelligence--context-steering&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The AI system is the technical core of the project. Each enemy evaluates an array of possible directions and assigns a weight to each one using the &lt;strong&gt;dot product&lt;/strong&gt; between the candidate direction and the desired direction (usually towards the player).&lt;/p&gt;
&lt;p&gt;Weights are adjusted based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Distance to player&lt;/strong&gt;: Higher weight the closer they are.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Safety distance&lt;/strong&gt;: Warriors penalize directions that bring them too close.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Danger and Interest Maps&lt;/strong&gt;: Mask base weights to avoid collisions and adapt movement to the environment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Enemy Types&lt;a href=&quot;#enemy-types&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;

















&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Behavior&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Minion&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Chases the player directly without advanced Context Steering.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Warrior&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Maintains distance and flanks the player using the full weight vector.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Both types attack when in range and respect a cooldown time between attacks. Enemy weapons are assigned randomly from the &lt;strong&gt;Object Pool&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt; Object Pool&lt;a href=&quot;#-object-pool&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Object Pool is a system for managing pre-created instances. At the start of the game, ~20 weapons are instantiated from a set of prefabs. When an enemy or chest needs a weapon, it retrieves one from the pool without creating new instances at runtime. When an enemy dies, the weapon is returned to the pool for reuse.&lt;/p&gt;
&lt;p&gt;This pattern reduces Garbage Collector impact and stabilizes performance during gameplay.&lt;/p&gt;
&lt;h2&gt; Interactable Elements&lt;a href=&quot;#-interactable-elements&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Interactable elements follow a hierarchy based on interfaces and inheritance:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;IInteractableElement&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;├── Item&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;│   ├── Weapon        ← Collision object vector, self-damage logic&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;│   └── Potion        ← Buff as Scriptable Object&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;├── Door              ← Normal door / Exit door&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;├── Key               ← Opens doors, stored in player&apos;s list&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;└── Container         ← Chests with animation&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Weapons&lt;/strong&gt; autonomously manage their own collision logic: they search for a &lt;code&gt;Hitbox&lt;/code&gt; implementing &lt;code&gt;IDamagable&lt;/code&gt; and apply damage, ensuring it isn’t applied twice to the same target in a single attack animation.&lt;/p&gt;
&lt;p&gt;Items emit a &lt;strong&gt;golden glow&lt;/strong&gt; when the player aims at them, providing immediate visual feedback.&lt;/p&gt;
&lt;h2&gt; User Interface (UI)&lt;a href=&quot;#-user-interface-ui&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;Player Health&lt;a href=&quot;#player-health&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Represented by &lt;strong&gt;five red hearts&lt;/strong&gt;, each equivalent to 20% of total health. Hearts turn black proportionally as health is lost.&lt;/p&gt;
&lt;h3&gt;Pause Menu&lt;a href=&quot;#pause-menu&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Accessible anytime during gameplay, with three options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Resume Game&lt;/li&gt;
&lt;li&gt;Options (Volume + Key remapping for keyboard and controller)&lt;/li&gt;
&lt;li&gt;Exit to Main Menu&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Main Menu&lt;a href=&quot;#main-menu&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Start screen with direct access to &lt;strong&gt;Character Selection&lt;/strong&gt;, where the user can navigate between characters and choose difficulty before starting.&lt;/p&gt;
&lt;h2&gt;⚙️ Unity Architecture&lt;a href=&quot;#️-unity-architecture&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The project is organized into three main scenes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Main Menu&lt;/strong&gt;: Characters with animations, UI management, music, and clearing of static events between scenes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loading Screen&lt;/strong&gt;: Callback ensuring loading is complete before showing the new scene.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Game Scene&lt;/strong&gt;: Contains all game managers.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Main Managers&lt;a href=&quot;#main-managers&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;

































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Manager&lt;/th&gt;&lt;th&gt;Responsibility&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;GameInput&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Captures input and notifies movement, attack, and interaction via events.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;GameManager&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Singleton controlling game state (Playing / Paused / Victory / GameOver) and score.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;SoundManager&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Subscribes to events from other classes and plays centralized sound effects.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;MusicManager&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Plays background music and exposes volume control.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;DungeonCreator&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Selects dungeon preset based on chosen character and difficulty.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;DamageFeedbackManager&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Changes player and enemy materials upon taking damage for visual feedback.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;State Management&lt;a href=&quot;#state-management&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Game state is managed as an &lt;strong&gt;ENUM&lt;/strong&gt; with values &lt;code&gt;Playing&lt;/code&gt;, &lt;code&gt;Paused&lt;/code&gt;, &lt;code&gt;Victory&lt;/code&gt;, and &lt;code&gt;GameOver&lt;/code&gt;. Thanks to the Singleton pattern in &lt;code&gt;GameManager&lt;/code&gt;, any game object can query or react to the current state easily.&lt;/p&gt;
&lt;h2&gt; Highlighted Code Snippet&lt;a href=&quot;#-highlighted-code-snippet&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;// Direction selection via Context Steering&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;float&lt;/span&gt;&lt;span&gt; bestWeight&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; float&lt;/span&gt;&lt;span&gt;.MinValue;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;Vector2&lt;/span&gt;&lt;span&gt; bestDirection&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; Vector2.zero;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; 0&lt;/span&gt;&lt;span&gt;; i &lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; directions.Length; i&lt;/span&gt;&lt;span&gt;++&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    // Dot product between candidate direction and direction to player&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    float&lt;/span&gt;&lt;span&gt; weight&lt;/span&gt;&lt;span&gt; =&lt;/span&gt;&lt;span&gt; Vector2.&lt;/span&gt;&lt;span&gt;Dot&lt;/span&gt;&lt;span&gt;(directions[i], toPlayer.normalized);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    // Adjustment by danger map&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    weight &lt;/span&gt;&lt;span&gt;-=&lt;/span&gt;&lt;span&gt; dangerMap[i];&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    // Adjustment by interest map&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    weight &lt;/span&gt;&lt;span&gt;+=&lt;/span&gt;&lt;span&gt; interestMap[i];&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (weight &lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; bestWeight)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        bestWeight &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; weight;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        bestDirection &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; directions[i];&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt; Key Learnings&lt;a href=&quot;#-key-learnings&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This project allowed me to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement &lt;strong&gt;Context Steering&lt;/strong&gt;, an AI technique from specialized video game literature.&lt;/li&gt;
&lt;li&gt;Apply the &lt;strong&gt;Object Pool&lt;/strong&gt; pattern to optimize real-time memory management.&lt;/li&gt;
&lt;li&gt;Design a clean class hierarchy with &lt;strong&gt;interfaces&lt;/strong&gt; and &lt;strong&gt;inheritance&lt;/strong&gt; in C#.&lt;/li&gt;
&lt;li&gt;Manage global game state with &lt;strong&gt;Singletons&lt;/strong&gt; and state machines.&lt;/li&gt;
&lt;li&gt;Centralize cross-cutting logic (sound, feedback, scoring) in independent managers.&lt;/li&gt;
&lt;li&gt;Work with Unity &lt;strong&gt;Scriptable Objects&lt;/strong&gt; for reusable item data.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><category>category:Projects</category><category>tag:Unity</category><category>tag:C#</category><category>tag:Game Development</category><category>tag:Artificial Intelligence</category></item><item><title>3D Viewer — OpenGL Rendering Engine</title><link>https://carlos-requena.github.io/Web_Personal/en/post/3d-viewer</link><guid isPermaLink="false">en:3d-viewer</guid><description>3D rendering engine built from scratch in C++ with OpenGL. Features Assimp model loading, Phong lighting, normal mapping, textures, and an interactive ImGUI interface.</description><pubDate>Mon, 23 Feb 2026 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A 3D rendering engine built from scratch in C++ using OpenGL. It allows loading models in multiple formats via Assimp, applying different types of lighting and materials, rendering with normal mapping, and controlling a free camera interactively. The entire scene configuration is managed in real-time through an ImGUI interface.&lt;/p&gt;
&lt;h2&gt; Video Demo&lt;a href=&quot;#-video-demo&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://drive.google.com/file/d/1ln3UuS0lW_OjWofK6olYhcgwOLc5uuBI/view?usp=share_link&quot;&gt;Watch demonstration on Google Drive&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt; Key Features&lt;a href=&quot;#-key-features&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model Loading&lt;/strong&gt;: Supports multiple formats via the Assimp library&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Phong Lighting&lt;/strong&gt;: Configurable point and directional lights&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normal Mapping&lt;/strong&gt;: Surface detail without additional geometry&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rendering Modes&lt;/strong&gt;: Fill, wireframe, and fill with normal mapping&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Texture/Material Rendering&lt;/strong&gt;: Selectable in real-time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interactive Interface&lt;/strong&gt;: Dropdown menus powered by ImGUI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free Camera&lt;/strong&gt;: WASD movement + mouse look, panning, and pitch control&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;️ Tech Stack&lt;a href=&quot;#️-tech-stack&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;C++&lt;/strong&gt;: Main language&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OpenGL&lt;/strong&gt;: Graphics API&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GLFW&lt;/strong&gt;: Window and input management&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GLM&lt;/strong&gt;: Vector and matrix mathematics&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assimp&lt;/strong&gt;: 3D model loading and import&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ImGUI&lt;/strong&gt;: Interactive user interface&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GLSL&lt;/strong&gt;: Vertex and fragment shaders&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;️ Architecture&lt;a href=&quot;#️-architecture&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The design follows an object-oriented scheme with well-defined responsibilities. The class diagram summarizes the main relationships:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;Renderer  ◆── ShaderHandler   (Composition: Renderer creates and owns ShaderHandler)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;Renderer  ◆── Camera&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;Renderer  ──▶ Light (N lights in vector)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;Renderer  ──▶ ModelManager&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;ModelManager  ◆── Model [1..N]&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;Model         ◆── ModelMesh [1..N]&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;FileLoader  · · ▶  Renderer   (Usage for file loading)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;figure&gt;&lt;img src=&quot;/Web_Personal/img/projects/1.webp&quot; alt=&quot;Class Relations&quot; loading=&quot;lazy&quot; /&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Renderer&lt;a href=&quot;#renderer&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The core class of the system. It manages the rendering cycle, shaders, camera, models, and lights. It is a Singleton (&lt;code&gt;GetInstancia()&lt;/code&gt;), allowing access from anywhere in the application (including ImGUI and input callbacks).&lt;/p&gt;
&lt;h3&gt;ShaderHandler&lt;a href=&quot;#shaderhandler&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Internal composition of &lt;code&gt;Renderer&lt;/code&gt;. Responsible for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compiling and linking GLSL programs (&lt;code&gt;createShaderProgram&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Initializing and managing VAOs/VBOs (&lt;code&gt;InicializacionArraysShaders&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Checking shader compilation errors (&lt;code&gt;comprobarCompilacion&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Managing fragment subroutines to switch between rendering modes&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Camera&lt;a href=&quot;#camera&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Stores view and projection matrices (&lt;code&gt;glm::mat4&lt;/code&gt;) and exposes methods for each type of movement: translation (&lt;code&gt;movimientoArriba&lt;/code&gt;, &lt;code&gt;movimientoDerecha&lt;/code&gt;), panning (&lt;code&gt;panoramica&lt;/code&gt;), and pitch (&lt;code&gt;cabeceo&lt;/code&gt;). Processes mouse and keyboard input via &lt;code&gt;procesarMovimiento&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;ModelManager → Model → ModelMesh&lt;a href=&quot;#modelmanager--model--modelmesh&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Three-level composition hierarchy:&lt;/p&gt;





















&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Class&lt;/th&gt;&lt;th&gt;Responsibility&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;ModelManager&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Maintains a vector of pointers to &lt;code&gt;Model&lt;/code&gt;, assigns texture IDs, and delegates rendering&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Loads the model via Assimp, stores meshes, model matrix, texture, and shader ID&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;ModelMesh&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Contains GPU data: VAO, VBO, EBO, and vertices/indices for each mesh&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;Light&lt;a href=&quot;#light&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Represents a light source in the scene. The type is differentiated by the &lt;code&gt;TipoLuz&lt;/code&gt; enum, and each type has its own constructor. Stores position, direction, ambient/diffuse/specular components, and enabled status.&lt;/p&gt;
&lt;h2&gt; ImGUI Interface&lt;a href=&quot;#-imgui-interface&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The interface is built in &lt;code&gt;main&lt;/code&gt; with dropdown menus that allow scene manipulation without touching code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;SetNextWindowSize&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;ImVec2&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;300&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;140&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;Begin&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Main Menu&quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;, ImGuiWindowFlags_NoCollapse)) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;BeginMenu&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Add&quot;&lt;/span&gt;&lt;span&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Add Point Light&quot;&lt;/span&gt;&lt;span&gt;))       popupPointLightOpen &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Add Directional Light&quot;&lt;/span&gt;&lt;span&gt;)) popupDirLightOpen &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Add Model&quot;&lt;/span&gt;&lt;span&gt;))             popupAddModel &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;EndMenu&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;BeginMenu&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Change Model Color&quot;&lt;/span&gt;&lt;span&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Texture&quot;&lt;/span&gt;&lt;span&gt;))   &lt;/span&gt;&lt;span&gt;Renderer&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GetInstancia&lt;/span&gt;&lt;span&gt;()-&amp;gt;&lt;/span&gt;&lt;span&gt;setTextureColorCalculation&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Material&quot;&lt;/span&gt;&lt;span&gt;))  &lt;/span&gt;&lt;span&gt;Renderer&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GetInstancia&lt;/span&gt;&lt;span&gt;()-&amp;gt;&lt;/span&gt;&lt;span&gt;setMaterialColorCalculation&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;EndMenu&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;BeginMenu&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Change Visualization Mode&quot;&lt;/span&gt;&lt;span&gt;)) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Wireframe&quot;&lt;/span&gt;&lt;span&gt;))                  &lt;/span&gt;&lt;span&gt;Renderer&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GetInstancia&lt;/span&gt;&lt;span&gt;()-&amp;gt;&lt;/span&gt;&lt;span&gt;setRenderModeWireframe&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Fill&quot;&lt;/span&gt;&lt;span&gt;))                       &lt;/span&gt;&lt;span&gt;Renderer&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GetInstancia&lt;/span&gt;&lt;span&gt;()-&amp;gt;&lt;/span&gt;&lt;span&gt;setRenderModeFill&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;MenuItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Fill with Normal Mapping&quot;&lt;/span&gt;&lt;span&gt;))   &lt;/span&gt;&lt;span&gt;Renderer&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GetInstancia&lt;/span&gt;&lt;span&gt;()-&amp;gt;&lt;/span&gt;&lt;span&gt;setRenderModeFillNormalMap&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        ImGui&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;EndMenu&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Popup actions for adding lights or models propagate data directly to &lt;code&gt;Renderer&lt;/code&gt; via its Singleton instance.&lt;/p&gt;
&lt;h2&gt; Normal Mapping&lt;a href=&quot;#-normal-mapping&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Normal mapping is implemented at the shader level by transforming normals to tangent space. Changes affect:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Model Loader (Assimp)&lt;/strong&gt;: Retrieving tangential attributes alongside vertices, normals, and UVs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Renderer::dibujoModeloMalla&lt;/code&gt;&lt;/strong&gt;: Passing tangent variables to the vertex shader.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GLSL Shaders&lt;/strong&gt;: Calculating lighting in tangent space using the normal map texture.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The system checks in &lt;code&gt;ModelManager::creaModelo&lt;/code&gt; that the normal map path is not empty before loading it, as the diffuse texture and normal map are independent:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; PAG&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;GestorModelos&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;creaModelo&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; char*&lt;/span&gt;&lt;span&gt; path&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;glm&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;mat4&lt;/span&gt;&lt;span&gt; modelMatrix&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    std&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;string&lt;/span&gt;&lt;span&gt; texturePath&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;std&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;string&lt;/span&gt;&lt;span&gt; normalPath&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;float&lt;/span&gt;&lt;span&gt; brightness&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    glm&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;vec3&lt;/span&gt;&lt;span&gt; ambientColor&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;glm&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;vec3&lt;/span&gt;&lt;span&gt; diffuseComponent&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;glm&lt;/span&gt;&lt;span&gt;::&lt;/span&gt;&lt;span&gt;vec3&lt;/span&gt;&lt;span&gt; specularExponent&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    Modelos&lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt; model &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; new&lt;/span&gt;&lt;span&gt; Modelos&lt;/span&gt;&lt;span&gt;(path, modelMatrix, brightness,&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;                                  ambientColor, diffuseComponent, specularExponent);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;!&lt;/span&gt;&lt;span&gt;texturePath.&lt;/span&gt;&lt;span&gt;empty&lt;/span&gt;&lt;span&gt;()) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        model-&amp;gt;&lt;/span&gt;&lt;span&gt;setIdTextura&lt;/span&gt;&lt;span&gt;(idTexturaModelos &lt;/span&gt;&lt;span&gt;==&lt;/span&gt;&lt;span&gt; 1&lt;/span&gt;&lt;span&gt; ?&lt;/span&gt;&lt;span&gt; 2&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; idTexturaModelos);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        cargarTextura&lt;/span&gt;&lt;span&gt;(texturePath);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;!&lt;/span&gt;&lt;span&gt;normalPath.&lt;/span&gt;&lt;span&gt;empty&lt;/span&gt;&lt;span&gt;()) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        model-&amp;gt;&lt;/span&gt;&lt;span&gt;setIdTexturaNormal&lt;/span&gt;&lt;span&gt;(idTexturaModelos);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        cargarTextura&lt;/span&gt;&lt;span&gt;(normalPath);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    modelosEscena.&lt;/span&gt;&lt;span&gt;push_back&lt;/span&gt;&lt;span&gt;(model);&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;⌨️ Controls&lt;a href=&quot;#️-controls&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;













































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Key / Action&lt;/th&gt;&lt;th&gt;Effect&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;W&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Move Up&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;S&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Move Down&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;A&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Move Right&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;D&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Move Left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Left Click + Mouse&lt;/td&gt;&lt;td&gt;Free Camera Rotation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;P&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Pan Left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;O&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Pan Right&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Pitch Left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;X&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Pitch Right&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;blockquote&gt;
&lt;p&gt;Movement keys only respond while the left mouse button is held down, preventing accidental movement when typing in ImGUI popups.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt; Repository&lt;a href=&quot;#-repository&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href=&quot;https://github.com/Carlos-Requena/3D_Viewer&quot;&gt;Carlos-Requena/3D_Viewer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Main (ImGUI + input)&lt;/strong&gt;: &lt;a href=&quot;https://github.com/Carlos-Requena/3D_Viewer/blob/master/program/main.cpp&quot;&gt;&lt;code&gt;program/main.cpp&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Renderer (normal mapping, L180)&lt;/strong&gt;: &lt;a href=&quot;https://github.com/Carlos-Requena/3D_Viewer/blob/master/program/Renderer.cpp&quot;&gt;&lt;code&gt;program/Renderer.cpp&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Key Learnings&lt;a href=&quot;#-key-learnings&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This project allowed me to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the complete OpenGL graphics pipeline (VAO/VBO/EBO, shader compilation, draw calls).&lt;/li&gt;
&lt;li&gt;Implement a Phong lighting system with multi-light support in GLSL.&lt;/li&gt;
&lt;li&gt;Apply &lt;strong&gt;normal mapping&lt;/strong&gt; in tangent space from scratch.&lt;/li&gt;
&lt;li&gt;Integrate &lt;strong&gt;ImGUI&lt;/strong&gt; to build interactive interfaces over OpenGL without additional frameworks.&lt;/li&gt;
&lt;li&gt;Design an object-oriented architecture with composition and Singleton patterns in C++.&lt;/li&gt;
&lt;li&gt;Manage GPU resources (textures, buffers) with IDs and a simplified Object Pool system.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><category>category:Projects</category><category>tag:C++</category><category>tag:OpenGL</category><category>tag:3D Graphics</category></item><item><title>The Speedrunner</title><link>https://carlos-requena.github.io/Web_Personal/en/post/the-speedrunner</link><guid isPermaLink="false">en:the-speedrunner</guid><description>A speedrun-type video game developed in Unity where the goal is to complete levels as quickly as possible with advanced movement mechanics.</description><pubDate>Mon, 13 May 2024 22:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;strong&gt;The Speedrunner&lt;/strong&gt; is a first-person platform game developed in Unity, focused on speed and precision. The main objective is to complete levels in the shortest possible time, beating personal records and competing against other players.&lt;/p&gt;
&lt;p&gt;This project was developed in collaboration by &lt;strong&gt;Carlos Requena Doña&lt;/strong&gt; and &lt;strong&gt;Yessin Mohamed&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt; Concept and Gameplay&lt;a href=&quot;#-concept-and-gameplay&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The game draws inspiration from titles like &lt;em&gt;“Warstride Challenges”&lt;/em&gt;, aiming for a fluid and frantic experience. The player controls “The Bean”, a character designed to move at high speeds through three-dimensional environments.&lt;/p&gt;
&lt;h3&gt;Key Features&lt;a href=&quot;#key-features&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Advanced Movement System&lt;/strong&gt;: Based on kinematic physics for a feeling of total fluidity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integrated Combat Mechanics&lt;/strong&gt;: Shooting targets and enemies is a fundamental part of advancing through levels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scoring System&lt;/strong&gt;: Time-based, encouraging replayability and route optimization (“Speedrunning”).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Progressive Difficulty&lt;/strong&gt;: Levels designed to challenge player skills.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;‍♂️ Movement Mechanics&lt;a href=&quot;#️-movement-mechanics&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The core of the game lies in its movement system, which allows chaining actions to maintain and increase speed:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Wall Run&lt;/strong&gt;: Allows running along walls to reach inaccessible areas. Jumping off a wall provides an extra boost.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Double Jump&lt;/strong&gt;: Ability to perform a second jump in mid-air to correct trajectories or reach greater heights.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dash&lt;/strong&gt;: A quick forward burst that drastically increases speed momentarily (with a 2-second cooldown).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shooting&lt;/strong&gt;: Essential mechanic to open doors or activate mechanisms by shooting specific targets.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt; Level Design&lt;a href=&quot;#-level-design&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The game features level structures designed for route optimization. Although the map is static, replayability comes from finding the perfect sequence of movements.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Level 1&lt;/strong&gt;: Introduces basic mechanics and blocked doors requiring precise shooting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Level 2&lt;/strong&gt;: Increases complexity with alternative paths unlockable via targets, allowing shortcuts to reduce final time.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;️ Technical Architecture&lt;a href=&quot;#️-technical-architecture&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The project was built in Unity using a modular architecture:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Kinematic Character Controller&lt;/strong&gt;: Custom physics implementation for precise movement control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Input System&lt;/strong&gt;: Centralized player input management to support key remapping.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Game Manager (Singleton)&lt;/strong&gt;: Controls global game state (Playing, Paused, Victory, Game Over) and scoring system.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data Persistence&lt;/strong&gt;: JSON save system to store records and level unlock progress.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audio System&lt;/strong&gt;: Event management for sound effects and dynamic music.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt; Resources and Credits&lt;a href=&quot;#-resources-and-credits&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Development leveraged assets from &lt;strong&gt;Synty Studios (Polygon)&lt;/strong&gt; for low-poly visuals, along with other packages for particle effects and skyboxes, allowing the team to focus on mechanics programming and unique level design.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Project developed as part of a video game development portfolio.&lt;/em&gt;&lt;/p&gt;</content:encoded><category>category:Projects</category><category>tag:Unity</category><category>tag:C#</category><category>tag:Game Development</category></item></channel></rss>