widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05286
Re: [Merge] lp:~widelands-dev/widelands/ai_ship_tweaks into lp:widelands
Some of things you suggest are bit complicated to me :) But of course I will try to rework as much as possible
Advantage of ship_id is that once the names are exhausted name of ship is "Ship X", also once there will be a list of ships, it can be another column in list.
I tried to use serial numbers of bobs - can not be done. Pointers - I have to look at it thoroughly...
Test with 30 ships test what will happen when names are exhausted and if save/load goes well. No assert there, it is true, but I would expect a crash rather then a value not matching. But I can consider adding there some assert.
Another comments in diff
Diff comments:
> === modified file 'src/ai/defaultai.cc'
> --- src/ai/defaultai.cc 2016-01-02 12:36:38 +0000
> +++ src/ai/defaultai.cc 2016-01-02 21:40:20 +0000
> @@ -880,9 +893,13 @@
>
> // same defaults are directly saved to avoid inconsistency
> player_->set_ai_data(colony_scan_area_, kColonyScan);
> + player_->set_ai_data(expedition_start_time_, kExpStartTime);
version of packed is increase for packet player info - it is in diff visible...
> + player_->set_ai_data(ships_utilization_, kShipUtil);
> + player_->set_ai_data(no_more_expeditions_, kNoExpeditions);
> player_->set_ai_data(last_attacked_player_, kLastAttack);
> player_->set_ai_data(least_military_score_, kLeastMilit);
> player_->set_ai_data(target_military_score_, kTargetMilit);
> + player_->set_ai_data(expedition_ship_, kExpShip);
>
> } else {
> log (" %d: restoring saved AI data...\n", player_number());
> @@ -3630,6 +3734,20 @@
> expedition_management(*i);
> action_taken = true;
> }
> +
> + // Checking utilization
> + if (i->ship->get_ship_state() == Widelands::Ship::TRANSPORT) {
> +
> + // Good utilization is 10 pieces of ware onboard, to track utilization we use range 0-10000
> + // to avoid float or rounding errors if integers in range 0-100
> + const int16_t tmp_util = (i->ship->get_nritems() > 10) ? 10000 : i->ship->get_nritems() * 1000;
> + // This number is kind of average
> + ships_utilization_ = ships_utilization_ / 20 * 19 + tmp_util / 20;
ship utilization is in range 0-10000 so no big deal, but I rework it...
> + player_->set_ai_data(ships_utilization_, kShipUtil);
> +
> + // Arithmetics check
> + assert (ships_utilization_ >= 0 && ships_utilization_ <= 10000);
> + }
> }
> }
>
> @@ -4543,6 +4655,17 @@
> } else {
> allships.back().island_circ_direction = IslandExploreDirection::kCounterClockwise;
> }
> +
> + if (type == NewShip::kBuilt) {
> + marineTaskQueue_.push_back(kStopShipyard);
> + } else {
> + seafaring_economy = true;
> + if (ship.state_is_expedition()) {
> + assert (expedition_ship_ == kNoShip);
> + expedition_ship_ = ship.get_ship_id();
> + player_->set_ai_data(expedition_ship_, kExpShip);
but AI is not an object. It is not saved, is it? I will look at it...
> + }
> + }
> }
>
> // this is called whenever we lose ownership of a PlayerImmovable
--
https://code.launchpad.net/~widelands-dev/widelands/ai_ship_tweaks/+merge/280192
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_ship_tweaks.
References