Jump to content
XCOMUFO & Xenocide

Research


Beetle

Recommended Posts

Hi

 

I know that this topic was already discussed, but i'm still don't know how to implement that.

 

In example :)

If two bases are researching the same project, should it be treated like one big project, or maybe two different? There is also possibility two treat it like one project, but give some penalty in research points ???

 

Anybody knows how was it implemented in xcom: EU ?

Link to comment
Share on other sites

in xcom:eu it was absolutely independent, in a stupid kind of way:

if you researched for example plasma rifle in two bases at the same time, the first to finish the research gives you the ufopedia entry (in exactly the same time it would take if the second base would not research it at all).

the second base then still needs to finish the research, or leave it in the active research topic list by removing all scientists from the project. when the second base finishes the project, nothing happens.

Link to comment
Share on other sites

If two bases are researching the same project, should it be treated like one big project, or maybe two different? There is also possibility two treat it like one project, but give  some penalty in research points ???

I think, we should make it better then xcom:eu and treat it as a big project, but, like you don't double processing power when using two CPUs, give a penalty in research time. Like, with 20 Scientists at one base, it would take 100 days to research, with 40 scientists at one base it takes 50 days, and with 20 at one and another 20 scientists at another base, it takes 60 days...

Link to comment
Share on other sites

so basically you would have the "research project" called "support base xy's research of xyz", adding something like 50-75% of the local research power to that project? sounds nice, but what about research projects that need items, like alien weapons? should that then only be possible when the second base has the item too, or do we assume that the second base is assigned stuff that is item-independent? perhaps then resulting in an additional penalty?

 

now don't get me wrong, I really like the idea and would like to see it implemented, but it sounds like V1+, because a lot of consideration (and code) will have to go into this.

Link to comment
Share on other sites

so basically you would have the "research project" called "support base xy's research of  xyz", adding something like 50-75% of the local research power to that project? sounds nice, but what about research projects that need items, like alien weapons? should that then only be possible when the second base has the item too, or do we assume that the second base is assigned stuff that is item-independent? perhaps then resulting in an additional penalty?

No, I think if the second base wants to research it, they should as well have it at the base. How you call it makes no difference. Either you let them research it as normal item, just as it was in xcom:ue and they share the researches automaticly, or you add an extra button in the first reserching base which says sth like: support research, bringing up a dialog where you can choose to transfer the items necessary and automaticly start research at a second base...

 

now don't get me wrong, I really like the idea and would like to see it implemented, but it sounds like V1+, because a lot of consideration (and code) will have to go into this.

I don't think it will be this complicated, and it doesn'T change gameplay at all, so why not make it a v1 feature?

Link to comment
Share on other sites

Ok i will make it all projects global. About penalty for "multi base" researching is very easy from programming point., so i leave this topic to discuss here :)

 

Personnaly i like very much idea suggested by Mad

 

Beetle

Link to comment
Share on other sites

Ok i will make it all projects global. About penalty for "multi base" researching is very easy from programming point., so i leave this topic to discuss here :)

 

Personnaly i like very much idea suggested by Mad

 

Beetle

I like it too, and it sounds logical, it's not the same 40 scientists working on a single lab or two labs in the same base than 40 scientists working on two labs in two different bases in possibily two different continents, there has to be some sort of penalty for that.

Link to comment
Share on other sites

Sirs,

 

If this recruit may be permitted to make a suggestion, this recruit would like to expand on Max's idea. If you have multiple bases working on a project, then EACH base recieves a cumulative penalty proportional to the number of additional bases working on the project.

e.g. Efficiency = 100% - ((20% * number of bases researching) - 1)

(20% is just a suggested value.)

 

The loss of efficiency is caused by the need to communicate with the other bases.

At any rate, this means (assuming that each base has 10 scientists)

1 base = 10 points research per hour.

2 bases = 16 points per hour

3 bases = 18 points

4 bases = 8 points

5 bases = 0 points

 

This recruit would suggest, that to keep the research dialog simple, if a user goes and sets a base to research a topic that an another base is already researching then the user should receive a caution that this will reduce efficiency.

Link to comment
Share on other sites

dteviot - you propose a peak in efficiency with three bases?

 

I would think that increased locations would only cause a minor reduction in efficiency, maybe 10% or so, as I cannot see much being lost in communication - come on, the internet and telephones can be used ;)

Link to comment
Share on other sites

dteviot - you propose a peak in efficiency with three bases?

 

I would think that increased locations would only cause a minor reduction in efficiency, maybe 10% or so, as I cannot see much being lost in communication - come on, the internet and telephones can be used ;)

Those scientists with their MSNs... :laugh:

Link to comment
Share on other sites

There will be as many opinions as there are  scientists.

That could happen with all the scientists in the same base, it'd mean we'd have to use a similar penalty for large numbers of scientists in the same base as well.

I believe having a progressive penalty would be best, but never reducing the overall research effectiveness, just reducing that of any additional bases.

Link to comment
Share on other sites

