<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=GCI%2FRecruitment</id>
	<title>GCI/Recruitment - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=GCI%2FRecruitment"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GCI/Recruitment&amp;action=history"/>
	<updated>2026-07-10T11:03:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=GCI/Recruitment&amp;diff=40534&amp;oldid=prev</id>
		<title>Aethaeryn: categorizing</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GCI/Recruitment&amp;diff=40534&amp;oldid=prev"/>
		<updated>2011-03-06T03:03:58Z</updated>

		<summary type="html">&lt;p&gt;categorizing&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 03:03, 6 March 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l116&quot; &gt;Line 116:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 116:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; return 0;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; return 0;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category: GCI]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Aethaeryn</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=GCI/Recruitment&amp;diff=38959&amp;oldid=prev</id>
		<title>Crab: Created page with ' #include &lt;string&gt;  #include &lt;vector&gt;  #include &lt;algorithm&gt;  #include &lt;iostream&gt;  class potential_recruit  {  public:         potential_recruit(const std::string &amp;name, int cost,…'</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GCI/Recruitment&amp;diff=38959&amp;oldid=prev"/>
		<updated>2010-11-22T15:36:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039; #include &amp;lt;string&amp;gt;  #include &amp;lt;vector&amp;gt;  #include &amp;lt;algorithm&amp;gt;  #include &amp;lt;iostream&amp;gt;  class potential_recruit  {  public:         potential_recruit(const std::string &amp;amp;name, int cost,…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; #include &amp;lt;string&amp;gt;&lt;br /&gt;
 #include &amp;lt;vector&amp;gt;&lt;br /&gt;
 #include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 class potential_recruit&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
        potential_recruit(const std::string &amp;amp;name, int cost, double quality, int max_qty)&lt;br /&gt;
                : name_(name), cost_(cost), quality_(quality), max_qty_(max_qty)&lt;br /&gt;
                {}&lt;br /&gt;
        const std::string&amp;amp; name() const&lt;br /&gt;
        {&lt;br /&gt;
                return name_;&lt;br /&gt;
        }&lt;br /&gt;
        int cost() const&lt;br /&gt;
        {&lt;br /&gt;
                return cost_;&lt;br /&gt;
        }&lt;br /&gt;
        int quality() const&lt;br /&gt;
        {&lt;br /&gt;
                return quality_;&lt;br /&gt;
        }&lt;br /&gt;
        int max_qty() const&lt;br /&gt;
        {&lt;br /&gt;
                return max_qty_;&lt;br /&gt;
        }&lt;br /&gt;
 private:&lt;br /&gt;
        std::string name_;&lt;br /&gt;
        int cost_;&lt;br /&gt;
        double quality_;&lt;br /&gt;
        int max_qty_;&lt;br /&gt;
 };&lt;br /&gt;
 class team&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
        int gold()&lt;br /&gt;
        {&lt;br /&gt;
                return gold_;&lt;br /&gt;
        }&lt;br /&gt;
        void set_gold(int gold)&lt;br /&gt;
        {&lt;br /&gt;
                gold_ = gold;&lt;br /&gt;
        }&lt;br /&gt;
        void add_unit(const std::string &amp;amp;unit)&lt;br /&gt;
        {&lt;br /&gt;
               units_.push_back(unit);&lt;br /&gt;
        }&lt;br /&gt;
        const std::vector&amp;lt;std::string&amp;gt;&amp;amp; units()&lt;br /&gt;
        {&lt;br /&gt;
                return units_;&lt;br /&gt;
        }&lt;br /&gt;
        int get_current_qty(const potential_recruit &amp;amp;r) const&lt;br /&gt;
        {&lt;br /&gt;
                return get_current_qty(r.name());&lt;br /&gt;
        }&lt;br /&gt;
        int get_current_qty(const std::string &amp;amp;name) const&lt;br /&gt;
        {&lt;br /&gt;
                return std::count(units_.begin(), units_.end(), name);&lt;br /&gt;
        }&lt;br /&gt;
        void spend_gold(int gold)&lt;br /&gt;
        {&lt;br /&gt;
                gold_-=gold;&lt;br /&gt;
        }&lt;br /&gt;
 private:&lt;br /&gt;
        int gold_;&lt;br /&gt;
        std::vector&amp;lt;std::string&amp;gt; units_;&lt;br /&gt;
 };&lt;br /&gt;
 /** this is the function to call to do 1 recruit when you've selected it */&lt;br /&gt;
 static void recruit(team &amp;amp;t, const potential_recruit &amp;amp;r)&lt;br /&gt;
 {&lt;br /&gt;
        if (t.gold()&amp;lt;r.cost()) {&lt;br /&gt;
                std::cerr &amp;lt;&amp;lt;  &amp;quot;ERROR: cannot recruit &amp;quot;&amp;lt;&amp;lt;r.name()&amp;lt;&amp;lt;&amp;quot;, not enough gold&amp;quot;&amp;lt;&amp;lt; std::endl;&lt;br /&gt;
                exit(-1);&lt;br /&gt;
        }&lt;br /&gt;
        if (t.get_current_qty(r)&amp;gt;=r.max_qty()) {&lt;br /&gt;
                std::cerr &amp;lt;&amp;lt; &amp;quot;ERROR: cannot recruit &amp;quot;&amp;lt;&amp;lt;r.name()&amp;lt;&amp;lt;&amp;quot;, too many in the field&amp;quot;&amp;lt;&amp;lt; std::endl;&lt;br /&gt;
                exit(-1);&lt;br /&gt;
        }&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot; Recruiting [&amp;quot; &amp;lt;&amp;lt; r.name() &amp;lt;&amp;lt; &amp;quot;]&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        t.spend_gold(r.cost());&lt;br /&gt;
        t.add_unit(r.name());&lt;br /&gt;
 }&lt;br /&gt;
 void expect(const team &amp;amp;t, const std::string &amp;amp;name, int qty)&lt;br /&gt;
 {&lt;br /&gt;
        int current_qty = t.get_current_qty(name);&lt;br /&gt;
        if (current_qty != qty) {&lt;br /&gt;
                std::cerr &amp;lt;&amp;lt;  &amp;quot;ERROR: wrong number of [&amp;quot;&amp;lt;&amp;lt; name &amp;lt;&amp;lt; &amp;quot;], expected &amp;quot;&amp;lt;&amp;lt;qty&amp;lt;&amp;lt;&amp;quot; but got &amp;quot;&amp;lt;&amp;lt; current_qty &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
                exit(-2);&lt;br /&gt;
        } else {&lt;br /&gt;
                std::cerr &amp;lt;&amp;lt;  &amp;quot;OK: count of [&amp;quot;&amp;lt;&amp;lt; name &amp;lt;&amp;lt; &amp;quot;] is &amp;quot;&amp;lt;&amp;lt; current_qty&amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 static void ai_choose_recruits(team &amp;amp;t, int max_units_to_recruit, double quality_factor, const  std::vector&amp;lt;potential_recruit&amp;gt; &amp;amp;recruit_list)&lt;br /&gt;
 {&lt;br /&gt;
        /* TODO: code your implementation here */&lt;br /&gt;
        recruit(t,recruit_list.at(1));//Royal Guard&lt;br /&gt;
        recruit(t,recruit_list.at(1));//Royal Guard&lt;br /&gt;
        recruit(t,recruit_list.at(0));//Spearman&lt;br /&gt;
        recruit(t,recruit_list.at(0));//Spearman&lt;br /&gt;
        recruit(t,recruit_list.at(0));//Spearman&lt;br /&gt;
 }&lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
        //a small testcase&lt;br /&gt;
        team t;&lt;br /&gt;
        t.set_gold(120);&lt;br /&gt;
        t.add_unit(&amp;quot;Spearman&amp;quot;);&lt;br /&gt;
        std::vector&amp;lt;potential_recruit&amp;gt; recruit_list;&lt;br /&gt;
        recruit_list.push_back(potential_recruit(&amp;quot;Spearman&amp;quot;, 13, 12.6 ,10));&lt;br /&gt;
        recruit_list.push_back(potential_recruit(&amp;quot;Royal Guard&amp;quot;, 30, 40.0, 2));&lt;br /&gt;
        expect(t,&amp;quot;Spearman&amp;quot;, 1);&lt;br /&gt;
        expect(t,&amp;quot;Royal Guard&amp;quot;, 0);&lt;br /&gt;
        ai_choose_recruits(t, 5, 1.0, recruit_list);&lt;br /&gt;
        expect(t,&amp;quot;Spearman&amp;quot;, 4);&lt;br /&gt;
        expect(t,&amp;quot;Royal Guard&amp;quot;, 2);&lt;br /&gt;
        return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Crab</name></author>
		
	</entry>
</feed>