亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? randommapgenerator.java

?? good project for programmer,,
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
package com.sillysoft.lux;import com.sillysoft.lux.util.*;import java.util.*;import java.io.PrintWriter;import java.awt.geom.GeneralPath;import java.awt.geom.Point2D;import java.awt.geom.Line2D;import java.awt.geom.Rectangle2D;////  RandomMapGenerator.java//  Lux////  Copyright (c) 2002-2007 Sillysoft Games. //	http://sillysoft.net//	lux@sillysoft.net////	This source code is licensed free for non-profit purposes. //	For other uses please contact lux@sillysoft.net///**  RandomMapGenerator is an implementation of the MapGenerator interface.<br>	It is used to create the built-in random maps in Lux.<br>  <br>	Sometimes described as "potato blob" output. The general strategy is as follows:<br>	<br>		- Pick a width and height to use as the 2D field.<br>		- Pick a random point inside the field. This will serve as a centerpoint of a country.<br>		- Using polar co-ordinates, a randomly changing radius is drawn around the center to select the points that form into a country.<br>		-- Pick a point near outside of the country we just drew.<br>		-- Use this point as a centerpoint of another country. When a newly created point falls inside a previous shape move the point to follow outside the border of that country.<br>		-- Repeat picking nearby points and drawing countries for a while. This will form a continent of countries.<br>		- Then start fresh by picking a brand new point on the field. If inside another country pick again. Start a country around it and more countries near it. Repeat this a few times to grow some continents.<br>		<br>		- After the desired number of countries have been created then countries distance are compared. If they are close enough they connect.<br>		<br>		- More connections (along with lines indicating them) are then made over the board so that all the countries are connected.																								*/public class RandomMapGenerator implements LuxMapGenerator{private MapLoader loader;private Random rand;	// the random number generatorprivate int topx, topy;		// the maximum drawing bounds// These variables control how smooth the random shapes are.private int variance = 3; 					// The maximum distance away nearNumber() will returnprivate double fullCircle = 2*Math.PI;private double thetaStep = fullCircle/20; 	// The step size of the angleprivate int minRadius = 13; 					// the minimum the radius is allowed to be when drawing shapes// To encapsulate the getShpaeAround functions we store the array of shapes:private GeneralPath[] shapes;private Rectangle2D[] shapeBounds; // we keep a cache of the bounds of each shapeprivate int shapeCount;private Vector lines;	// the lines that the LuxView will have to drawprivate boolean[] connected;	// When making connections, we remember what is connected so farprivate int numCountries;private Country[] countries;private int[] contCodes;		// the continent code for each countryprivate int numContinents;private int[] contBonus;	// each continent has a bonus value associated with it// Because there doen't seem to be a way to get the actual points of an GeneralPath in java, we keep a vector of points for each shape. One Vector for each shape. They will be filled with Point2Ds.private Vector[] points;private Hashtable allPoints;	// the points are the keys, thenumber of shapes touching that point is the valueprivate int[][] distanceMemory;	// the closest distance between shapesprivate String boardSize;   // a value from the choices arrayprivate static List choices;public String name()	{	return "Random";	}public float version()	{	return 1.0f;	}public String description()	{	return "RandomMapGenerator is the class that Lux uses to generate the tiny-huge maps.";	}public List getChoices()	{	if (choices == null)		{		choices = new Vector();		choices.add("tiny");		choices.add("small");		choices.add("medium");		choices.add("large");		choices.add("huge");		}	return choices;	}public boolean generate(PrintWriter out, String choice, int seed, MapLoader loader)	{	this.loader = loader;	boardSize = choice;	rand = new Random(seed);	generateBoard();	this.loader = null;	return saveBoard(out, boardSize+" ID#"+seed);	}public boolean canCache()	{	return true;	}/**The main method that controls the generation of a map.Note that rand and boardSize must be set before this is called.		*/public void generateBoard()	{	//debug("Starting generateBoard. boardSize: "+boardSize);	/********************	To create a random board the following things must be done:		-> clear the CreateBoard and initialize vars		-> Determine the number of countries		and For each country:			-> Generate a shape			-> determine the adjoinging list			-> set the continent code		-> choose the bonus values for each continent		-> make any extra lines to connect countries	********************/	// The number of countries depend on the size of the board:	if ( boardSize.equals("tiny") )		{		numCountries = 6 + rand.nextInt(11); // 6 to 16		}	else if ( boardSize.equals("small") )		{		numCountries = 10 + rand.nextInt(11); // 10 to 20		}	else if ( boardSize.equals("large") )		{		numCountries = 20 + rand.nextInt(11); // 20 to 30		}	else if ( boardSize.equals("huge") )		{		numCountries = 30 + rand.nextInt(11); // 30 to 40		}	else		{	// it's medium (or undefined)		numCountries = 15 + rand.nextInt(11); // 15 to 25		}	initialize();	topx = getWidthForSize(boardSize);	topy = getHeightForSize(boardSize);	// Do the shapes now.	// Pick random points and draw shapes around them.	while (shapeCount < numCountries)		{		generateNugget();		}	// so all the shapes are picked. 	loader.setLoadText("adding easy connections");	// add connections between shapes that are very close together	connectShapesAt(5);	// this will cause them to be in the same continent	loader.setLoadText("choosing continent nuggets");	// The shapes have now been completed. Some close connection have been made.	// Here we expand those trees into continents.	// we mark the countries we have assigned to conts	contCodes = new int[numCountries];	connected = new boolean[numCountries];	//used to remember who has been given a continent (markConnectedFrom() and others use this array)	for (int i = 0; i < numCountries; i++) 		{		connected[i] = false;		contCodes[i] = -1;		}	// try and make continents have about this number of countries	int averageContinentCountries = 5;	numContinents = (int)Math.ceil((double)numCountries/(double)averageContinentCountries);	// NOTE: numContinents may become smaller, if we don't find that many nuggets	// the method: cycle through the countries and find the biggest tree without a cont code	// give that tree a continent code	// repeat till all countries have a cont code or we have chosen the desired number of conts	for (int nextContCode = 0; nextContCode < numContinents; nextContCode++)		{		int biggestTreeSize = 0;		int inBiggestTree = -1;		for (int i = 0; i < numCountries; i++) 			{			if (contCodes[i] == -1)				{				Vector tree = getTouching(i);				if (tree.size() > biggestTreeSize)					{					biggestTreeSize = tree.size();					inBiggestTree = i;					}				}			}		if (inBiggestTree != -1)			{// xxxx this would be the place to break up big continents into smaller ones...			// so mark the tree as the nugget to start this cont:			markConnectedFrom(inBiggestTree);			markContinentCodeFrom(inBiggestTree, nextContCode);			}		else			{			// then everything has been given a continent.			numContinents = nextContCode;	// this will break us out of thr for loop			}		}// Now numContinents is garanteed to be its final value.String currentLoadText = new String ("building up nuggets");loader.setLoadText(currentLoadText);// So now we have numContinents nuggets to build on.// cycle through the countries, making connections from unassigned countries, until everything has a continent.while ( ! isFullyConnected() ) // NOTE: the isFullyConnected() function just tests that everything has been marked as connected. the graph will not be fully connected when the while loop exits.	{	// pick a random country that still has no continent.	int from = rand.nextInt(numCountries);	while (contCodes[from] != -1)		from = (from+1) % numCountries;	// now connect it to the closest possible country.	int closestShape = -1;	int closestDistance = 1000000;	for (int j = 0; j < countries.length; j++)		{		if (from != j && ! countries[from].canGoto(j))			{			int distance = distanceBetween(from, j);			if (distance < closestDistance && lineCanExistBetween(from,j) )				{				closestDistance = distance;				closestShape = j;				}			}		}	if (closestShape != -1)		{		// then connect the unassigned country to it's closest neighbor		makeCountriesTouch(from, closestShape);		addLineBetweenShapes(from, closestShape);		// if we connected it to a shape with a contCode then we get that contCode too.		if (contCodes[closestShape] != -1)			{			markConnectedFrom(from);			markContinentCodeFrom(from, contCodes[closestShape]);			}		}	else		{		System.out.println("ERROR in RandomMapGenerator.generateBoard() -> (closestShape == -1) while building up nuggets");		System.out.println("	-> from = "+from);		// HACK: create a new continent with this shape...		markConnectedFrom(from);		markContinentCodeFrom(from, numContinents);		numContinents++;		}	currentLoadText = currentLoadText+".";	loader.setLoadText(currentLoadText);	}// good. the world is now fully divided into continents.// since the continents are now finalized we can create bonus values for them all// for now the bonus is just the # of countries in the cont.contBonus = new int[numContinents];for (int i = 0; i < numContinents; i++)	{	int size = BoardHelper.getContinentSize( i, countries );	contBonus[i] = size;	}currentLoadText = new String("fully connecting");loader.setLoadText(currentLoadText);// now the only thing left to do is ensure that the graph is fully connected.// we want to do it using the smallest possible connections.// first add all the tiny edges possible:connectShapesAt(12);// now the harder part:// we must clear the connected memoryfor (int i = 0; i < numCountries; i++)	connected[i] = false;markConnectedFrom(0);// first connect continents that are closeconnectContinentsAt(50);// Now we must fullt connect the graph.// Start by getting the connected graph from shape 0.Vector tree = getTouching(0);// And add non-reachable nodes until everything is connected...while (tree.size() < numCountries)	{	// In each iteration we should connect the closest shape that is not in <tree> to a shape in <tree>	int closestShapeFrom = -1, closestShapeTo = -1;	int closestDistance = 1000000;	for (int i = 0; i < tree.size(); i++)		{		int in = ((Country)tree.get(i)).getCode();		for (int out = 0; out < numCountries; out++)			{			if ( ! tree.contains( countries[out] ) )				{				// then consider connecting <out> to <in>				int dist = distanceBetween(in,out);				if (dist < closestDistance && lineCanExistBetween(in,out) )					{					closestDistance = dist;					closestShapeFrom = in;					closestShapeTo = out;					}				}			}		}	if (closestShapeFrom == -1)		{		// this should never happen...		System.out.println("ERROR in RandomMapGenerator.generateBoard() -> (closestShapeFrom == -1) while fully connecting");		break;	// the board won't be fully connected, but what else can we do?		}	else		{		makeCountriesTouch(closestShapeFrom, closestShapeTo);		addLineBetweenShapes(closestShapeFrom, closestShapeTo);		tree = getTouching(0);		// some user feedback		currentLoadText = currentLoadText+".";		loader.setLoadText(currentLoadText);		}	}	// now our graph is fully connected	// whew	// in order to make a more globe-like world we would also like to make a 	// connection crossing over the edges of the board	// (like the alaska-russia connection in Risk).	double lowWrapDistance = 1000000;	int lowShape = -1, highShape = -1;	for (int i = 0; i < numCountries; i++)		{		for (int j = 0; j < numCountries; j++)			{			double dist = wrappedDistance(i,j);			if (dist < lowWrapDistance)				{				lowWrapDistance = dist;				if (shapeBounds[i].getX() < shapeBounds[j].getX())					{					lowShape = i;					highShape = j;					}				else					{					lowShape = j;					highShape = i;					}				}			}		}	// Now we have the shapes to connect	makeCountriesTouch(lowShape, highShape);	// now we just have to find the shortest wrapped line and add it...	Point2D lowPoint = null, highPoint = null;	double smallestDist = 1000000;	for (int i = 0; i < points[lowShape].size(); i++)		for (int j = 0; j < points[highShape].size(); j++)			{			// pretend the low-shape is actually really high			Point2D mapHigherPoint = new Point2D.Double(((Point2D)points[lowShape].get(i)).getX()+topx, ((Point2D)points[lowShape].get(i)).getY());			double dist = mapHigherPoint.distance((Point2D)points[highShape].get(j));			if (dist < smallestDist)				{				smallestDist = dist;				lowPoint = (Point2D)points[lowShape].get(i);				highPoint = (Point2D)points[highShape].get(j);				}			}	// so we have the points, map them and add the lines...	Point2D mapHigherPoint = new Point2D.Double(lowPoint.getX()+topx, lowPoint.getY());	Point2D mapLowerPoint = new Point2D.Double(highPoint.getX()-topx, highPoint.getY());	lines.add( new Line2D.Float(highPoint, mapHigherPoint) );	lines.add( new Line2D.Float(mapLowerPoint, lowPoint) );	//report for testing purposes	//debug("GenReport -> size: "+boardSize+", numShapes: "+numCountries+", conts: "+numContinents);	}public static int getWidthForSize(String boardSize)	{	if ("tiny".equals(boardSize))		{		return 600;		}	else if ("small".equals(boardSize))		{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久www免费人成看片高清| 日韩黄色一级片| 日韩一区二区三区免费看 | 欧美性大战久久久| 99精品黄色片免费大全| 国产91精品入口| 成人黄色软件下载| 色综合久久久久久久| 一本一本大道香蕉久在线精品| 91影院在线观看| 欧美专区日韩专区| 欧美一区二区三区色| 日韩欧美国产午夜精品| 久久综合久久综合亚洲| 国产丝袜在线精品| 欧美国产乱子伦| 亚洲人成网站精品片在线观看| 中文字幕一区日韩精品欧美| 一区二区三区免费观看| 日日摸夜夜添夜夜添精品视频| 日本欧美一区二区在线观看| 极品少妇一区二区三区精品视频| 国产精品18久久久久久久久 | 这里只有精品电影| 亚洲精品在线电影| 中文字幕在线不卡一区| 亚洲激情av在线| 久久99精品久久只有精品| 国内外精品视频| 91丨九色丨蝌蚪丨老版| 91精品国产综合久久久久久漫画| 久久综合999| 一区二区三区中文在线| 日韩电影在线一区二区三区| 国产成人av在线影院| 欧美影视一区在线| 精品国产凹凸成av人导航| 亚洲男同1069视频| 久久av中文字幕片| 91丨九色丨黑人外教| 亚洲成a人片在线观看中文| 国内久久婷婷综合| 欧美日韩aaa| 综合分类小说区另类春色亚洲小说欧美| 一区二区三区在线免费观看| 久久久久久久久97黄色工厂| 亚洲欧洲中文日韩久久av乱码| 亚洲精品国产第一综合99久久| 蜜桃av噜噜一区二区三区小说| 99在线精品观看| 久久午夜电影网| 亚洲h动漫在线| 成人免费视频国产在线观看| 日韩亚洲欧美一区| 亚洲精品福利视频网站| 成人午夜电影小说| 久久中文娱乐网| 麻豆精品一二三| 欧美挠脚心视频网站| 日韩一区中文字幕| 国产专区欧美精品| 欧美日韩一级片网站| 自拍偷自拍亚洲精品播放| 国产一区在线精品| 欧美电影精品一区二区| 亚洲已满18点击进入久久| 国产精品色哟哟| 国产在线国偷精品产拍免费yy | 日韩av一区二区在线影视| 一本久道中文字幕精品亚洲嫩| 国产人成一区二区三区影院| 精品一二三四区| 欧美成人精品高清在线播放 | 国产亚洲精品中文字幕| 国产主播一区二区| 国产欧美一区二区精品性| 国产很黄免费观看久久| 久久久久久久久久电影| 风间由美中文字幕在线看视频国产欧美| 三级欧美韩日大片在线看| 91极品美女在线| 亚洲欧美电影院| 99re免费视频精品全部| 最新成人av在线| 91福利精品视频| 亚洲高清一区二区三区| 欧美日韩成人综合| 婷婷中文字幕综合| 日韩欧美精品在线| 国产在线精品一区二区| 国产精品久久久久久一区二区三区 | 国产一二三精品| 精品亚洲成av人在线观看| 欧美一区二区视频网站| 久久精品国产色蜜蜜麻豆| 久久精品视频免费| 成人性色生活片免费看爆迷你毛片| 国产精品久久久久婷婷| 欧美日韩国产一二三| 精品一区二区久久久| 久久久久久久久久久久久女国产乱| 国产福利电影一区二区三区| 国产精品成人网| 欧美另类一区二区三区| 黑人巨大精品欧美一区| 亚洲色图色小说| 免费高清在线视频一区·| 日韩精品专区在线| 99久久伊人精品| 视频在线观看一区二区三区| 久久久久国色av免费看影院| 97超碰欧美中文字幕| 三级久久三级久久久| 日韩精品一区国产麻豆| 国产成a人亚洲精品| 亚洲国产毛片aaaaa无费看| 亚洲精品一区二区三区四区高清| 91免费在线视频观看| 秋霞电影网一区二区| 亚洲欧美一区二区三区久本道91| 免费成人深夜小野草| 亚洲私人影院在线观看| 日韩欧美国产不卡| 97久久精品人人做人人爽50路| 日韩精品五月天| 亚洲免费在线电影| 久久在线免费观看| 欧美视频精品在线观看| av一二三不卡影片| 久久成人免费电影| 亚洲图片自拍偷拍| 亚洲图片你懂的| 国产农村妇女毛片精品久久麻豆| 欧美精品久久久久久久多人混战| 亚洲欧洲无码一区二区三区| 日韩一级黄色片| 欧美日韩一区二区三区四区五区| 成人网页在线观看| 国产精品系列在线播放| 美日韩一区二区三区| 亚洲制服欧美中文字幕中文字幕| 国产欧美日韩久久| 久久人人爽爽爽人久久久| 制服.丝袜.亚洲.另类.中文| 欧美高清你懂得| 欧美影院精品一区| 欧美在线观看一区| 欧美色图免费看| 欧美性色综合网| 亚洲一二三四区不卡| 伊人开心综合网| 亚洲九九爱视频| 一区二区三区免费在线观看| 亚洲素人一区二区| 亚洲精品成a人| 亚洲成人7777| 日韩av在线播放中文字幕| 欧美aⅴ一区二区三区视频| 日本成人在线电影网| 日本视频免费一区| 久久成人综合网| 国产在线精品一区二区夜色| 国产高清亚洲一区| 久久成人免费网| 国产98色在线|日韩| 99久久精品久久久久久清纯| 91亚洲资源网| 欧美精选一区二区| 日韩精品一区二区三区在线观看 | 欧美在线免费播放| 欧美色精品在线视频| 欧美一区二区不卡视频| 久久先锋影音av| 亚洲精品国产精华液| 蜜桃av一区二区三区| 国产sm精品调教视频网站| 99国产精品久久久久久久久久久| 色综合天天综合给合国产| 日本精品视频一区二区| 91精品国产福利| 国产欧美综合在线观看第十页| 亚洲欧美在线视频观看| 丝袜美腿高跟呻吟高潮一区| 国产精品一卡二| 欧美在线不卡一区| 欧美精品一区二区在线播放| 亚洲欧洲在线观看av| 视频一区免费在线观看| 春色校园综合激情亚洲| 欧美日韩午夜精品| 久久久久99精品一区| 亚洲国产乱码最新视频 | 中文字幕综合网| 婷婷成人激情在线网| 国产剧情在线观看一区二区| 色天使久久综合网天天| 久久综合色婷婷| 午夜国产精品影院在线观看| 国产白丝精品91爽爽久久| 欧美日韩国产天堂|