Scientist on one base have a project leader, who coordinates his underlings, so no effectiveness degradation emerges.

Then according to what you posted, how would there be as many opinions as scientists?

 

The point is that, as you said now, there will be a leader of some sorts on each base. The reduction of efficiency is due to the fact that the scientists, not working on the same physical space, are not as "comfortable" as they would be working all on the same lab.

Link to comment
Share on other sites

dteviot - you propose a peak in efficiency with three bases?

 

I would think that increased locations would only cause a minor reduction in efficiency, maybe 10% or so, as I cannot see much being lost in communication - come on, the internet and telephones can be used ;)

 

The peak at 3 bases is an artifact of a 20% degredation rate. If you chose 10%, then the peak would be at 5 bases.

1 base = 10,

2 base = 18

3 base = 24

4 base = 28

5 base = 30

 

However, the main point this recruit was trying to make was that when having a "multibase" research project, rather than having one base at 100% efficiency, and the next base at 70% say, all bases involved in the project suffer a cost. This recruit suggested that the penalty increased with number of bases but it could simply be fixed.

 

Incidentally, as Fred Brooks (in Mythical Man Month has observed) the more people you add to a project, the worse your efficiency gets. Which would probably apply even to the case of multiple labs in one base. Consider, for example, two labs both doing an autopsy of a Grey corpse. There would probably be a considerable amount of duplicated discoveries.

Link to comment
Share on other sites

They will probably cut a leg away and carry it into second lab to study :).

 

Then according to what you posted, how would there be as many opinions as scientists?

 

The leader just enforces his (or accepted) opinion. If there is many leaders, they will have to coordinate between each other.

 

Edit:

I mean, scientists, given half a chance to throw a party, er.. a conference, will never stop at their own will. I know :).

Edited by UnFleshed One
Link to comment
Share on other sites

They will probably cut a leg away and carry it into second lab to study :).

 

Then according to what you posted, how would there be as many opinions as scientists?

 

The leader just enforces his (or accepted) opinion. If there is many leaders, they will have to coordinate between each other.

 

Edit:

I mean, scientists, given half a chance to throw a party, er.. a conference, will never stop at their own will. I know :).

Here is the situation as this recruit understands it:

1) There is general agreement that multiple bases should be able to contribute to a research project.

2) There is general agreement that in this case, progress will not be as efficient as if an equal number of scientists were working on the project at a single base.

3) Mad has suggested that in a multiple base situation, the first base continues to run at 100% efficiency, and later bases run at a reduced efficiency.

This recruit suggests it would be simpler (both for programming, and for user understanding) to apply a single efficiency modifer to all bases. For example, consider the case where bases have different numbers of scientists (and labs.) In the case of variable efficiency, users would wish the "larger" lab to be the "primary" lab running at 100%. How would this be achieved? Especially if the smaller base started on the project first (because the larger base was already busy when the research project became available.)

4) This recruit has also suggested that adding each additional base to a research base would produce smaller incremental gains in total output. This recruit believes this would add additional challenge/interest in research. However, spending a large amount of time arguing this point is probably counterproductive. As the amount of work required to implement is one line of code (assuming the penalty is applied equally to all bases.) This recruit would suggest just implementing it, and if it proves unsatisfactory gameplay, it be removed. Alternatively, it could be keyed into the game's difficulty factor.

Link to comment
Share on other sites

In the case of variable efficiency, users would wish the "larger" lab to be the "primary" lab running at 100%. How would this be achieved? Especially if the smaller base started on the project first (because the larger base was already busy when the research project became available.)

 

Either let the game decide which lab will be headquarters (the one that will give best output to whole enterprise). Or let the gamer do it.

 

Or both.

 

Edit:

And make some penalty for changing lead lab. Like a couple hours to a day of reduced efficiency, so player will have to do some trade-offs in cases as that one above.

Edited by UnFleshed One
Link to comment
Share on other sites

Edit:

And make some penalty for changing lead lab. Like a couple hours to a day of reduced efficiency, so player will have to do some trade-offs in cases as that one above.

 

I don't like that idea. I think it's unnecesary micro-management from player side. I think all should be made automaticly and player should be only informed that he or she is loosing man hours becouse of multiple bases reasearch.

Link to comment
Share on other sites

Edit:

And make some penalty for changing lead lab. Like a couple hours to a day of reduced efficiency, so player will have to do some trade-offs in cases as that one above.

 

I don't like that idea. I think it's unnecesary micro-management from player side. I think all should be made automaticly and player should be only informed that he or she is loosing man hours becouse of multiple bases reasearch.

I agree, I think we are going into V1+ issues. IMO the simplest and most logical thing to do is reduced efficiency per added base (first base has 100% efficiency, second base 80%, third base has 60%, etc.), but even that is more or less optional :)

Link to comment
Share on other sites

Interesting discussion, but go with the simplier approach (from the programming side, make scientists individuals so we can extend further the system later).

 

Greetings

Red Knight

 

Yeap according to ours previous dissusion scientists are already implemented as inviduals :)

Link to comment
Share on other sites

