Really great work! That was not easy, but I think this design fits much better 
into the existing code. I think that reads much better than before.

Last comment is about dealing with ship names. I suggest dealing with the 
string sets directly instead of indices into an array. 

Diff comments:

> 
> === modified file 'src/ai/defaultai.h'
> --- src/ai/defaultai.h        2016-01-06 19:11:20 +0000
> +++ src/ai/defaultai.h        2016-01-20 20:12:20 +0000
> @@ -348,13 +349,16 @@
>       uint32_t ai_productionsites_ratio_;
>       uint32_t ai_personality_early_militarysites;
>  
> +     //this points to persistent data stored in Player object

. Not owned.

so that nobody wonders if this leaks memory.

> +     Widelands::Player::AiPersistentState* persistent_data;
> +
>       // this is a bunch of patterns that have to identify weapons and armors 
> for input queues of trainingsites
>       std::vector<std::string> const armors_and_weapons =
>               {"ax", "lance", "armor", "helm", "lance", "trident", "tabard", 
> "shield", "mask"};
>  
>       enum {kReprioritize, kStopShipyard, kStapShipyard};
>  
> -     std::vector<int16_t> marineTaskQueue_;
> +     std::vector<int16_t> marine_task_queue;
>  
>       
> std::unique_ptr<Notifications::Subscriber<Widelands::NoteFieldPossession>>
>          field_possession_subscriber_;
> 
> === added file 'src/game_io/game_player_ai_persistent_packet.h'
> --- src/game_io/game_player_ai_persistent_packet.h    1970-01-01 00:00:00 
> +0000
> +++ src/game_io/game_player_ai_persistent_packet.h    2016-01-20 20:12:20 
> +0000
> @@ -0,0 +1,37 @@
> +/*
> + * Copyright (C) 2002-2004, 2006-2009 by the Widelands Development Team
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
> 02110-1301, USA.
> + *
> + */
> +
> +#ifndef WL_GAME_IO_GAME_PLAYER_AI_PERSISTENT_PACKET_H
> +#define WL_GAME_IO_GAME_PLAYER_AI_PERSISTENT_PACKET_H
> +
> +#include "game_io/game_data_packet.h"
> +
> +namespace Widelands {
> +
> +/*
> + * how many and which economies does a player have?

fix comment

> + */
> +struct GamePlayerAiPersistentPacket : public GameDataPacket {
> +     void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
> +     void write(FileSystem &, Game &, MapObjectSaver  * = nullptr) override;
> +};
> +
> +}
> +
> +#endif  // end of include guard: 
> WL_GAME_IO_GAME_PLAYER_AI_PERSISTENT_PACKET_H
> 
> === modified file 'src/game_io/game_player_info_packet.cc'
> --- src/game_io/game_player_info_packet.cc    2015-11-28 22:29:26 +0000
> +++ src/game_io/game_player_info_packet.cc    2016-01-20 20:12:20 +0000
> @@ -62,6 +62,7 @@
>  
>                                       player.set_ai(fr.c_string());
>                                       player.read_statistics(fr);
> +                                     player.read_remaining_shipidx(fr);

I find dealing with indices around ship names overly complex. these indices 
might be invalid. Why not keep a std::set<string> with the ship names around 
and save the individual ship name in the ship code? When you need to choose a 
new ship name you just use random_choice(set(kAllNames) - set(names of all 
ships)).

>  
>                                       player.m_casualties = fr.unsigned_32();
>                                       player.m_kills      = fr.unsigned_32();


-- 
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.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to