[Freeciv-Dev] [patch #2889] Allow autosettlers to plan for farmland

2011-08-10 Thread Ryan Riegel

Follow-up Comment #2, patch #2889 (project freeciv):

Your second concern is already addressed by the code; my modifications only
take effect in the case that the tile is not already irrigated (but can be).

Your first concern is a valid complaint.  The remedy is ugly, though, and
possibly fruitless: I'm not sure that the game allows rule-sets to make
farmland building and irrigation take a different amount of time because,
unlike building roads and railroads, building farmland uses the same activity
type as irrigation.  (This quirk is, in fact, why I couldn't implement
farmland planning in the same way that railroad planning is already
performed.)

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2889] Allow autosettlers to plan for farmland

2011-08-09 Thread Ryan Riegel

URL:
  

 Summary: Allow autosettlers to plan for farmland
 Project: Freeciv
Submitted by: rriegs
Submitted on: Wed 10 Aug 2011 05:07:51 AM GMT
Category: ai
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: 

___

Details:

Already, autosettlers will build roads even when all they really want to do
is build a railroad.  This patch enables autosettlers to build irrigation
solely for the purpose of later building farmland.

This patch (in conjunction with https://gna.org/patch/?2840) will result in
autosettlers prioritizing the irrigation of tiles such as wheat and oases over
other improvements, as farmed wheat/oases yield a whopping 6 food for an
improvement of 3.  Looking just one step ahead (at mere irrigation) will only
notice one extra food, and thus might not result in these tiles being
irrigated until after improvements are finished elsewhere.

This patch would also have an impact if (somehow) a despotism obtains
refrigeration.  Irrigation may not provide any benefit at all for some tiles,
but farmland still will.  This effect may also be the case in alternate
rule-sets.

TODO: It would be nice if autosettlers could think ahead for other terrain
modifications, as well.  For instance, autosettlers usually convert jungle
(1/0/0) to forest (1/2/0) instead of grassland (2/0/0) even though grassland
can ultimately be improved to 4/0/1 but forest offers no further improvement.



___

File Attachments:


---
Date: Wed 10 Aug 2011 05:07:51 AM GMT  Name:
add-autosettler-farmland-planning.patch  Size: 2kB   By: rriegs



___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2885] Fix autosettler to use rail connectivity bonus when planning for railroads

2011-08-09 Thread Ryan Riegel

Follow-up Comment #1, patch #2885 (project freeciv):

Sorry, forgot to log in.  The following is my submission and upload.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2866] A different autosettler fix for 2.3.0-RC2

2011-08-08 Thread Ryan Riegel

Follow-up Comment #2, patch #2866 (project freeciv):

My apologies, but there was a segfault that could occur with
fix-autosettler-for-city-centers.  The game code can and does produce city
objects with null tile pointers, which ultimately lead to NULL dereferences. 
I've attached corrected versions of this patch as well as all-of-the-above.

(file #13783, file #13784)
___

Additional Item Attachment:

File name: fix-autosettler-for-city-centers-ii.patch Size:3 KB
File name: all-of-the-above-ii.patch  Size:6 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #17767] Advisor code don't handle special resouces

2011-08-07 Thread Ryan Riegel

Follow-up Comment #4, bug #17767 (project freeciv):

A patch correcting the second issue is now available at
https://gna.org/patch/index.php?2866

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2866] A different autosettler fix for 2.3.0-RC2

2011-08-07 Thread Ryan Riegel

Additional Item Attachment, patch #2866 (project freeciv):

File name: fix-autosettler-for-city-centers.patch Size:2 KB
File name: fix-autosettler-for-tile-resources.patch Size:0 KB
File name: fix-autosettler-road-to-rail-extra.patch Size:1 KB
File name: add-autosettler-farmland-planning.patch Size:1 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2866] A different autosettler fix for 2.3.0-RC2

2011-08-07 Thread Ryan Riegel

Follow-up Comment #1, patch #2866 (project freeciv):

I've tracked down and corrected the bug behind the second issue mentioned in
https://gna.org/bugs/?17767, where autosettler won't transform the city tile
even though the result is strictly better.  The nature of the problem and
solution is discussed in my comment there; in short, code called by
autosettler doesn't realize the created virtual tile should serve as the city
center and so output bonuses are not applied.  My fix alters is_city_center to
look at a tile's coordinates instead of its raw pointer.  A cursory
investigation suggests that this shouldn't cause any problems.

I've uploaded this patch as well as separate patches for my three original
fixes, plus yet another patch that incorporates them all.  None of the
individual-feature patches conflict with one another.

