Re: [Freeciv-Dev] Aircraft and fuel

2007-02-11 Thread Per I. Mathisen

On Sat, 10 Feb 2007, Jason Short wrote:

One weird situation is if you fly a bomber out from a carrier to hit a
spot 12 tiles away...then move the carrier in the other direction 9 (or
however many is the maximum) tiles.  Then at the start of the next turn
(it does happen at the start right?) the bomber gets automatically
returned to the carrier even though it's now 20 tiles away.  This would
seem just a bit odd to the player.


Indeed. However, the opposite solution, to let the aircraft fail to return 
because you accidentially moved your carrier out of range, would be nasty.


One solution could be to require a carrier that launches aircraft to stay 
put where it is until your next turn. Real life carriers do not move out 
of an area while its aircraft are still flying missions there...



A technical problem is that the return point is sometimes a city, a
unit, or just a tile.  And if it is a unit there is limited transporting
capacity and it's possible when the plane tries to return it finds that
the carrier is full.


Yes. I wrote code for this, and it gets rather complicated due to all 
the possible corner cases:


/***
  Return or relocate aircraft (and other UCF_RETURN_TO_BASE class units).
  Function returns FALSE if unit died for some reason.
  1) Try using goto coordinates.
  2) Try to return to a carrier.
  3) Try returning to last city.
  4) Look for anywhere in range.
/
static bool player_return_to_base(struct player *pplayer, struct unit *punit)
{
  /* 1) Goto coordinates set, try to relocate to new base. */
  if (punit-goto_tile) {
struct unit *carrier = find_transport_from_tile(punit, punit-goto_tile);

if (real_map_distance(punit-tile, punit-goto_tile)
  (unit_move_rate(punit) + punit-moves_left) / SINGLE_MOVE
 !is_non_allied_unit_tile(punit-goto_tile, pplayer)
 (carrier || can_unit_survive_at_tile(punit, punit-goto_tile))) {
  if (move_unit(punit, punit-goto_tile, 0)) {
punit-goto_tile = NULL;
if (carrier) {
  put_unit_onto_transporter(punit, carrier);
}
return TRUE;
  } else {
return FALSE;
  }
} else {
  /* Invalidate goto */
  notify_player(pplayer, punit-tile, E_UNIT_ORDERS,
_(Your %s could not relocate to target base.),
unit_name(punit-type));
  punit-goto_tile = NULL;
}
  }

  if (punit-base.unit != -1 || punit-base.tile != punit-tile) {
struct unit *carrier = find_unit_by_id(punit-base.unit);

/* 2) Return to mobile base (carrier). If carrier moves out of range,
 * we still allow it to land on it for convenience and ease of mind. */
if (carrier  could_unit_load(punit, carrier)) {
  if (move_unit(punit, carrier-tile, 0)) {
put_unit_onto_transporter(punit, carrier);
return TRUE;
  } else {
return FALSE;
  }
}
/* 3) Return to fixed base (terrain base). If base is set, we can by
 * definition reach it, unless it was destroyed. */
if (punit-base.tile
 !is_non_allied_unit_tile(punit-base.tile, pplayer)
 can_unit_survive_at_tile(punit, punit-base.tile)) {
  return move_unit(punit, punit-base.tile, 0);
}
/* Invalidate return */
notify_player(pplayer, punit-tile, E_UNIT_ORDERS,
  _(Your %s could not return to base.),
  unit_name(punit-type));
punit-base.unit = -1;
punit-base.tile = NULL;
  }

  /* 4) Ooops - lost our base! Search for a new base to land on. First
   * we check the tile we stand on, then any other possible bases. */
  if (can_unit_survive_at_tile(punit, punit-tile)) {
return TRUE; /* one lucky bastard! */
  } else {
struct unit *carrier = find_transport_from_tile(punit, punit-tile);

if (carrier) {
  put_unit_onto_transporter(punit, carrier);
  return TRUE; /* should be a rare occurance, but possible */
}
  }
  players_iterate(aplayer) {
if (!pplayers_allied(pplayer, aplayer)) {
  continue;
}
city_list_iterate(aplayer-cities, pcity) {
  if (real_map_distance(punit-tile, pcity-tile)
(unit_move_rate(punit) + punit-moves_left) / SINGLE_MOVE
   !is_non_allied_unit_tile(pcity-tile, pplayer)
   can_unit_survive_at_tile(punit, pcity-tile)) {
notify_player(pplayer, pcity-tile, E_UNIT_ORDERS,
  _(Your %s made an emergency relocation to %s.),
  unit_name(punit-type), pcity-name);
return move_unit(punit, pcity-tile, 0);
  }
} city_list_iterate_end;
unit_list_iterate(aplayer-units, carrier) {
  if (could_unit_load(punit, carrier)
   real_map_distance(punit-tile, carrier-tile)
   (unit_move_rate(punit) + punit-moves_left) / SINGLE_MOVE
   !is_non_allied_unit_tile(carrier-tile, pplayer)) 

Re: [Freeciv-Dev] Aircraft and fuel

2007-02-11 Thread Benedict Adamson

Per Inge Mathisen wrote:
...
I suggest instead of fuel, we add the rule that all aircraft 
automatically return to the airfield/city/carrier that the unit visited 
last at the start of your turn. That is, when you use an aircraft, it 
stays in the air until your next turn/phase, allowing other players a 
chance to shoot it down (of course, this is exploitable by attacking in 
the last second in simultaneous movement mode, but I have given up 
trying to make that mode fair).

...

That would make aircraft more like a kind of artillery shell, allowing a 
unit (aircraft carrier) to attack at range rather than only adjacent 
tiles. A more extreme solution would be to eliminate the aircraft 
entirely, in the same way that the game does not record artillery shells 
or other ammunition. The aircraft unit would instead represent the 
airfield the squadron is using, which unlike other units can attack 
units that are not adjacent.


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


Re: [Freeciv-Dev] Aircraft and fuel

2007-02-10 Thread Daniel Markstedt

On 2/10/07, Per Inge Mathisen [EMAIL PROTECTED] wrote:

I have been looking at the goto issues with aircraft, and I think we have
been approaching this problem in the totally wrong way. The aircraft model
with fuel was always just a neat hack, but not a good design. Attempting
to solve goto for aircraft, for client, for AI and for automatic return,
turned out to be extremely complicated. It is a problem that, I think,
screams for redesign rather than a solution.

The whole dangerous tiles path finding for triremes and aircraft should
be removed. It was just too hard. For triremes it can be done either with
deep ocean tiles (how far did we get here?) that are impassable for
triremes, or just making a movement rule that they cannot stray from land.
For aircraft, we would need to abolish the concept of fuel.

I suggest instead of fuel, we add the rule that all aircraft automatically
return to the airfield/city/carrier that the unit visited last at the
start of your turn. That is, when you use an aircraft, it stays in the air
until your next turn/phase, allowing other players a chance to shoot it
down (of course, this is exploitable by attacking in the last second in
simultaneous movement mode, but I have given up trying to make that mode
fair).

This return is done with teleport and no movement points are required - no
need to fuss about counting tiles for return. If you use goto, you can
designate a new landing site if it is within (movement points remaining +
max movement points) tiles, and the aircraft will land there instead,
allowing aircraft to move a maximum of 2xMP each turn. The teleport method
is already used for airlift, so it has precedent for air movement.

Opinions?

   - Per

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



I'm in favor of this idea. It sounds much more elegant a game mechanic.

Deep ocean has been implemented in (or there is a patch for) devel.
Amplio has nice ocean-deep ocean border sprites, but there are no deep
ocean-land sprites yet, which makes especially poles look bad.

~Daniel

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