User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Fix Bug: 'TypeError: this.hasResources is not a function' in this line: 'if (utility.action === 'trade' && this.hasResources()) {' Line Number: 70
User prompt
Improve iq
User prompt
Fix Bug: 'Uncaught TypeError: self.createAndAddWorkplace is not a function' in this line: 'self.workplaces.push(self.createAndAddWorkplace());' Line Number: 455
User prompt
Fix Bug: 'Uncaught TypeError: self.createAndAddHouse is not a function' in this line: 'houses.push(self.createAndAddHouse(2048 / 2, 2732 / 2));' Line Number: 441
===================================================================
--- original.js
+++ change.js
@@ -53,8 +53,30 @@
};
});
var Villager = Container.expand(function (resources) {
var self = Container.call(this);
+ Villager.prototype.calculateOverallUtility = function (utilities) {
+ var weights = {
+ 'work': 1.0,
+ 'home': 0.8,
+ 'plant': 0.5,
+ 'buildHouse': 0.7,
+ 'trade': 0.6
+ };
+ utilities.forEach(function (utility) {
+ var weightedUtility = utility.utility * (weights[utility.action] || 1);
+ if (utility.action === 'home' && this.tiredness > 0.5) {
+ weightedUtility *= 1.5;
+ }
+ if (utility.action === 'trade' && this.hasResources()) {
+ weightedUtility *= 1.2;
+ }
+ utility.utility = weightedUtility;
+ }, this);
+ return utilities.reduce(function (highest, current) {
+ return highest.utility > current.utility ? highest : current;
+ });
+ };
Villager.prototype.kiss = function (partner) {
if (this.canFallInLove(partner)) {
this.createBabyWith(partner);
}
@@ -140,11 +162,9 @@
}, {
action: 'trade',
utility: self.calculateTradeUtility()
}];
- var highestUtilityAction = utilities.reduce(function (highest, current) {
- return highest.utility > current.utility ? highest : current;
- });
+ var highestUtilityAction = self.calculateOverallUtility(utilities);
self.state = highestUtilityAction.action;
if (self.state === 'work') {
self.moveTo(self.workplace.x, self.workplace.y, 'goingToWork');
}
A background of a paysage with plain and without tree or montainbut no water see from the top in the air 100m by 100m Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One human medieval villager in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a house in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree a rock and crambery in a RTS style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heart comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cloud in a comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A market in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An Inn in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An school in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An bakery in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A well in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An apple in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rock in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A home in a RTS and fantasy style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A brewery in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lumberjack in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a marketplace in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a festival in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.