Journeyometer 2: Rivendell is live!

Adventure in the world of J.R.R. Tolkien’s The Lord of the Rings. Learn more at our website: http://www.cubicle7.co.uk/our-games/the-one-ring/
Angelalex242
Posts: 1116
Joined: Mon Dec 02, 2013 7:52 pm
Location: Valinor

Re: Journeyometer 2: Rivendell is live!

Post by Angelalex242 » Sat Jan 17, 2015 3:32 am

Well then.

Can we duplicate Bilbo's journey with the 13 Dwarves and Gandalf?

How many corruption checks did Bilbo and pals make?

Glorelendil
Posts: 5162
Joined: Mon Jan 13, 2014 5:20 pm

Re: Journeyometer 2: Rivendell is live!

Post by Glorelendil » Sat Jan 17, 2015 9:17 am

Ok, I'm a little embarrassed to be showing this, but below is the code that does the actual journey computations. This is after the selected cells have been sorted and validated. Bear in mind that this was a javascript learning project for me, and that (as is my wont) I just started typing without really planning out how this was going to work.

Code: Select all

	/* DIVIDE INTO LEGS */

	var journey = [];
	var leg = null;

	for(var i=0;i<sorted_cells.length;i++) {
		var cell = sorted_cells[i];
		if( cell.region_id == -1 ) {
			invalidJourney("Outside the Lines");
			return;
		}
		// good place to set distance
		cell["distance"] = 10.0;
		if( $("#first_cell_rule_2").prop("checked")) {
			if( i == 0 || i == sorted_cells.length - 1) {
				cell.distance = 5.0;
			}
		}
		
		if( !leg ) {
			leg = {"cells":[]};
			leg["region_id"] = cell.region_id;
		}
		
		if( leg.region_id != cell.region_id ) {
			journey.push( leg );
			leg = null;
			i -= 1;
		} else {
			leg.cells.push( cell );
		}
	}
	// and the final leg...
	if( leg ) {
		journey.push( leg );		
	}
	
	/* SET VARIABLES FOR LOOPING */
		
	var terrains = {"Easy":{"multiplier":1, "tn":12},
					"Moderate":{"multiplier":1.5, "tn":14},
					"Hard":{"multiplier":2, "tn":16},
					"Severe":{"multiplier":3, "tn":18},
					"Daunting":{"multiplier":5, "tn":20},
					"Impassable":{"multiplier":-1, "tn":0}};

	var types = {"Free Lands":{"tn":12},
				"Border Lands":{"tn":14},
				"Wild Lands":{"daysperroll":7, "tn":16},
				"Shadow Lands":{"daysperroll":1, "tn":18},
				"Dark Lands":{"daysperroll":0.5, "tn":20}};
					
	
	journey["total_rolls"] = 0;
	journey["total_c_rolls"] = 0;
	journey["total_miles"] = 0;
	journey["total_days"] = 0;
	
	/* DATES */
	var month = document.getElementById( "startmonth" ).value;
	var day = document.getElementById( "startday" ).value;
	var start_date = new Date( 0, month, day );
