[DEV] 2Moons/SmartMoons 3.0 - Next Gen Update (PHP 8.4, Twig Engine & Aerospace Design)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Hey, thanks for sharing this.

      From what I can see so far, this part looks more like the 2Moons ↔ OPBE integration layer (wrapping attackers/defenders into PlayerGroup/Fleet/Ship and building the BattleReport), not yet the actual scaling logic itself.

      I don’t see any downscaling of ship counts before the Battle() call or any rescaling of the results afterwards. So I assume the real scaler implementation is located somewhere else in your repo.

      I’ll go through your repository to understand where and how the actual calculation/scaling is done, especially how you:
      - normalize large fleet sizes
      - run the reduced battle simulation
      - and scale the results back (losses, debris, survivors, etc.)

      Really curious to see how you handled mixed fleets and edge cases.

      Thanks again for sharing, I’ll take a deeper look
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • it starts inside calculateAttack,

      in function simplifyBattle

      this part

      $divider = 2;
      $simp = simplifyBattle($attackers, $defenders, $divider);
      $attackers = $simp[0]; // divided value
      //file_put_contents('test.txt', print_r($attackers, true), FILE_APPEND);
      $defenders = $simp[1]; // divided value

      if you cloned the project, it is not inside master branch you need to write
      git branch - to see branches
      than switch branch git checkout battle_engine_scaler

      The post was edited 1 time, last by amamoslavida_ ().

    • SmartMoons / 2MoonsCE — Combat Engine v3.2

      Hallo zusammen

      ich habe in den letzten Wochen die komplette Battle Engine von Grund auf überarbeitet, analysiert und stabilisiert.

      Dabei wurde nicht nur ein einzelner Bug gefixt, sondern die komplette Pipeline neu gedacht:

      • Flottenstart → Kampfsimulation → Schaden → Verluste
      • Trümmerfeld → Mondchance
      • Kampfbericht → Nachrichtensystem
      • Spionageberichte
      • Bots / NPC Angriffe
      • Hooks & Events



      Alles wurde geprüft, neu strukturiert und auf PHP 8.3 / 8.4 optimiert.

      Wichtig:
      Alle Änderungen sind vollständig abwärtskompatibel.
      Bestehende Hooks, Bots, ACS-Systeme und Plugins funktionieren weiterhin ohne Anpassungen.

      ---

      ️ Wichtige Fixes

      • Debris Bug gefixt — Trümmerfeld war teilweise immer 0
      • BattleReport Crashes behoben — keine "Unknown Player" / [0:0:0] mehr
      • Rundenabbruch korrigiert — letzte Runde wird korrekt berechnet
      • Morale System Fix — Schaden wird jetzt korrekt verteilt
      • Defence Rebuild Bug — keine falschen Verluste mehr
      • RapidFire Anzeige korrigiert
      • Empty Fleet Crashes gefixt
      • Spy Reports funktionieren wieder zuverlässig (nie mehr leer)
      • MIP Berechnung stabilisiert
      • Deterministische Kämpfe (kein Random HP Chaos mehr)
      ---

      ⚡ Performance Verbesserungen
      • Kein unnötiges unserialize() mehr im Kampfsystem
      • Deutlich weniger Memory-Verbrauch bei Round-Daten (bis zu 30x weniger)
      • Tech-Werte werden nur einmal berechnet
      • Formation & Synergy werden nur einmal berechnet
      • Early Exit bei sofortigem Kampfende



      Wichtig:
      Die Performance hängt jetzt nicht mehr von der Anzahl der Schiffe ab, sondern nur noch von:
      • Schiffstypen
      • Flottenanzahl
      • Runden



      ---

      Neue Systeme
      • Tactical Formations (Offensiv / Defensiv / Flanking / etc.)
      • Critical Hits System
      • Morale System (dynamischer Schadensverlust)
      • Ship-Class Synergies (Flottenboni)
      • Erweiterte Kampfdaten pro Runde
      ---

      ️ Stabilität & Kompatibilität

      • Komplett PHP 8.3 / 8.4 kompatibel
      • Keine undefined index / notices mehr
      • Bots & NPC Kämpfe funktionieren weiterhin
      • Hooks bleiben unverändert
      • Return-Format bleibt gleich (keine Breaking Changes)



      ---

      Dateien

      Folgende Dateien wurden überarbeitet:

      • calculateAttack.php
      • CombatFramework.class.php
      • GenerateReport.php
      • MissionCaseAttack_class.php
      • MissionCaseDestruction_class.php
      • MissionCaseSpy_class.php
      • calculateMIPAttack.php



      ---

      Hinweis

      Ich habe:

      • ✔ alle Änderungen bereits im Repository aktualisiert
      • ✔ zusätzlich alle relevanten Dateien als ZIP zum Testen gepackt
      • ✔ die ZIP hier im Forum hochgeladen



      Ihr könnt also direkt testen, ohne selbst alles zusammensuchen zu müssen.

      ---

      Full Changelog

      Den kompletten technischen Changelog findet ihr hier:

      Findet ihr demnächst auf GitHub.
      ---

      Feedback

      Ich freue mich über Feedback, Tests und vor allem:
      • Edge Cases
      • Große Kämpfe (extreme Fleet Sizes)
      • Bot-Verhalten



      Wenn jemand noch weitere Ideen für die Battle Engine hat gerne her damit

      ---

      SmartMoons / 2MoonsCE
      © 2025–2026 Florian Engelhardt (0wum0)
      Files
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • amamoslavida_ wrote:

      it starts inside calculateAttack,

      in function simplifyBattle

      this part

      $divider = 2;
      $simp = simplifyBattle($attackers, $defenders, $divider);
      $attackers = $simp[0]; // divided value
      //file_put_contents('test.txt', print_r($attackers, true), FILE_APPEND);
      $defenders = $simp[1]; // divided value

      if you cloned the project, it is not inside master branch you need to write
      git branch - to see branches
      than switch branch git checkout battle_engine_scaler
      Here you can test it
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Hello i fetch your github repo and updated, made some tests with battle engine.

      500 LF vs 500 LF nothing entered techs
      # battle 1 - attacker : 264 - defender : 261
      # battle 2 - attacker : 112 - defender : 355
      # battle 3 - attacker : 276 - defender : 273

      500 Rip vs 500 Rip ( same technique, nothing entered )
      #battle 1 - attacker : 179 defender : 196
      #battle 2 - attacker : 125 defender : 182
      #battle 3 - attacker : 166 defender : 186

      battle derives too much if you are unlucky player you lose more fleet. Equal number of ships entered to the battle so player loses' should also be equal with same level of technology.

      +button reset ships add 5000 Light cargo on attacker.
    • results from opbe

      500 LF vs 500 LF
      #1 A : 337 D : 337
      #2 A : 337 D : 336
      #3 A : 337 D : 337

      500 RIP vs 500 RIP
      #1 A : 323 D : 0
      #2 A : 323 D : 0
      #3 A : 322 D : 0
      ( interesting OPBE bug for attacking with deathstars, whoever attack first win ? )

      OGAME
      500 RIP vs 500 RIP
      #1 A : 46 D : 42
      #2 A : 44 D : 46
      #3 A : 49 D : 40

      result : ogame working best, OPBE is really good and precise but it has bug with Deathstar ( maybe rapid fire issue ), your one is good compared to OPBE Death stars, but it is not precise.

      + OPBE will fail on big ships if you dont use scaler.
    • Thanks for the detailed analysis! We've done a full rewrite of the combat engine.
      Regarding the Scaler: Our engine already iterates over ship types, not individual ships. 5,000,000,000 Light Fighters = exactly 1 loop iteration — same as 5. The performance problem OPBE has (iterating individual ships) simply doesn't exist in our engine. A scaler would give us no benefit.
      Regarding battle variance: You're right that our results diverge more than OGame. We identified two causes:
      1. ±20% random attack variance per ship type per round (OGame uses ±15%)
      2. 5% Critical Hit chance (2× damage) — a single lucky crit on 500 RIPs vs 500 RIPs can swing the entire battle
      3. Morale system — if one side falls behind, it loses up to 40% attack power per round, amplifying small early imbalances
      All three are now configurable per universe in the Admin Panel under "Combat Engine Settings":
      • Attack Variance % (0 = fully deterministic, 15 = OGame-like, default 20)
      • Critical Hit Chance % (0 = disabled)
      • Critical Hit Multiplier (default 2×)
      • Morale System on/off toggle
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Update: Combat Engine Improvements & New Admin Controls
      Hey, thanks again for the detailed feedback — we took it seriously and did a full review of the combat engine.



      Regarding the Scaler suggestion:
      Our engine (v3.2) already works fundamentally differently from OPBE. All combat loops iterate over ship types, not individual ships. This means 5,000,000,000 Light Fighters = exactly 1 loop iteration — identical to 5 ships. The O(n) individual-ship problem that OPBE has simply does not exist in our implementation, so a scaler would provide no benefit here.



      Regarding battle variance & the RIP vs RIP asymmetry:
      You were right that our results diverge more than OGame. We identified three causes:
      1. ±20% random attack variance per ship type per round (OGame uses ±15%)
      2. 5% Critical Hit chance per ship type, dealing 2× damage — a single lucky crit on a large fleet like 500 RIPs can swing the entire battle outcome
      3. Morale system — when one side falls behind in total fleet weight, it loses up to 40% attack power cumulatively over rounds, amplifying small early imbalances significantly
      None of these are calculation bugs — they are intentional design features — but together they produce noticeably higher variance than vanilla OGame, especially in symmetric same-type matchups like RIP vs RIP.



      What we changed:
      All three parameters are now fully configurable per universe directly in the Admin Panel under Universe Config → Combat Engine Settings:
      SettingDefaultRange
      Attack Variance20%0–50%
      Critical Hit Chance0–100%0 = disabled
      Critical Hit Multiplier1×–10×
      Morale SystemEnabledon/off toggle

      To get OGame-like symmetric results: set Variance to 15%, Crit Chance to 0%, Morale off.
      Server admins can now tune the combat feel per universe without any code changes.



      Thanks for helping us make the engine better. If you find further discrepancies, feel free to share battle reports with fleet compositions and we'll investigate.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • that is good, morale system etc, something new does not harm, i tought you wanted to do same engine with ogame, if you not trying that than it is pretty ok, nice job. best engine is unvarying engine so you can calculate and attack respectively. dont work much people already quit playing those kind of games, you put a lot efforts lately :D
    • [UPDATE] Bot System Overhaul – What Changed & Bug Fixes
      Hey everyone,
      we've done a significant round of fixes and improvements to the bot system. Here's a full summary of what changed:



      Bug Fixes
      • Bots were completely broken — The bot_personalities database table was missing, causing BotPersonality::load() to throw an uncaught exception on every bot tick. This silently killed the entire cronjob run without any visible error.
      • Class "botActionsCronjob" not found — The cronjob file used a relative require_once path without ROOT_PATH, causing the CronjobTask interface to fail loading when PHP wasn't running from the webroot. The class was never defined as a result.
      • Bots only attacked inactive players — raid_inactive_only was defaulting to 1, meaning bots only targeted players offline for 7+ days. Changed to 0.
      • Bots skipped targets with any defense — A defense structure filter was blocking almost all targets. Removed.
      • Minimum loot thresholds too high — raid_min_gain was set to 50,000 resources by default, filtering out most planets. Changed to 0.



      ✨ New Features
      • Spy missions — Bots now send spy probes (Mission 6, Ship 210) before raiding. Configurable via spy_probes setting per bot type. Enabled automatically when pvp_enabled = 1.
      • Hardcoded personality fallbacks — If the bot_personalities table is missing from the DB, the engine now silently falls back to hardcoded defaults (balanced, farmer, raider, researcher, miner, turtle) instead of crashing.
      • bot_personalities table + migration — Added to migration_15.sql including all 6 default personalities with proper weights for mines, energy, fleet, research, defense priorities.
      • personality column in bots table — Added via migration_15.sql (ALTER TABLE bots ADD COLUMN personality VARCHAR(64) DEFAULT 'balanced').



      ⚙️ How to Enable Bot Raids/Fights
      1. Go to Admin → Bot Manager → Strategien / Typen
      2. Select your bot type
      3. Check: ✅ PVP (Raids) and ✅ Raid
      4. Save



      ️ Required DB Migration
      If you're upgrading from an older version, run
      migration_15.sql via phpMyAdmin or the upgrade page. This creates:
      • bot_personalities table with default entries
      • Adds personality column to bots table
      • Adds combat engine config columns (combat_rand_variance, combat_crit_chance, combat_crit_mult, combat_morale_enabled) to the config table



      Files Changed
      • includes/classes/bot/BotEngine.class.php
      • includes/classes/bot/BotPersonality.class.php
      • includes/classes/cronjob/botActionsCronjob.class.php
      • install/migrations/migration_15.sql



      Found a bug?
      Please report all issues directly on GitHub: github.com/0wum0/2MoonsCE/issues
      Include:
      • A short description of the problem
      • Steps to reproduce
      • Any error messages from bot_actions_cron_debug.txt or cache/cron_debug.log
      • Your PHP version
      Thanks for testing and your feedback!
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • amamoslavida_ wrote:

      that is good, morale system etc, something new does not harm, i tought you wanted to do same engine with ogame, if you not trying that than it is pretty ok, nice job. best engine is unvarying engine so you can calculate and attack respectively. dont work much people already quit playing those kind of games, you put a lot efforts lately :D
      thank you
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Könnt ihr mir Feedback zum Botsystem dann bitte geben, also ob es bei euch läuft?

      Und auch zur Battle Engine?

      Danke

      Und wenn ihr images habt dann immer her damit.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Ahhh ich habe noch Fehler imBot system gefunden. Ich behebe sie dann poste ich das update auf git
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Okay ich habe mal zum Test alle bots auf raid getriggert Einfach mal zum testen.
      Ich habe es jetzt So korrigiert, dass sie Spionagesonden versenden, Lohnt sich der angriff dann greifen sie anhand des spio Berichtes an.
      Bots saven ebenso ihr Flotte bei angriff, Sie können alles bauen und können Allianzen bilden.

      Ihr hattet recht da war einiges kaputt.

      [Release] 2MoonsCE – Bot System Update | Alliance, ACS, Bug Fixes



      Übersicht Wir haben das Bot-System grundlegend erweitert. Bots verhalten sich jetzt deutlich realistischer: Sie gründen echte Allianzen mit natürlichen Namen, führen koordinierte Angriffe durch und alle Parameter sind vollständig über die Datenbank konfigurierbar.



      Bug Fixes
      Out of range value for column 'small_ship_cargo' (und weitere Schiff-Spalten) Das $PLANET-Array wurde einmal pro Tick geladen. Nach dem ersten sendFleet subtrahierte die DB die Schiffe korrekt – das In-Memory-Array zeigte aber noch die alten Werte. Folgende Fleet-Sends im selben Tick versuchten erneut zu subtrahieren → unsigned underflow → MySQL-Fehler. → Fix: Neue Methode
      subtractFleetFromPlanet() aktualisiert das In-Memory-Array nach jedem sendFleet. Betrifft sendExpedition, sendSpy, sendRaid, sendRecycleOnOwnDebris, saveFleet, doAcsRaid.
      EXPEDITION skip: no fleet slots (1/1)
      sendExpedition ignorierte den bot_min_fleet_slots-Override – Bots mit computer_tech = 0 hatten nur 1 Slot und sprangen sofort raus. → Fix: sendExpedition nutzt jetzt max(GetMaxFleetSlots($USER), bot_min_fleet_slots).



      ✨ Neue Features
      Bot-Allianzen
      • Bots gründen oder treten Allianzen automatisch bei
      • Namen sehen aus wie echte Spieler-Gilden (Iron Vanguard, Silent Storm, Nova Corps etc.) – kein BOT_-Prefix mehr
      • Eigene Namen/Tags über alliance_name_pool / alliance_tag_pool als JSON konfigurierbar
      • Bots werden intern via eines unsichtbaren Datenbank-Feldes (ally_events) markiert – niemals im UI sichtbar
      • alliance_max_count = 1 (Standard): Es entsteht nur eine Bot-Allianz pro Server, alle Bots treten dieser bei
      Koordinierte ACS-Raids
      • Bots in derselben Allianz können gemeinsam angreifen (Mission 2)
      • Nur Persönlichkeiten raider und balanced nehmen teil
      • Konfigurierbar: Gruppengröße, Wahrscheinlichkeit pro Tick, Mindest-Ressourcen beim Ziel
      Vollständige Konfigurierbarkeit via bot_setting (Migration 16) Alle neuen Parameter direkt in der DB-Tabelle einstellbar: can_alliance, alliance_max_count, alliance_max_members, alliance_name_pool, alliance_tag_pool, can_acs, acs_max_size, acs_chance_percent, acs_min_loot, can_defense, can_save_fleet, bot_min_fleet_slots, spy_probes, raid_min_loot



      Migration Nach dem Code-Update das Install-Tool aufrufen (/install/index.php?mode=upgrade) – Migration 16 wird automatisch erkannt und fügt alle neuen Spalten hinzu.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • @fossil kannst du mir sagen ob alles klappt?
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Das ist merkwürdig bei mir sind sie dauer aktiv hast du einen log im root? Bot log und botaction log? Und co
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Welche PHP Version verwendest du?
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Okay, I'll see if I can incorporate the language variables.

      What exactly isn't working for you with the bots? For me, they're building, fighting, sending fleets, forming alliances, and creating new ones.


      I'm using the exact same game files.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️