Interesting discussion, but go with the simplier approach (from the programming side, make scientists individuals so we can extend further the system later).

 

Greetings

Red Knight

 

Yeap according to ours previous dissusion scientists are already implemented as inviduals :)

Are you referring to this thread? http://www.xcomufo.com/forums/index.php?sh...298&hl=research

If not, can you point me at the correct one?

 

Thanks.

Link to comment
Share on other sites

Yes, exactly. This dissusion was on icq or msn (don't remember now) and it's decisons made that topic (recalled by UnFleshed One in previous repley)

 

edit: but i'n fact this means that we can implement even very sophisticated algorithms with easy here :)

Edited by Beetle
Link to comment
Share on other sites

Hi Guys,

 

Looking at this stuff, I’ve got a suggestion that I think will save a reasonable amount of work. Specifically, you have the engineer and scientist classes derive from personnel. However, I believe they’re really almost exactly the same thing.

 

Look at the code:

class Scientist : Personnel
{
 LabStatistics stats { get; }
 AssignedResearch { assign, unassign }

 Research ( Technology tech ) // Triggered once per day.
}

class Engineer : Personnel
{
 WorkshopStatistics stats { get; }
 AssignedProject { assign, unassign }

 Construct ( Project project ); // Triggered once per day.
}

 

So, they should either:

(a) Inherit from a common base class, say “worker”, or

(B) Just have a worker class, with instances having either the skill “construct” or “research”

 

 

To explain in more detail:

As I understand it, this is the conceptual use case of a “ResearchProject”:

1) Player opens the research dialog and is presented with a list of topics that can be researched.

2) Player picks a topic, creates a Project, and assigns scientists to it. (How the player picks the scientists is unclear to me: Possibly as individuals, by lab, by base, whatever.)

3) Now at regular intervals (e.g. once every game hour or day) a “ResearchProjectsManager” (for want of a better name) goes through the list of Research projects. For each project it iterates through the scientists assigned to it, asking them “How much have you contributed to the project?” and adding their output to the cumulative contributions for the project.

4) When the cumulative contributions exceed the “Cost” of the project, it’s completed and the player gets a “reward.” The ability to build or use a weapon, or research another technology, or whatever.

 

To my mind, this looks essentially the same story as for engineers engaged in constructing something. The only really different bits are:

1) How to determine which items can be researched/constructed.

2) What workers can be involved on a project.

3) What to do with the reward. (Constructed objects must be put somewhere when done.)

 

And this just screams inheritance to me (at least in terms of project types.).

 

Incidentally, as regards the worker/engineer/scientist classes.

Personally, I prefer a worker class with skill, because it allows the future possibility of personnel having multiple skills, so they might do some jobs better than others. (E.g. bio research as opposed to tech, or building aircraft as opposed to armour.) Or workers that could be both scientists and engineers, but with different levels of skill in each. Probably only of interest to players who really like to micromanage research/construction.

Link to comment
Share on other sites

Hmmm it seams that we are going more and more off the topic here :) We supposed to dissuss problem from player side (not implementation). Workers (scientists and engineers) are inviduals from code side, but player can only see numbers (like in oryginal xcom:eu) and i think making it diffrent is work for V1+.
Link to comment
Share on other sites

Damn, I closed browser while typing :Brickwall:

 

Good thing I have a keylogger :).

 

2) Player picks a topic, creates a Project, and assigns scientists to it. (How the player picks the scientists is unclear to me: Possibly as individuals, by lab, by base, whatever.)

 

I suppose, he receives a list of available personell (wich was generated by iteration through every scientist to see who's free). If scientists are all clones of some great scientist and therefore perfectly interchangable, player just fills the lab in. Otherwise he picks everyone personally (or presses the "select best" button).

 

I prefer when lab can be populated by scientists and assigned a project to do. Not when project gets created and assigned scientists if there place in lab.

 

Lab should go first. Thus limiting amount of simultaneous projects. It is more logical also.

 

That is, project gets created and then it gets assigned a lab or two.

 

Scientists and workers are almost the same, yes. But I believe we didn't make an intermediate base class for them because there isn't many things you will be able to do with that class without casting it down (or is it up? anyway, to derived).

 

If as you said there will be multiskill personell, or something like that (it is defenitely v1+ :)), then we always can easily make a very base class and branch soldiers, scientists, personal attendants and whatever from it.

 

1) How to determine which items can be researched/constructed.

2) What workers can be involved on a project.

3) What to do with the reward. (Constructed objects must be put somewhere when done.)

 

That's a job for project initiator.

 

Although I still whould like to see high science and grunt oily work separated. We might use different approaches to manufacture (when they know exactly how long will it take to build something) and for guesswork when they see a totally unknown artifact working in totally unknown fashion...

Edited by UnFleshed One
Link to comment
Share on other sites

Scientists and workers are almost the same, yes. But I believe we didn't make an intermediate base class for them because there isn't many things you will be able to do with that class without casting it down (or is it up? anyway, to derived).

 