//	date.setDate( date.getDate() - 1 ); // does this work?
//	var end_date = new Date(0, month, day );
	var date_cells = [];

	var speed = ( document.getElementById("riding").checked ? 40 : 20 );
	
	
	/* SET LEG ATTRIBUTES */
	/* First time through just set values */
	
	var last_day_stamped = -1
	for(var i=0;i<journey.length;i++) {
		var leg = journey[i];
		leg["days"] = 0;
		leg["region"] = regionForId(leg.region_id);
		
		if( leg.region.terrain_type == "Impassable" ) {
			invalidJourney( "Impassable!" );
			return;
		} else if ( !leg.region ) {
			invalidJourney( "Outside the Lines");
			return;
		}
		
		// position
		
		if( i == 0 ) {
			if( journey.length > 1 ) {
				leg["position"] = "first";				
			} else {
				leg["position"] = "only";
			}
		} else if ( i == journey.length - 1) {
			leg["position"] = "last";
		} else {
			leg["position"] = "middle";
		}
		
		leg["miles"] = 0;
		var loi = [];  // locations of interest; reset for each leg
		
		for(var c=0;c<leg.cells.length;c++) {
			var cell=leg.cells[c];

			var rdp = Math.floor( journey.total_days );
			if( rdp > last_day_stamped ) {
				var date = new Date( start_date );
				date.setDate( date.getDate() + rdp );
				cell["date"] = date;
				date_cells.push( cell );
				last_day_stamped = rdp;
			}
			
			leg.miles += cell.distance; // this might be only 5
			// time to cross
			var apparent_distance = cell.distance * terrains[leg.region.terrain_type].multiplier;
			var days_to_cross = apparent_distance / speed;
			journey.total_days += days_to_cross
			leg.days += days_to_cross;
			var days_per_roll = daysPerRoll( date.getMonth());
			journey.total_rolls += days_to_cross / days_per_roll;
						
			// lois
			loi = loi.concat( locationsAtCell( cell ));			
		}
		
		journey.total_miles += leg.miles;
				
		// corruption checks
		var type = types[leg.region.region_type];
		if( type.daysperroll ) {
			leg["corruption_rolls"] = Math.ceil( leg.days / type.daysperroll );
			leg["corruption_tn"] = type.tn;
			journey.total_c_rolls += leg.corruption_rolls;
		}
		
		// travel checks
		leg["travel_tn"] = terrains[leg.region.terrain_type].tn;
		
		// make loi unique
		var location_set = {};
		for(var l=0;l<loi.length;l++) {
			var loc = loi[l];
			location_set[loc.id] = loc;
		}
		leg["loi"] = location_set;
		
		// now set start and end for first and last legs
		if(i == 0) { // this is the first leg
			var start_cell = leg.cells[0];
			locations = locationsAtCell( start_cell );
			if( locations.length > 0 ) {
				leg["start"] = locations[0];
			}
		}
		
		if(i == journey.length - 1) { // this is the last leg
			var end_cell = leg.cells[leg.cells.length - 1];
			locations = locationsAtCell( end_cell );
			if( locations.length > 0 ) {
				leg["end"] = locations[0];
			}
			if( journey.length > 1 ) {
				leg["prev"] = journey[i-1].region.name				
			}
		}
	}
	
	journey.total_rolls = Math.ceil( journey.total_rolls );
	
	if( journey.length > 1 ) {
		journey[0]["next"] = journey[1].region.name;
	}
	
	var leftover = 0;
	for(var i=0;i<journey.length;i++) {
		var leg = journey[i];
		var rolls = leg.days * 1.0 * journey.total_rolls / journey.total_days + leftover;
		leg.travel_rolls = Math.round( rolls );
		leftover = rolls - leg.travel_rolls;
	}
....sigh.

EDIT: And don't ask me what any of it means. I've forgotten.
The Munchkin Formerly Known as Elfcrusher
Journey Computer | Combat Simulator | Bestiary | Weapon Calculator

User avatar
zedturtle
Posts: 3289
Joined: Sat Mar 22, 2014 12:03 am

Re: Journeyometer 2: Rivendell is live!

Post by zedturtle » Sat Jan 17, 2015 11:20 am

Where are you calculating seasons? I didn't immediately see that... that was my other question to you, as I'd consider November to be Autumn (and thus 3 Fatigue for Failure and tests every three days) but I'm not sure about where your cutoffs are.
Jacob Rodgers, occasional nitwit.

This space intentionally blank.

Glorelendil
Posts: 5162
Joined: Mon Jan 13, 2014 5:20 pm

Re: Journeyometer 2: Rivendell is live!

Post by Glorelendil » Sat Jan 17, 2015 2:05 pm

I will check. I remember I had a hard time deciding where to change seasons.
The Munchkin Formerly Known as Elfcrusher
Journey Computer | Combat Simulator | Bestiary | Weapon Calculator

Otaku-sempai
Posts: 3399
Joined: Sun May 12, 2013 2:45 am
Location: Lackawanna, NY

Re: Journeyometer 2: Rivendell is live!

Post by Otaku-sempai » Sat Jan 17, 2015 8:42 pm

Glorelendil wrote:I will check. I remember I had a hard time deciding where to change seasons.
That shouldn't be too difficult. The mid-seasons align approximately with the solstices and equinoxes. So the seasons should start a month-and-a-half earlier (at least as far as the calendar of Gondor is concerned):

