#Function to start computation
function begin()
	if(saved state does not exist):
		saved = false;
		create new state;
	else:
		load saved state
	
	clean skiier's stats
	weekweather = weather(current interation) + randomGaussianNum/6
	
	while(weekweather > 1):
		weekweather = weather(current interation) + randomGaussianNum/6
	end while
	runSimulation()
	
	
#Function to simulate the week in park
function runSimulation()
	for(i:number of week):
		for(j:number of skiiers):
			x = get Individual(j);
			if(i<(x.IQ+1)) //If number of week is less then individual's IQ+1
				boolean individual went = random boolean;
				save boolean to List went;
			else if(i>(x.IQ+1)):
				boolean individual went = decision();
				save boolean to List went;
		end for
		global()
		#Function to update park success and weekly weather
		function globals()
			while(weekweather > 1): //update weather
				weather(current interation) + randomGaussianNum/6; 
			end while
			
			for(i:numberofskiiers)
				if Individual i went, increment counter of # of ppl going (double went)
			end for
		park success of current week = went / numberofskiiers;
		end globals
		
		skiiers()
		#Function to update skiier's stats
		function skiiers()
			if(park success > gamepercent && if the individual went 
		       || parksuccess < gamepercent ** if the individual did not go
				update individual's week success to false;
			else
				update individual's week success to true;
			
			add individual's current experience to the total indivual's experience
		end skiiers
		
	end for
	Update the graphical outputs
	Increment the current iteration to prepare for the next iteration
	Update the computed skiier's success

	
#Function to compute the decision of Individual
function decision()
	ff = friendfactor();
	
	#Function to compute friend factor
	function friendfactor()
		for(i:numberoffriends):
			friendfactor += i's (a friend's) experience; //if experience is availiable
		end for
	return friendfactor/2;
	end friendfactor
	
	weather = saved weather - current weather factor + 1;
	decisionpercent = getDecisionPercent //Set boundary limit value from GUI
	strategy = strategy();
	
	#Function to compute strategy()
	function strategy()
		decision[0] = if individiual's last week was successful then do what he did last week
					or if it wasn't, do the opposite
		if individual IQ == 1
			return decision[0];
		decision[1] = if individual went less then 2 times (in 3 weeks)
					  && (He didn't go two weeks in a row || last week was a park success)
					  && (Park success 2 weeks was higher then last week)
		
		if individual IQ == 2
			return decision[1];
			
		numberofpeoplegoing = (if decision[1] add population else add 1-population) + RandomGaussian*.33;
		difference = gamepercentage (from GUI) - numberofpeoplegoing
		if the difference is > .333
			decision[2] = true;
		else if difference is less then 0
			decision[2] = false;
		else if difference is more then (.1666) //.3333/2
			percentage = difference/.333 (1/3 of population)
			decision[2] = random Double;
		else
			percentage = difference/.333 (1/3 of population)
			decision[2] = random Double;
		
		return decision[2];
		end strategy
	
	decisionpercent*strategy + (1-decisionpercent)*.25*(ff+weather+1.25(individual.skill_level+individual.experience))
	return decision>.5

end decision
	
	
	
	
	
	
	