Converting a pointer to a worker to a pointer to an engineer is called downcasting. And I don't believe it will be necessary. If you can wait until Monday, I will attempt to provide working sample code showing how it all hangs together. (Damm. I was hoping to get to play some UFO:Aftershock this weekend.)

Link to comment
Share on other sites

Hmmm it seams that we are going more and more off the topic here :) We supposed to dissuss problem from player side (not implementation). Workers (scientists and engineers) are inviduals from code side, but player can only see numbers (like in oryginal xcom:eu) and i think making it diffrent is work for V1+.

Exactly but we do the difference because we plan to change that.

 

Please don't comment on implementation before we will now what do we want to do :)

I would have say the same ;), go on with a design standpoint.

 

Greetings

Red Knight

Link to comment
Share on other sites

OK, does anyone disagree with this point from my earlier post:

 

This is the conceptual use case of a “ResearchProject”:

1) Player opens the research dialog and is presented with a list of topics that can be researched.

2) Player picks a topic, creates a Project, and assigns scientists to it. (How the player picks the scientists is unclear to me: Possibly as individuals, by lab, by base, whatever.)

3) Now at regular intervals (e.g. once every game hour or day) a “ResearchProjectsManager” (for want of a better name) goes through the list of Research projects. For each project it iterates through the scientists assigned to it, asking them “How much have you contributed to the project?” and adding their output to the cumulative contributions for the project.

4) When the cumulative contributions exceed the “Cost” of the project, it’s completed and the player gets a “reward.” The ability to build or use a weapon, or research another technology, or whatever.

 

And what we're mostly supposed to be discussing is how player assigns scientists to projects? Where the rules go something like:

1) Player can have 1 research project per base running at any one time.

2) All the scientists in the base will be working on the project.

3) Two or more bases can work on the same project.

Link to comment
Share on other sites

And what we're mostly supposed to be discussing is how player assigns scientists to projects?  Where the rules go something like:

1) Player can have 1 research project per base running at any one time.

2) All the scientists in the base will be working on the project.

3) Two or more bases can work on the same project.

 

that would be quite a deviation from the original game, where projects and scientists take up lab space, and multiple projects can be researched in one lab.

 

if researching something like "alien grenade" blocks your entire lab, that's kind of unrealistic. Our bases are made up of modules, so for a standard combat-oriented base this would work, but you might want to create a research base with something like 6-7 labs.

 

(the Apocalypse-research structure seemed about right to me: 1 lab = 1 project.

if we did it like that and allowrd for multiple labs to participate in a project, with the abovementioned "additional-lab-penalty", I guess we'd have a good system, but that would definitely be V1+.)

Link to comment
Share on other sites

And what we're mostly supposed to be discussing is how player assigns scientists to projects?  Where the rules go something like:

1) Player can have 1 research project per base running at any one time.

2) All the scientists in the base will be working on the project.

3) Two or more bases can work on the same project.

 

that would be quite a deviation from the original game, where projects and scientists take up lab space, and multiple projects can be researched in one lab.

 

if researching something like "alien grenade" blocks your entire lab, that's kind of unrealistic. Our bases are made up of modules, so for a standard combat-oriented base this would work, but you might want to create a research base with something like 6-7 labs.

 

