📄 golconst.java
字号:
package GameOfLife;
public class GoLconst
{
//Public constants
public static String PROGRAM_VERSION = "2.3 ARR";
public static String PROGRAM_RELEASE_DATE = "28 Aug 2003";
/***Grid control variables***/
public static int GRID_COLUMNS = 50;
public static int GRID_ROWS = 30;
public static int GRID_CELLSIZE = 15;
//time-interval between generations
public static int GRID_REFRESH_SLOW = 1500;
public static int GRID_REFRESH_FAST = 500;
public static int GRID_REFRESH_HYPER = 5;
/***Variables determining properties for Grid coordinates***/
public static boolean GRID_COORD_SHOW = true;
//0->all cells, 1->last row&col, 2->last col, 3->last row, 4->last cell
public static int GRID_COORD_DETAIL = 1;
public static String GRID_COORD_COLOR = "blue"; //blue,black,red,green
/***Text display & command area***/
public static int TEXTAREA_HEIGHT = 10;
/***Population & Citizen-level control variables***/
//density of population used in the Random & Sugarscape template
public static double DENSITY_FACTOR = 0.6;
// maximum vision level for a citizen
public static int VISION_MAX = 4;
// maximum metabolism level for a citizen
public static int METABOLISM_MAX = 4;
// max "initial" qty of sugar inherited by a citizen - may gather more later.
public static int SUGAR_MAX_CITIZEN = 10;
//maximum "initial" qty of sugar in a cell, may exceed this limit later
public static int SUGAR_MAX_CELL = 10;
//Grid fertility - how generous a distribution do you want to start with
public static double GRID_FERTILITY = .80; //Any value between 0.0 & 1.0
// unit increase in amt of sugar per generation
public static double SUGAR_RENEW = 0.2;
//Carrying capacity
public static boolean LIMIT_CELL_SUGAR = true;
/* debug mode - do you want it on or off?
/ The first flag switches on all debugging, leave it Off if you want debug info
/ for a specific section of code. Use one of the other more specific debug
/ switches to debug a particular section of code.
/ Enabling the DEBUG switch will render some of the other debugging switches
/ ineffective. The switches listed above the DEBUG switch are turned On but
/ not Off with the DEBUG switch.
*/
public static boolean DEBUG_CRITICAL_ERROR = true;
public static boolean DEBUG = false;
public static boolean DEBUG_PROGRAM_FLOW = false;
public static boolean DEBUG_CREATE_CITIZEN = false;
public static boolean DEBUG_CITIZEN_DEATH = false;
public static boolean DEBUG_SEARCH_SUGAR = false;
public static boolean DEBUG_CELLSCAPE_SUGAR = false;
public static boolean DEBUG_CITIZEN_DETAIL = false;
public static boolean flagSugarscape;
public static String chkGoLconstants()
{ //Boolean Variables don't require checking as non-boolean values
//Would Cause a Compilation error
String dataStream = "\n";
//Defines if & what form grid coordinates are to be displayed
if( GRID_COORD_DETAIL < 0 || GRID_COORD_DETAIL > 5)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream +=
"GRID_COORD_DETAIL:Invalid value, assuming 1!!\n"; }
GRID_COORD_DETAIL = 1;
}
if( !(GRID_COORD_COLOR == "blue" || GRID_COORD_COLOR == "black" ||
GRID_COORD_COLOR == "red" || GRID_COORD_COLOR == "green") )
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "GRID_COORD_COLOR:Invalid value, assuming blue!!\n"; }
GRID_COORD_COLOR = "blue";
}
if( DENSITY_FACTOR > 1 || DENSITY_FACTOR < 0)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "DENSITY_FACTOR:Invalid value, assuming 0.5!!\n"; }
DENSITY_FACTOR = 0.5;
}
if( VISION_MAX <= 0 )
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "VISION_MAX:Invalid value, assuming 4!!\n"; }
VISION_MAX = 4;
}
if( METABOLISM_MAX < 0 )
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "METABOLISM_MAX:Invalid value, assuming 4!!\n"; }
METABOLISM_MAX = 4;
}
if( SUGAR_MAX_CITIZEN < 0)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "SUGAR_MAX_CITIZEN:Invalid value, assuming 10!!\n"; }
SUGAR_MAX_CITIZEN = 10;
}
if( SUGAR_MAX_CELL < 0)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "SUGAR_MAX_CELL:Invalid value, assuming 10!!\n"; }
SUGAR_MAX_CELL = 10;
}
if( GRID_FERTILITY > 1 || GRID_FERTILITY < 0)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "GRID_FERTILITY:Invalid value, assuming 0.5!!\n"; }
DENSITY_FACTOR = 0.5;
}
if( SUGAR_RENEW > SUGAR_MAX_CELL || SUGAR_RENEW < 0)
{ if( DEBUG_CRITICAL_ERROR || DEBUG )
{ dataStream += "SUGAR_RENEW:Invalid value, assuming 0.1!!\n"; }
SUGAR_RENEW = 0.1;
}
return dataStream;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -