Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2002:
[Freeciv-Dev] Re: [FreeCiv-Cvs] per: Adding generalised calendar. Calend

[Freeciv-Dev] Re: [FreeCiv-Cvs] per: Adding generalised calendar. Calend

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: coppensbart@xxxxx
Cc: Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx>, Freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [FreeCiv-Cvs] per: Adding generalised calendar. Calendars can now ... (PR#1964)
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Sat, 24 Aug 2002 18:31:40 +0200

On Sat, Aug 24, 2002 at 01:23:30PM +0200, Bart Coppens wrote:
> On Friday 23 August 2002 22:03, Mike Kaufman wrote:
> > What complicates things immensely is when you require a calendar to handle
> > units of time that are different than mm:dd:yy hh:mm:ss system.
> >
> > -mike
> I came up with this list with possible problems and things worth paying 
> attention to, I don't know of these count as 'different':
>  -Leap years: If a scenario uses 1 day / turn, there should be the 
> possibility 
> of leap years. This could make this scenario more realistic, not only if it 
> were a scenario using 'normal' leap years (29th Februar), but scenarios using 
> complicated systems should also be possible.
> An example of other systems is, for examle, Tolkien's Elven calendar. They 
> have 3 'middle-days'. Every twelth year, these days are doubled, making a 
> total of 6 middle-days that year. Also, every third yén, there were only 3 
> middle-days.
>  -Different lengths of weeks, months, years, etc.
> This one seems to be very obvious: some cultures have longer or shorter 
> weeks, 
> months, etc. For example, some ancient cultures (like the Celts iirc) use the 
> synodical (29 1/2 days) or the sidereal (27 1/3) month based on the 
> movement/position of the moon.
> The Hobbits use months months of 30 days, and weeks of 6 days. Cultures with 
> different length of years should also be possible (think of a scenario on 
> another planet, like Mars)
>  -Naming days, weeks, years, etc.
> This should be trivial to implement, but I wanted to remind you of the 
> possibility since most cultures have different names for a year or day. 
> Especially the months may vary (again, for an example, see Tolkiens works)
> Also, it would be nice to name special days, like Christmas, Easter, etc.
>  -Adding non-month days
> I don't know if this should be an extra option (it could be implemented using 
> extra months), but (again) the Hobbits have some days that do not really 
> belong to any month: Yule, Lithe and Overlithe. I can imagine some real 
> cultures using these days, too.
>  -Stardates
> This is the only one that really qualifies the different timesystem you were 
> asking for. Stardates are used in Star Trek. There is much to find on the web 
> explainig this system. Explaining it here would take too long. Pay attention 
> though, there have been used 2 different types of stardates, so don't 
> implement one type and don't use the other, having the two different types in 
> a scenario would be very great!
>  -BC-AD
> Now the dates use a (so it seems) hardcoded BC and AD. I suggest making this 
> too editable. Most cultures didn't know about Christ, or some will have their 
> own major event to add to their years, so adding this seems pointless. Take 
> for example the Elves. They have Ages, being the First Age (FA), the Second 
> Age (SA), the Third Age (TA) and the Fourth Age (FA).
> The Hobbits of the Shire have another reckoning, the Shire Reckoning, using 
> year 1 as the year they colonization of the Shire.
>  -Customisable texts
> As a possible adition to the previous suggestion, it could be nice to 
> consider 
> this. Now the year indicator says things like 'Year: 1120 AD', and probably 
> in the future will be able to say things like 'Day: March 1120 AD', possibly 
> using TA or something like that. I think it would be nice to be able to 
> define what is said. So a scenario could have: 'This day is the <day>th day 
> of the <month number>th month of the year <year> Anno Domini'. This seems 
> far-fetched, but it could be useful.
>  -Fully Scriptable
> I like to dream of what has to come, so I suggest to make this so that when 
> serverside scripting finally works, the calendar can be scriptable as well. 
> For example, the Third Age in Tolkien's works ends when the Three Keepers, 
> Frodo, Bilbo and some elves set sail to at the Grey Havens. No technology, no 
> year (well, the date is given but I don't think it should be 'hardcoded' in a 
> possible scenario), only an event is used as the beginning of a new Age. 
> Since events could be scriptable, maybe the following pseudocode could be 
> used in this case:
> if Keepers.Transport = boat and Keepers.location = Grey Havens
>  then Calendar.age = "Fourth Age"
> A very long list, I hope at least some of this can become implemented. Most 
> of 
> these make future scenarios more realistic than Civ2 ever could be, so I 
> think they could be very useful.

<ad for me>
  All this can be done with my model.
</ad for me>

Or at least it can be implemented without any major changes in the
internals. So while adding a new calendar still requires writing new
code this is limited to three functions which need to be rewritten for
a new calendar. And you don't have to change code at the client.

The patch. Changes:
 - remove game.year
 - add dates (a string representation of a turn)
 - replace game.endyear with game.enddate
 - add game.startdate
 - add game.calendar
 - add two calendars (a classic freeciv one and a wargame style one)
 the latter is just to show what is possible
 - remove almost all references to year (in any form)
 - add a function turn_to_date which yields a date (various forms are
 - change unit of onsetbarbarian from year to turn

The patch is for a CVS before Ben's patch got applied.

Open issue is how many and how general should the calendars are? The
classic freeciv calendar (calendar==0) has a quite hardcoded behaviour
with the spaceshipparts. So I don't see a chance to get this easy
configurable with rulesets. Also because the next one may want a
certain year-step by another event (each player has build a certain
unit, a certain player has build a wonder,...).

So with the included calendar==1 you get turn descriptions like:
  March 23, 10 BC, 00:00
  March 23, 10 BC, 00:10
  March 23, 10 BC, 00:50
  March 23, 10 BC, 01:00
and so on.

Every other possibility mentioned above can be implemented with a new
calendar (which required minimal code changes). For the case above for
example you only have to code this function:

+static const char *cal_wargame_turn_to_date(int turn,
+                                           enum date_format date_format)
+  static char buffer[MAX_DATE_LEN];
+  switch (date_format) {
+    my_snprintf(buffer, sizeof(buffer), "%03d", turn);
+    break;
+  case DATE_BC:
+    my_snprintf(buffer, sizeof(buffer), _("March 23, 10 BC, %02d:%d0"),
+               turn / 6, turn % 6);
+    break;
+  default:
+    assert(0);
+  }
+  return buffer;

Implementing a solution which solves all the possible models mentioned
above and only requires ruleset changes and no code change is IMHO a
big nightmare.


 email: rf13@xxxxxxxxxxxxxxxxx
 "The very concept of PNP is a lovely dream that simply does not translate to
  reality. The confusion of manually doing stuff is nothing compared to the
  confusion of computers trying to do stuff and getting it wrong, which they
  gleefully do with great enthusiasm." 
    -- Jinx Tigr in the SDM

Attachment: cal1.diff.gz
Description: application/gunzip

[Prev in Thread] Current Thread [Next in Thread]