(the Apocalypse-research structure seemed about right to me: 1 lab = 1 project.

if we did it like that and allowrd for multiple labs to participate in a project, with the abovementioned "additional-lab-penalty", I guess we'd have a good system, but that would definitely be V1+.)

 

My appologies, it's been some time since I last played X-COM, so my memory is fuzzy.

 

Changing topic. For tracking progress on projects (as opposed to the rules for how the user allocates resources to projects) I submit the following example code. Note that it DOESN'T comply with coding standards, it's just presented here to show the basic idea.

 

Which is to have a base class "Project" that holds the basic "bookkeeping" logic, with derived classes handling the special case processing for differences between Research and Construction tasks. As you can see, Construction tasks are deterministic, research are not.

#include <string>
#include <vector>

using namespace std;


char const* kSkillConstruct = "construct";
char const* kSkillResearch  = "research";


class Skill
{
public:
Skill(string const& name, int level) : _name(name), _level(level) {};
string const& GetName() const {return _name;};
double GetBaseContribution() const {return _level;};

private:
string _name;
int    _level;
};

class Worker
{
public:
Worker(string const& name, Skill const& skill) : _name(name), _skill(skill) {};
string const& GetName() const {return _name;};
Skill const&  GetSkill() const {return _skill;};

private:
string  _name;
   Skill   _skill;
};

class Project
{
public:
Project(string const& name, double cost) : _name(name), _progress(0.0), _cost(cost) {};

bool IsFinished() const {return (_cost <= _progress);};
void AddWorker(Worker const& worker) {_assignedWorkers.push_back(&worker);};

virtual void   AddSuitableWorkers(vector<Worker> const& Staff);
virtual bool   AdvanceProject(int TimeUnits);
virtual bool   CanContribute(Worker const& worker) const = 0;
virtual double CalculateContribution(Worker const& worker) const {return worker.GetSkill().GetBaseContribution();};
virtual void   GiveReward() = 0;

private:
string                 _name;
double                 _progress;
double                 _cost;
vector<Worker const*>  _assignedWorkers;
};

void Project::AddSuitableWorkers(vector<Worker> const& staffList)
{
for (int i = 0; i < staffList.size(); ++i)
{
 if (CanContribute(staffList[i]))
 {
	 AddWorker(staffList[i]);
 }
}
}

bool Project::AdvanceProject(int TimeUnits)
{
while (0 != TimeUnits)
{
 for (int i = 0; i < _assignedWorkers.size(); ++i)
 {
	 _progress += CalculateContribution(*_assignedWorkers[i]);
 }
 --TimeUnits;
};

if (IsFinished())
{
 GiveReward();
}
return IsFinished();
}

class ConstructionProject : public Project
{
public:
ConstructionProject(string const& name, double cost) : Project(name, cost) {};
virtual bool   CanContribute(Worker const& worker) const {return worker.GetSkill().GetName() == kSkillConstruct;};
virtual void   GiveReward() { /* would get plasma ammo here */ };
};

class ResearchProject : public Project
{
public:
ResearchProject(string const& name, double cost) : Project(name, cost) {};
virtual bool   CanContribute(Worker const& worker) const {return worker.GetSkill().GetName() == kSkillResearch;};
virtual void   GiveReward() { /* would get technology here */ };
virtual double CalculateContribution(Worker const& worker) const;
};

double ResearchProject::CalculateContribution(Worker const& worker) const
{
   // assume for research, odds of worker making a contribution are proportional to skill
   return (rand() < (worker.GetSkill().GetBaseContribution() * RAND_MAX / 100));
}

void DemoProjects()
{
   // create workers.
   vector<Worker> minions;
minions.push_back(Worker("engineer01", Skill(kSkillConstruct,  1)));
minions.push_back(Worker("engineer02", Skill(kSkillConstruct,  2)));
   minions.push_back(Worker("scientist1", Skill(kSkillResearch,  50)));
   minions.push_back(Worker("scientist2", Skill(kSkillResearch,  90)));

   // at this point here, would produce a list of projects that user can choose from
// left as exercise for students

// once user chooses project, we create it.  (Probably use a factory pattern)
// but for demo purposes, we'll just create a research and construction project
   vector<Project*> projects;
projects.push_back(new ResearchProject("Alien Terror", 20));
projects.push_back(new ConstructionProject("Plasma Ammo", 20));

// assign workers to projects
for (int i = 0; i < projects.size(); ++i)
{
 projects[i]->AddSuitableWorkers(minions);
}

// now simulate progress of time
for (i = 0; i < projects.size(); ++i)
{
 if (projects[i]->AdvanceProject(1))
 {
	 break;
 }
}
};

Link to comment
Share on other sites

I would change some methods names and how the workers work, plus couple standard projects a little more with the Engineer and Scientist class.. but the concept looks promising.

 

Try to think in the interface and how to use it, do not post the actual implementation code. And use a more simplier notation for the definition, C# like code is clean enough to show the design idea.

 

Greetings

Red Knight

Link to comment
Share on other sites

couple standard projects a little more with the Engineer and Scientist class

 

Can you please explain why/how. As I have tried to show in this code, specialized engineer & scientist classes don't appear to be needed, as the only difference is the skill they have.

 

Try to think in the interface and how to use it, do not post the actual implementation code. And use a more simplier notation for the definition, C# like code is clean enough to show the design idea.

 

The concept is that building something in a workshop and researching something in a lab are sufficiently similar that we can have a common framework for both activities, that different functionality can be plugged into, to cater for the differences.

 

In my prior code example, I represented this common framework as the class "Project", with derived classes for handling Research & Construction projects.

 

From a conceptual viewpoint, a Project needs to:

1) Determine which projects can be initiated.

2) Determine which resources can be assigned to a project. (Resources could be any combination of people, facilities and bases.)

3) Allow player to assign resources to a project.

4) Allow for start-up costs for a project. (e.g. Money for construction, item for research.)

5) Track the resources being used by a project.

6) Display the resources being used by a project to player.

7) Allow player to add/remove resources from a project.

8) Allow player to cancel project.

9) Track progress of project, and display to user.

10) Calculate incremental progress on project, based on resources allocated and time elapsed.

11) "Reward" player on completion of project.

12) Release resources on completion of project.

 

N.B. Some of these activities are sufficiently complex that we might choose to implement them as classes themselves. In which case I think we're talking GoF's strategy pattern. I may be wrong here, feel free to correct me.

 

Now, the major area of contention appears to be the "rules", as the player sees them, for:

1) Allowing player to assign resources to a project, and

2) Calculating incremental progress

 

Some possible rules for 1 are:

1) Player assigns any number of staff to project, regardless of where the staff are.

2) Player assigns staff to facility, then assigns facility to project. (Variant: player can assign multiple facilities to project.)

3) Player assigns staff to base, then assigns bases to projects. (Variant, can assign multiple bases.)

 

Likewise, for 2, some possible rules are:

1) A staff member's "contribution" is proportional to member's skill and time spent e.g. output = time * staff.skillLevel

2) Odds of staff member making a contribution this period are proportional to skill level. if (rand()

3) As 1, but staff are assigned to facilities, and output is inversely proportional to how crowded the facility is. E.g. output = time * staff.skillLevel / facililty.Occupiers

4) Additional facilities are not as efficient as "primary" facility.

 

Obviously, these are not complete sets of possible rules. However, I believe the "Project" framework allows us to separate out what is common to all implementations. Minimizing code duplication, and making it easier to update to post v1.0

Link to comment
Share on other sites

Now we are speaking a similar language. ;)

virtual bool CanContribute(Worker const& worker) const {return worker.GetSkill().GetName() == kSkillConstruct;};
When I say couple it a little more is more like, think about adding a double dispatcher to avoid doing stuff like that, and instead of using Worker, use Personnel class.
From a conceptual viewpoint, a Project needs to:

1) Determine which projects can be initiated.

2) Determine which resources can be assigned to a project.  (Resources could be any combination of people, facilities and bases.)

3) Allow player to assign resources to a project.

4) Allow for start-up costs for a project.  (e.g. Money for construction, item for research.)

5) Track the resources being used by a project.

6) Display the resources being used by a project to player.

7) Allow player to add/remove resources from a project.

8) Allow player to cancel project.

9) Track progress of project, and display to user.

10) Calculate incremental progress on project, based on resources allocated and time elapsed.

11) "Reward" player on completion of project.

12) Release resources on completion of project.

Excelent definition.

 

N.B. Some of these activities are sufficiently complex that we might choose to implement them as classes themselves.  In which case I think we're talking GoF's strategy pattern.  I may be wrong here, feel free to correct me.
You are not wrong in that appreciation.

 

Now, the major area of contention appears to be the "rules", as the player sees them, for:

1) Allowing player to assign resources to a project, and

2) Calculating incremental progress

1. That is something the model is and should not be aware of. (Just as a reminder speaking as Player as the actual "Player" :))

2. That shouldnt be a problem. This that every scientist will generate points per day, when the needed points are covered, you are done. (that is for now, but should be enough for V1, and a couple of additions for V2).

 

Greetings

Red Knight

Edited by red knight
Link to comment
Share on other sites

Now, the major area of contention appears to be the "rules", as the player sees them, for:

1) Allowing player to assign resources to a project, and

2) Calculating incremental progress

1. That is something the model is and should not be aware of. (Just as a reminder speaking as Player as the actual "Player" :))

Sorry, I don't understand. Can you expand please.

Link to comment
Share on other sites

I reread my statement and it was more than obscure. The idea is that the framework is not under any circunstance tied with the "Player" (you playing the game), that is something that the Interface will handle (so the control is done in the presentation layer) the model will just know that it can be assigned resources (no control on who or where they came from). Did I clarify the idea?

 

Greetings

Red Knight

Link to comment
Share on other sites

I reread my statement and it was more than obscure. The idea is that the framework is not under any circunstance tied with the "Player" (you playing the game), that is something that the Interface will handle  (so the control is done in the presentation layer) the model will just know that it can be assigned resources (no control on who or where they came from). Did I clarify the idea?

 

Understood. Presumably the Project framework will have a reference (in the abstract sense) to an object in the Interface that the Project knows to invoke when it needs to find the resources for a Project.

Link to comment
Share on other sites

  • 1 month later...

While waiting for DagonSquirel to build, I’m going to write down some of my thoughts on the Research engine.

 

I’ve looked at the TechnologyManager class. I believe the having multiple member functions “isTechnologyAvailable(string)”, “isItemAvailable(string)” etc. is overkill. Really just need a single function (and underlying map).

 

The most difficult part of the Research manager looks like trying to answer the question “Can base X research Y?” Because we have to evaluate the “prerequisite” part of a research xml entry, an example is:

<AnyOneOf>
<reference xnetid="XNET_PLASMA_CANNON" />
<reference xnetid="XNET_XC-2_STARFIRE" />
</AnyOneOf>
<AnyOneOf>
<reference xnetid="XNET_GAIA_MISSILE" />
<reference xnetid="XNET_XC-2_STARFIRE" />
</AnyOneOf>

 

I’m thinking that to do this, I will need something like a recursive descent parser, to build up an expression tree, and then evaluate.

 

e.g.

AllOf(AnyOneOf(xnet(XNET_PLASMA_CANNON), xnet(XNET_XC-2_STARFIRE)), AnyOneOf(xnet(XNET_GAIA_MISSILE), xnet(XNET_XC-2_STARFIRE)))

 

So I’m probably going to want a separate class just to parse the XML and generate the expressions. I’m going to need to have something that can evaluate if xnet(XNET_PLASMA_CANNON) is true, if AnyOneOf() is true, and AllOf() is true.

 

Can anyone think of an easier way of doing this?

Edited by dteviot
Link to comment
Share on other sites

An idea has hit my head. Since technology tree is a tree, it can be done with graph. There's awesome Boost.Graph library that can solve arbitrary graphs (solve == looking in example which techs can be researched, what items produced etc). What do you think?
Link to comment
Share on other sites

An idea has hit my head. Since technology tree is a tree, it can be done with graph. There's awesome Boost.Graph library that can solve arbitrary graphs (solve == looking in example which techs can be researched, what items produced etc). What do you think?

I'll have a look at it, but to be honest, my initial assesment is that evalutating the graph is the easy part of this. The hard part is parsing the XML and building up the tree. Evaluating nodes that ask isInBase(Item) or isTechnologyAvailable(Tech) looks trivial. As does evaluating areAllOfTheseNodesTrue(), isOneOfTheseNodesTrue()

Link to comment
Share on other sites

I'll have a look at it, but to be honest, my initial assesment is that evalutating the graph is the easy part of this.  The hard part is parsing the XML and building up the tree.  Evaluating nodes that ask isInBase(Item) or isTechnologyAvailable(Tech) looks trivial.  As does evaluating areAllOfTheseNodesTrue(), isOneOfTheseNodesTrue()

That's true, parsing XML will be hardest task here. Using already written graph library will help so you don't need to worry about graph, just about proper parsing.

 

Btw, who's responsible for Production? I heard that there's some work done, but I can take it if nobody works on it.

Link to comment
Share on other sites

I'll have a look at it, but to be honest, my initial assesment is that evalutating the graph is the easy part of this.  The hard part is parsing the XML and building up the tree.  Evaluating nodes that ask isInBase(Item) or isTechnologyAvailable(Tech) looks trivial.  As does evaluating areAllOfTheseNodesTrue(), isOneOfTheseNodesTrue()

That's true, parsing XML will be hardest task here. Using already written graph library will help so you don't need to worry about graph, just about proper parsing.

 

Btw, who's responsible for Production? I heard that there's some work done, but I can take it if nobody works on it.

David was working on production, if I'm not mistaken.

Link to comment
Share on other sites

I notice that research.xsd contains a lot more capability than is used by research.xml. Therefore, I’d like to make the following changes to xsd, which should eliminate redundant parts of the xsd, or make parsing easier.

 

1. Eliminate the “reference” type. Instead the explicit reference types should be used. This will make parsing easier, as the parser doesn’t have to try and figure out what sort of reference it’s dealing with.

e.g. these

	<reference xnetid="XNET_XC-2_STARFIRE"/>
<reference itemid="ITEM_XC-2_STARFIRE"/>

 

become

	<xnetref name="XNET_XC-2_STARFIRE"/>
<itemref  name="ITEM_XC-2_STARFIRE"/>

 

2. Remove the unused reference types: topicref & craftref

I believe these are unneeded, as topicref is obviously for detecting if a topic has been researched, and we can tell that from checking if something it grants is available. The same applies to craftref. Either we have an instance of the craft, or we have the ability to produce the craft. (This means I don’t have to implement this functionality.)

 

3. change combatantref to

<xsd:element name="combatantref">
<xsd:complexType>
 <xsd:attribute name="alien" type="itemREF" use="required"/>
 <xsd:attribute name="rank" type="rankREF" use="required"/>
</xsd:complexType>
</xsd:element>

 

Currently captured aliens appear as items in the base’s inventory, with a rank. This should make determining if a “combatant” requirement has been satisfied essentially the same work as determining if an item is present in a base.

(Aside, currently the ranks are “dead”, “soldier”, “terrorist”, “commander” etc, so I’ll probably want to add “Live” to the rankREF enumerations, to cover the case of we don’t care about the rank, it just has to be alive. And I’ll probably want to add the “rankREF” enumeration to basic.xsd.)

 

4. The schema currently supports multiple facility types being needed to research a topic. I’d like to modify it so that each research topic will only require the use of one facility type. (Although different topics could require different facility types, presumably a post v1.0 feature.) Personally, I suspect the providing for multiple facilities was a bug in research.xml

 

5. Comment for Azreal, (and yes, I’ve said this before, but I guess I wasn’t clear) the RES_XCAP-AG_CHASSIS research topic is redundant. As the it grants doesn’t exist. All that’s needed is to add “” to the grants list for topics RES_XCAP-AG_PLASMA and RES_XCAP-AG_GAIA.

 

6. Stupid questions time. We’ve got some research topics like this:

<topic name="RES_VIPER_SOLDIER_INTERROGATION">
<research>
 <time>1234</time>
</research>
 
<prerequisite>
 <reference combatantid="LIVE_VIPER_SOLDIER"/>
</prerequisite>  
 
<grants>
 <AnyOneOf>
	 <xnetref name="XNET_ALIEN_ABDUCTIONS"/>
	 <xnetref name="XNET_ALIEN_RETALIATION"/>
 </AnyOneOf>
</grants>
</topic>

Does this mean that if we do this topic once and get Alien Abductions, but we don’t have Alien Retaliation, then we should be able to research the topic again and get Retaliation? At which point the topic should be removed from the available for research list? Does this relate in any way to the (unused) “persists” attribute that topics can have?

 

7. What PRECISELY does the researchbonus do?

<topic name="RES_PLASMA_RIFLE">
<research>
 <time>1234</time>
</research>

<prerequisite>
 <itemref name="ITEM_PLASMA_RIFLE" />
</prerequisite>
<cost type="ITEM_PLASMA_RIFLE" >1</cost>
<cost type="money">2000</cost>
<researchbonus topic="RES_PLASMA_RIFLE_CLIP">10</researchbonus>
<researchbonus topic="RES_PLASMA_CANNON">15</researchbonus>
 
<grants>
 <itemref name="ITEM_PLASMA_RIFLE" /> 
 <xnetref name="XNET_PLASMA_RIFLE" /> 
</grants>
 
</topic>

If I have both clip and cannon researched before doing the rifle, does it give me:

a. A 25% (10 + 15) reduction in development time

b. A 23.5% (0.9 * 0.85), or do I just get the biggest bonus.

c. something else?

 

A final comment:

In ..\Xenocide\xenocidegame\data\schemabasic.xsd, there are both REF types, and ID types.

 

E,g.

<xsd:simpleType name="researchREF">
<xsd:restriction base="xsd:string">
 <xsd:pattern value="RES_[^\s]*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="xnetREF">
<xsd:restriction base="xsd:string">
 <xsd:pattern value="XNET_[^\s]*"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="researchID">
<xsd:restriction base="xsd:ID">
 <xsd:pattern value="RES_[^\s]*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="xnetID">
<xsd:restriction base="xsd:ID">
 <xsd:pattern value="XNET_[^\s]*"/>
</xsd:restriction>
</xsd:simpleType>

 

I’ve got 3 questions.

1. Why do we have this apparent duplication/redundancy?

2. Is there any reason why either the REF or ID types should not be removed?

3. (I’ve asked this before, but didn’t get a full answer) Is there a reason why we’re using patterns to define these types, rather than enumerations? Several times now I’ve encountered mismatches between xml files because the pattern match isn’t strong enough. If we went to enumerations, I believe most of these mismatches would be eliminated.

Link to comment
Share on other sites

I'll have a look at it, but to be honest, my initial assesment is that evalutating the graph is the easy part of this.  The hard part is parsing the XML and building up the tree.  Evaluating nodes that ask isInBase(Item) or isTechnologyAvailable(Tech) looks trivial.  As does evaluating areAllOfTheseNodesTrue(), isOneOfTheseNodesTrue()

That's true, parsing XML will be hardest task here. Using already written graph library will help so you don't need to worry about graph, just about proper parsing.

 

Btw, who's responsible for Production? I heard that there's some work done, but I can take it if nobody works on it.

David was working on production, if I'm not mistaken.

I think guyver was referring to production in workshops. (As opposed to creating the C++ item objects) My thought was that production projects are really very similar to research projects, so I'd do the research side, and then expand to cover production. I think I talk more about it earlier in this thread. I've just restarted research (I took a week off.) So will probably post my new thoughts on the topic later today or tomorrow.

Link to comment
Share on other sites

5. Comment for Azreal, (and yes, I’ve said this before, but I guess I wasn’t clear) the RES_XCAP-AG_CHASSIS research topic is redundant.  As the <itemref name="ITEM__XCAP-AG,_CHASSIS" /> it grants doesn’t exist. All that’s needed is to add “<xnetref name="XNET_XCAP-AG,_CHASSIS" />” to the grants list for topics RES_XCAP-AG_PLASMA and RES_XCAP-AG_GAIA.

I made that it granted an item? odd, well, I suppose it slipped as I added all the others. Yes, XNET_XCAP-AG,_CHASSIS is granted by XCAP-AG,_PLASMA and GAIA, should be corrected.

 

6. Stupid questions time.  We’ve got some research topics like this:

<topic name="RES_VIPER_SOLDIER_INTERROGATION">
<research>
 <time>1234</time>
</research>
 
<prerequisite>
 <reference combatantid="LIVE_VIPER_SOLDIER"/>
</prerequisite>  
 
<grants>
 <AnyOneOf>
	 <xnetref name="XNET_ALIEN_ABDUCTIONS"/>
	 <xnetref name="XNET_ALIEN_RETALIATION"/>
 </AnyOneOf>
</grants>
</topic>

Does this mean that if we do this topic once and get Alien Abductions, but we don’t have Alien Retaliation, then we should be able to research the topic again and get Retaliation?  At which point the topic should be removed from the available for research list?  Does this relate in any way to the (unused) “persists” attribute that topics can have?

I'd say that it should be that way, even if it's not that way already, it's the same when you research an Alien Navigator, you should get a random Alien Mission entry everytime you research one, but never repeating one.

Link to comment
Share on other sites

×
×
  • Create New...