(file #13771)
___

Additional Item Attachment:

File name: all-of-the-above.patch Size:6 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #17767] Advisor code don't handle special resouces

2011-08-06 Thread Ryan Riegel

Follow-up Comment #3, bug #17767 (project freeciv):

A quick follow up:

I've figured out the problem with the engineers not transforming the city
center.  It seems again the culprit is again the virtual tile.  The city fails
to report that the virtual tile would serve as its city center, and so
autosettler doesn't realize that it should act as if it had irrigation,
farmland, and a minimum of one food and one shield.

Thus, autosettler again perceives any work on the city square as clobbering
its various benefits.  This is irrelevant for irrigation and road building,
but can be significant for transformation and mining.

I have a crude fix for this problem, but it involves changing the definition
of is_city_center.  Rather than comparing tile pointers, it checks if tiles
have the same x-y coordinates (and tile_virtual_new is modified to preserve
x-y coordinates).  I'm not sure if this could potentially break things,
though.  Can distinct tiles ever have matching x-y coordinates?

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #17767] Advisor code don't handle special resouces

2011-08-06 Thread Ryan Riegel

Follow-up Comment #2, bug #17767 (project freeciv):

The underlying problem of your first concern is that tile_virtual_new fails
to set S_RESOURCE_VALID, so autosettler effectively thinks that anything it
does to a tile will kill its resources.  Patch https://gna.org/patch/?2866
corrects this problem directly.

I'm not sure why the engineers won't transform the city tile from 3/1/3 to
4/1/3.  It might be getting confused about the 1/1/0 minimum output for city
tiles, but even without the minimum one food and shield, autosettler should be
happy to transform 3/1/3 to 4/0/3 because food is slightly favored above
shields.  I'll have to take a closer look.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2840] Autosettler tweak for 2.4 r 20006

2011-08-06 Thread Ryan Riegel

Follow-up Comment #2, patch #2840 (project freeciv):

See my comment in https://gna.org/patch/?2866

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2841] Autosettler tweak for 2.3.0-RC1

2011-08-06 Thread Ryan Riegel

Follow-up Comment #3, patch #2841 (project freeciv):

See my comment in https://gna.org/patch/index.php?2841

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2841] Autosettler tweak for 2.3.0-RC1

2011-08-06 Thread Ryan Riegel

Follow-up Comment #2, patch #2841 (project freeciv):

I've tried this patch out and there seems to be a problem with the logic that
biases irrigation/mining towards where roads already exist.  The bias is so
strong that autosettlers tear down forests and, worse, replant them on
farmland just because a road happens to pass through!

I commented out the road bias and the patch still doesn't quite work. 
Autosettlers are much better about irrigating tiles with resources, but still
miss some tiles (wheat, oases) while irrigating some tiles that might be
better mined (oil).

My patch (https://gna.org/patch/?2866) addresses the underlying problem---the
fact that resource bonuses aren't counted when autosettler considers the
changes it can make to tiles---and seems to fix the problem of autosettlers
avoiding resource tiles.  It does nothing, however, to favor road construction
near existing improvements, nor will it build farmland near cities that can't
yet use it.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #2866] A different autosettler fix for 2.3.0-RC2

2011-08-06 Thread Ryan Riegel

URL:
  

 Summary: A different autosettler fix for 2.3.0-RC2
 Project: Freeciv
Submitted by: rriegs
Submitted on: Sat 06 Aug 2011 11:15:58 PM GMT
Category: ai
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: 

___

Details:

This patch addresses the issue of autosettler not irrigating (or building
roads or farmland on) tiles with certain resources.  This is done differently
from https://gna.org/patch/?2841 in that this patch corrects a bug preventing
proper consideration of resources' contribution to their tiles' outputs.

This patch also adjusts autosettler's consideration of building a road for
the sole purpose of building a railroad, which incorrectly used the road
connectivity bonus rather than the bonus for rail.  (The road connectivity
bonus is still used when considering building the road for its own sake.)

Lastly, this patch also adds the ability for autosettler to consider
irrigating a tile for the sole purpose of building farmland.  While
autosettler is likely going to irrigate the tile anyway, this might lead to a
better decision about what tile/improvement to work on first.




___

File Attachments:


---
Date: Sat 06 Aug 2011 11:15:58 PM GMT  Name:
fix-autosettling-for-resources-etc.patch  Size: 4kB   By: rriegs



___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #13558] [RT #40005] Strange autosettler behavior

2011-08-06 Thread Ryan Riegel

Follow-up Comment #1, bug #13558 (project freeciv):

This bug (whether you want to call it that) is still present, but I can
explain what's going on:

Autosettler observes that grassland (2/0/0) may be Mined into a forest
(1/2/0) for a net improvement of 1 output (autosettler values food just
slightly more than shields, but two shields at the cost of one food is still
seen as worthwhile).  However, if a water source is also available (and you're
not a Despot!), autosettler observes that grassland can be Irrigated up to
3/0/0, which is even better and takes less time, to boot.  The problem arises
when either a water source is not immediately available, in which case
autosettler doesn't even consider irrigating the tile, or when your government
doesn't actually benefit from the irrigation due to the -1 penalty for outputs
over 3, in which case irrigating just doesn't seem to help.

A fix for the later case is straightforward: Pretend you don't have the
output penalty when reasoning about the tile because you probably won't have
it for long.  A bit annoying to code up, but doable.

The former is a bit more troubling, though, because autosettler currently
only connects irrigation to tiles via "emergent behavior".  In short,
Irrigating a different tile usually looks better than Mining waterless
grassland into a forest, so autosettler does that first.  Afterwards, the
grassland might have access to water, or if it still doesn't, a tile next to
it might, and so forth.  If, on the other hand, the only connectable water to
the grassland would require irrigation outside of all cities' limits,
autosettler doesn't realize a connection is possible (or might become possible
at a later date).

To solve this problem, it might make sense to more heavily penalize
autosettler for modifying terrain such that it leads to a drop in food or
shields, as a loss in either of these can be disastrous for a city.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev