Okay:
Open-source approach front and center, I suppose. Here's the beginnings of the code for the social model. Feel free to use this/change this/slam this/all of the above. This is just version .00001! I am not a genius. I need your help to do this right. I'm very sure I've missed a few of the changes that have been discussed over the last few days -- feel free to point out loudly whenever my natural ignorance leaked thru.
You can get all the source for both models I'm working on at http://home.austin.rr.com/lostmerchant/Clash/source/.
Code:
*******************************************
import java.util.*;
public interface Culture
{
public void addTrait(Policy p);
public Policy getTrait(String t);
public Enumeration getAllTraits();
}
*******************************************
import java.util.*;
public class PopularCulture implements Culture
{
private String name;
private Vector traits;
public PopularCulture(String n)
{
name = n;
traits = new Vector();
}
public void addTrait(Policy p)
{
traits.addElement(p);
}
public Policy getTrait(String t)
{
Enumeration enum = traits.elements();
while(enum.hasMoreElements())
{
Policy trait = (Policy)enum.nextElement();
if(trait.equals(t))
{
return trait;
}
}
return null;
}
public Enumeration getAllTraits()
{
return traits.elements();
}
}
***************************************
/**
* This data structure could be a simple HashMap instead, but making it an object
* leaves room for further enhancement of the 'values' or implementations
* of a 'policy' beyond a single integer.
*
* @author The gang
* @version .00001
* @since Jun 2000
*/
public class Policy
{
private String name;
private int value;
public Policy(String n)
{
name = n;
}
public Policy(String key, int value)
{
name = key;
setValue(value);
}
public void setValue(int v)
{
value = v;
}
public int getValue()
{
return value;
}
public boolean equals(Object o)
{
return o.equals(name);
}
}
*****************************************
import java.util.*;
public interface Religion
{
public void addReligousDoctrine(Policy p);
public void addReligousDoctrine(String key, int value);
public Policy getReligousDoctrine(String p);
public Enumeration getAllDoctrines();
}
****************************************
import java.util.*;
public class PrimitiveReligion implements Religion, Culture
{
private String name;
private Vector doctrines;
private Vector traits;
public PrimitiveReligion(String n)
{
name = n;
doctrines = new Vector();
traits = new Vector();
}
public void addReligousDoctrine(Policy p)
{
doctrines.removeElement(p);
doctrines.addElement(p);
}
public void addReligousDoctrine(String key, int value)
{
doctrines.removeElement(key);
doctrines.addElement(new Policy(key, value));
}
public Policy getReligousDoctrine(String p)
{
Enumeration enum = doctrines.elements();
while(enum.hasMoreElements())
{
Policy pol = (Policy)enum.nextElement();
if(pol.equals(p))
return pol;
}
return null;
}
public Enumeration getAllDoctrines()
{
return doctrines.elements();
}
public void addTrait(Policy p)
{
traits.removeElement(p);
traits.addElement(p);
}
public Policy getTrait(String t)
{
Enumeration enum = traits.elements();
while(enum.hasMoreElements())
{
Policy p = (Policy)enum.nextElement();
if(p.equals(t))
return p;
}
return null;
}
public Enumeration getAllTraits()
{
return traits.elements();
}
public String toString()
{
return name;
}
}
*******************************************
public class GreatWorldReligion extends PrimitiveReligion
{
private int counter;
private MapSquare holy_land;
public GreatWorldReligion(String n)
{
super(n);
}
public void setHolyLand(MapSquare h)
{
holy_land = h;
}
public MapSquare getHolyLand()
{
return holy_land;
}
}
Now unless I've completely missed my boat, we will have 'EthnicGroups' that will hold a pop number, EG name, Religion object, Culture object, 'TendencyValues' object, and one other grouping of related vars. Each 'MapSquare' will have a collection of 'EthnicGroup' objects.
And there is still more to add to 'EthnicGroups', I should think. 'SocialClasses', for one. But that's for another post, since I didn't see a consensus on how social classes will work out (did I miss it? Please help!) . . .
P.S.-- feel free to mentally (or otherwise) switch the simple Vectors to better, Java2 collections. I'm trying to keep this Java 1.x for now, so I can post demos at a website that will work in IE5.
For now, anyway.
[This message has been edited by F_Smith (edited July 08, 2000).]
Bookmarks