jstar88 / opbe

Ogame probabilistic battle engine
GNU Affero General Public License v3.0
76 stars 29 forks source link

Bug with big number of civil ships #42

Open koraykarakus opened 2 years ago

koraykarakus commented 2 years ago

There is problem with big number of small cargo, heavy cargo, and recycler, attacker : small cargo : 7,000,000 battlecruiser : 40,000

defender: small cargo : 2,700,000 battlecruiser : 15,000

after battle

attacker : small cargo : 6440792 battlecruiser : 39857

defender: small cargo : 2,700,000 battlecruiser : 15,000

result : The battle ended in a draw The attacker has lost a total of 2 246 842 000 units. The defender has lost a total of 0 units.

problem : attacker has bigger number of ships, more battlecruisers but he cannot drop even 1 ship of defender.

test code used : <?php require ("../../RunnableTest.php"); class MyTest extends RunnableTest { public function getAttachers() { $fleet = new Fleet(1,array( $this->getShipType(202, 7000000), $this->getShipType(215, 40000))); $player = new Player(1, array($fleet)); return new PlayerGroup(array($player)); } public function getDefenders() { $fleet = new Fleet(2,array( $this->getShipType(202, 2700000), $this->getShipType(215, 15000))); $player = new Player(2, array($fleet)); return new PlayerGroup(array($player)); } } new MyTest(); ?>

noonn commented 1 year ago

I have the same problem. If you know how to solve it, please tell me.

noonn commented 1 year ago

I checked again. It seems that the problem occurs regardless of the number of ships in battle. It looks like you need a quick fix. I need help from someone who can solve it.

noonn commented 1 year ago

Please try a test.

combatObject/ShipsCleaner.php

============== find line if (USE_BIEXPLOSION_SYSTEM && $this->lastShipHit >= $this->fighters->getCount() / PROB_TO_REAL_MAGIC) { log_comment('lastShipHit bigger than getCount()/magic'); if ($prob < MIN_PROB_TO_EXPLODE) { $probToExplode = 0; } else { $probToExplode = $prob; } } //otherwise statistically: else { log_comment('lastShipHit smaller than getCount()/magic'); $probToExplode = $prob * (1 - MIN_PROB_TO_EXPLODE); }

Modify as below

if ($prob < MIN_PROB_TO_EXPLODE) { log_comment('lastShipHit smaller than getCount()/magic'); $probToExplode = $prob * (1 - MIN_PROB_TO_EXPLODE); } else { log_comment('lastShipHit smaller than getCount()/magic'); $probToExplode = $prob; }

==================

Please let me know if you have better code.