Spring: February 15 to May 14.
Summer: May 15 to August 14.
Fall: August 15 to November 14.
Winter: November 15 to February 14.
Last edited by Otaku-sempai on Sat Jun 17, 2017 11:43 am, edited 2 times in total.
"Far, far below the deepest delvings of the Dwarves, the world is gnawed by nameless things. Even Sauron knows them not. They are older than he."

Glorelendil
Posts: 5162
Joined: Mon Jan 13, 2014 5:20 pm

Re: Journeyometer 2: Rivendell is live!

Post by Glorelendil » Sat Jan 17, 2015 8:45 pm

Otaku-sempai wrote:
Glorelendil wrote:I will check. I remember I had a hard time deciding where to change seasons.
That shouldn't be too difficult. The mid-seasons align approxumately with the solstices and equinoxes. So the seasons should start a month-and-a-half earlier:

Spring: February 15 to May 14.
Summer: May 15 to August 14.
Fall: August 15 to November 14.
Winter: November 15 to February 14.
Except that makes late August "fall", which (at least in my experience) makes no sense at all: it's often one of the hottest times of the summer. And late February ("spring"?) is often one of the coldest periods.
The Munchkin Formerly Known as Elfcrusher
Journey Computer | Combat Simulator | Bestiary | Weapon Calculator

Otaku-sempai
Posts: 3399
Joined: Sun May 12, 2013 2:45 am
Location: Lackawanna, NY

Re: Journeyometer 2: Rivendell is live!

Post by Otaku-sempai » Sat Jan 17, 2015 8:51 pm

Historically, the solstices were often considered to be mid-summer and mid-winter, so there is precedent. In any case, that has to be pretty close to how Tolkien was writing it.
"Far, far below the deepest delvings of the Dwarves, the world is gnawed by nameless things. Even Sauron knows them not. They are older than he."

User avatar
Falenthal
Posts: 2273
Joined: Sun Feb 02, 2014 8:46 am
Location: Girona (Spain)
Contact:

Re: Journeyometer 2: Rivendell is live!

Post by Falenthal » Sat Jan 17, 2015 8:53 pm

Just by looking at the Wikipedia should suffice, but I won't do it and will write how I consider the seasons :D :

Winter: 22 December - 21 March
Spring: 22 March - 21 June
Summer: 22 June - 21 September
Autum: 22 September - 21 December

EDIT: The wiki says lots of things, but this one might apply (or not) to Middle-Earth
On the Celtic calendar, the traditional first day of winter is 1 November (Samhain, the Celtic origin of Halloween); spring starts 1 February (Imbolc, the Celtic origin of Groundhog Day); summer begins 1 May (Beltane, the Celtic origin of May Day); the first day of autumn is 1 August (Celtic Lughnasadh). The Celtic dates corresponded to four Pagan agricultural festivals.
My own dates relate to this:
Currently, the most common equinox and solstice dates are March 20, June 21, September 22 or 23 and December 21;

Glorelendil
Posts: 5162
Joined: Mon Jan 13, 2014 5:20 pm

Re: Journeyometer 2: Rivendell is live!

Post by Glorelendil » Sat Jan 17, 2015 8:57 pm

Otaku-sempai wrote:Historically, the solstices were often considered to be mid-summer and mid-winter, so there is precedent. In any case, that has to be pretty close to how Tolkien was writing it.
Again, I don't think calendar seasons or even solstices really matter. It's the changing weather conditions that should matter, and weather changes lag behind astronomical changes. The shortest day of the year is neither coldest day (on average), nor the first day of the coldest 3 month period, in our world or (I assume) theirs.

I may be overthinking it, though, and perhaps for most people just doing it by solstices and equinoxes is good enough.

P.S. The other thing my sim does that most of us probably don't do when computing Journeys by hand is to look at each day individually when factoring in season. I suspect most of us either look at departure date, or perhaps when the bulk of the journey happens, and then just apply one season to the whole journey.
The Munchkin Formerly Known as Elfcrusher
Journey Computer | Combat Simulator | Bestiary | Weapon Calculator

User avatar
Falenthal
Posts: 2273
Joined: Sun Feb 02, 2014 8:46 am
Location: Girona (Spain)
Contact:

Re: Journeyometer 2: Rivendell is live!

Post by Falenthal » Sat Jan 17, 2015 9:00 pm

I'd like to relate it to the general temperatures.
In "my own Middle-Earth", winter begins the 22nd of December, not the 1st of November.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests