← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/ai_ship_tweaks into lp:widelands

 

Review: Approve

very good! Only a couple of nits.

Please set a commit message (further up on this page) before letting bunnybot merge this. 



Diff comments:

> 
> === modified file 'src/ai/defaultai.cc'
> --- src/ai/defaultai.cc	2016-01-06 19:11:20 +0000
> +++ src/ai/defaultai.cc	2016-01-22 20:02:27 +0000
> @@ -62,28 +63,21 @@
>  constexpr int kMinMFCheckInterval = 19 * 1000;
>  constexpr int kShipCheckInterval = 5 * 1000;
>  constexpr int kMarineDecisionInterval = 20 * 1000;
> -constexpr int kTrainingSitesCheckInterval = 45 * 1000;
> +constexpr int kTrainingSitesCheckInterval = 15 * 1000;
>  
> -// least radius to scan terrain when considering colonization port
> +// handfull of constants used for expeditions/colonization
> +constexpr int kColonyScanStartArea = 35;
>  constexpr int kColonyScanMinArea = 10;
> +constexpr int kExpeditionMaxDuration = 90 * 60 * 1000;
> +constexpr uint32_t kNoShip = std::numeric_limits<uint32_t>::max();
> +const uint32_t kNoExpedition = 0;

nit: constexpr?

>  
>  // this is intended for map developers, by default should be off
>  constexpr bool kPrintStats = false;
>  
> -constexpr int kPersistentData  = 0; //int16_t & bools
> -constexpr int kMilitLoneliness = 1;
> -constexpr int kAttacker        = 2;
> -constexpr int kAttackMargin    = 0; //uint32_t
> -constexpr int kLastAttack      = 1;
> -constexpr int kProdRatio       = 2;
> -constexpr int kColonyScan      = 3;
> -constexpr int kTreesAround     = 4;
> -constexpr int kEarlyMilitary   = 5;
> -constexpr int kWoodDiff        = 0; //int32_t
> -constexpr int kTargetMilit     = 1;
> -constexpr int kLeastMilit      = 2;
> -
>  constexpr int8_t kUncalculated = -1;
> +constexpr uint8_t kFalse = 0;
> +constexpr uint8_t kTrue = 1;
>  
>  // duration of military campaign
>  constexpr int kCampaignDuration = 15 * 60 * 1000;
> 
> === modified file 'src/ai/defaultai.h'
> --- src/ai/defaultai.h	2016-01-06 19:11:20 +0000
> +++ src/ai/defaultai.h	2016-01-22 20:02:27 +0000
> @@ -254,14 +255,14 @@
>  	uint32_t num_prod_constructionsites;
>  	uint32_t num_ports;
>  
> -	int16_t last_attacked_player_;
> +	//int16_t last_attacked_player_;

remove commented out variables? Also below.

>  	uint32_t last_attack_time_;
>  	// check ms in this interval - will auto-adjust
>  	uint32_t enemysites_check_delay_;
>  
>  	// helping scores for building new military sites
> -	int32_t target_military_score_;
> -	int32_t least_military_score_;
> +	//int32_t target_military_score_;
> +	//int32_t least_military_score_;
>  
>  	WoodPolicy wood_policy_;
>  
> 
> === 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-22 20:02:27 +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 {
> +
> +/*
> + * stores data that are needed for AI
> + */
> +struct GamePlayerAiPersistentPacket : public GameDataPacket {

nit: make it a class ... { public: }, since it has logic

> +	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/logic/map_objects/tribes/tribe_descr.h'
> --- src/logic/map_objects/tribes/tribe_descr.h	2016-01-13 07:27:55 +0000
> +++ src/logic/map_objects/tribes/tribe_descr.h	2016-01-22 20:02:27 +0000
> @@ -143,6 +143,8 @@
>  
>  	void resize_ware_orders(size_t maxLength);
>  
> +	const std::vector<std::string>* get_ship_names() const {return &ship_names_;};

why not return const vector<>& ? A reference clearly signifies that this can never be nullptr, but is otherwise equivalent.

> +
>  private:
>  	// Helper function for adding a special worker type (carriers etc.)
>  	DescriptionIndex add_special_worker(const std::string& workername);
> 
> === modified file 'src/logic/player.cc'
> --- src/logic/player.cc	2016-01-14 22:09:24 +0000
> +++ src/logic/player.cc	2016-01-22 20:02:27 +0000
> @@ -201,6 +198,12 @@
>  				rediscover_node(egbase().map(), egbase().map()[0], note.fc);
>  			}
>  		});
> +
> +	//Populating remaining_shipnames vector
> +	for (auto shipname : *tribe_descr.get_ship_names()) {

nit:

const auto& shipname : 

to avoid copying

> +		m_remaining_shipnames.insert(shipname);
> +	}
> +
>  }
>  
>  
> @@ -1439,6 +1422,15 @@
>  	assert(m_ware_productions[0].size() == m_ware_stocks[0].size());
>  }
>  
> +/**
> + * Write remaining ship indexes to the give file
> + */
> +void Player::write_remaining_shipnames(FileWrite & fw) const {
> +	fw.unsigned_16(m_remaining_shipnames.size());
> +	for (auto shipname : m_remaining_shipnames){

const auto& shipname

> +		fw.string(shipname);
> +	}
> +}
>  
>  /**
>   * Write statistics data to the give file


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