The present turn management system just sort of evolved.
Essentially, the latest version works as follows:
1. Scan the list of units and make moves and resolve combat. [Scans the unit list]
2. Do all the economics calculations, these cover production, trade and government orders (that I know of). The social model used to be resolved here, it is currently partially inactivated. [Scans the map squares and also the civilizations]
3. Production. This is entirely road building at present. [Scans the civilizations]
4. Population increase. [Scans the map squares]
5. Check end of game.
There are some changes to this that I would propose. I would like to resolve matters at the level that is required, rather than in an arbitrary order.
We have three "scan levels". The units are scanned. This is outside the normal scanning mechanism - a complete list of units is maintained, and the units moved, more or less in order of age, until there is a conflict. There is a small possibility of an incorrect result here - if a unit is moving from square 1 to square 2 to square 3, and an enemy unit is moving from square 3 to square 2 to square 1, the possible conflict will be detected (and dealt with) at the square 2/3 boundary. If the second unit is faster, the conflict may have been more correctly resolved at the square 1/2 boundary. However, when the first unit is moved, the code doesn't know about the other unit, until the conflict happens, so it might get it wrong. Fixing this is on the list in place 1328.
The second scan level is the individual squares. This is required for population growth and for resource production, and perhaps trade.
The third level is the civilization scan, where things are done per civilization. This covers the whole social model and some economic decisions, as well as the AI.
As a policy, I prefer to put loops in positions where the code knows what it is looping over, rather than passing mysterious iterators around the place. There are a variety of advantages to this - it reduces dependencies (my battlecry!), and means that many changes are restricted to a single java file.
For example, at present the civilization iterator is called (from whereever) to get the list of civilizations, then a specific method called on each of them. It is my view that the iteration should be done in a loop in a static method in the civilization file.
The system I would propose is as follows:
1. Military phase Scan the list of units and make moves and resolve combat. [Scans the unit list] Unchanged.
2. End of game phase Check end of game. Can only happen as a result of military action anyway.
3. Square phase Scan the squares (once only), do the resource production, the population feeding, and the population growth, and store any surplus resources for action by the owning civilization. Trade may be dealt with at this point also. Infrastructure will be stored at the square level and checked here.
4. Civilization phase Scan the civilization list. For each civilization perform the following:
4.1 Province phase Scan at the province level:
4.1.1 Grab any taxes.
4.1.2 Perform any government purchases.
4.1.3 Assess the social aspects of the province (storing some results at the government level).
4.1.4 Implement any riot events.
4.2 Government phase Perform government level actions:
4.2.1 Build roads
4.2.2 Implement any government level social events (such as assassinating the ruler).
4.2.3 Interactive phase Make decisions relating to social matters, purchase or other economic decisions, military decisions.
The interactive phase, for the human player, is section 4.2.3. For computer controlled civilizations, these decisions will be made by the AI before the interactive phase begins.
I rather think that the only changes of any significance will be in storing resources for use later in the same move, but Mark will have a better idea of this than I. The advantage of that is it clearly separates the production aspect from the use aspect.
Cheers
Essentially, the latest version works as follows:
1. Scan the list of units and make moves and resolve combat. [Scans the unit list]
2. Do all the economics calculations, these cover production, trade and government orders (that I know of). The social model used to be resolved here, it is currently partially inactivated. [Scans the map squares and also the civilizations]
3. Production. This is entirely road building at present. [Scans the civilizations]
4. Population increase. [Scans the map squares]
5. Check end of game.
There are some changes to this that I would propose. I would like to resolve matters at the level that is required, rather than in an arbitrary order.
We have three "scan levels". The units are scanned. This is outside the normal scanning mechanism - a complete list of units is maintained, and the units moved, more or less in order of age, until there is a conflict. There is a small possibility of an incorrect result here - if a unit is moving from square 1 to square 2 to square 3, and an enemy unit is moving from square 3 to square 2 to square 1, the possible conflict will be detected (and dealt with) at the square 2/3 boundary. If the second unit is faster, the conflict may have been more correctly resolved at the square 1/2 boundary. However, when the first unit is moved, the code doesn't know about the other unit, until the conflict happens, so it might get it wrong. Fixing this is on the list in place 1328.
The second scan level is the individual squares. This is required for population growth and for resource production, and perhaps trade.
The third level is the civilization scan, where things are done per civilization. This covers the whole social model and some economic decisions, as well as the AI.
As a policy, I prefer to put loops in positions where the code knows what it is looping over, rather than passing mysterious iterators around the place. There are a variety of advantages to this - it reduces dependencies (my battlecry!), and means that many changes are restricted to a single java file.
For example, at present the civilization iterator is called (from whereever) to get the list of civilizations, then a specific method called on each of them. It is my view that the iteration should be done in a loop in a static method in the civilization file.
The system I would propose is as follows:
1. Military phase Scan the list of units and make moves and resolve combat. [Scans the unit list] Unchanged.
2. End of game phase Check end of game. Can only happen as a result of military action anyway.
3. Square phase Scan the squares (once only), do the resource production, the population feeding, and the population growth, and store any surplus resources for action by the owning civilization. Trade may be dealt with at this point also. Infrastructure will be stored at the square level and checked here.
4. Civilization phase Scan the civilization list. For each civilization perform the following:
4.1 Province phase Scan at the province level:
4.1.1 Grab any taxes.
4.1.2 Perform any government purchases.
4.1.3 Assess the social aspects of the province (storing some results at the government level).
4.1.4 Implement any riot events.
4.2 Government phase Perform government level actions:
4.2.1 Build roads
4.2.2 Implement any government level social events (such as assassinating the ruler).
4.2.3 Interactive phase Make decisions relating to social matters, purchase or other economic decisions, military decisions.
The interactive phase, for the human player, is section 4.2.3. For computer controlled civilizations, these decisions will be made by the AI before the interactive phase begins.
I rather think that the only changes of any significance will be in storing resources for use later in the same move, but Mark will have a better idea of this than I. The advantage of that is it clearly separates the production aspect from the use aspect.
Cheers
Comment