User:Max Randor
I am new to the WorldForge community as of 20/6/2006AD My knowledge of code is very limited - a bit of theory some HTML and some CSS. I have done some stuff on Wikipedia and most Stuff I contribute to can be found via my home page I therefore intend - at least to begin with. To work on the Worldforge site - especialy this Wiki - which I can use and to a lesser extent with Zope. anyway so far I have contributed to the CVS page by adding from the CVS FAQ on the main site - and wikifying - it still needs work with linking. also Quick Start Guide
Contents
Places to put stuff
This is in early development and is not by any means cleaned up or working it is just here so you can see. proper file
# N, E, S, W, NE, SE, SW, NW in order directions = [[0,0,0.707,0.707],[0,0,0,1],[0,0,-0.707,0.707],[0,0,1,0],[0,0,0.387,0.921],[0,0,-0.387,0.921],[0,0,-0.921,0.387 ],[0,0,0.921,0.387]] e.g: m.make('house3',type='house3',pos=(158,150,22),orientation=directions[1] put a statue somewhere around the castle Statue : Pos - X: -440.43 Y: -113.09 Z: 19.988 ish facing north m.make('statue',type='statue',pos=(-440.43,-113.09,settlement_height),orientation=directions[0] apple trees make an orchard somewhere birch trees need to be scattered around like the oaks ('birch', 32, 18, 190, -202, 102, 20) willow trees as near fresh water boulders need scattering on mountains flowers need scattering in valleys 1 - 6 mushrooms in a circle around oak, birch, hickory, willow trees randint(1,6) #in the example code there are 68 stakes produced for i in range(10, 350, 5): #which of these is how many? should the 350 by 360 as no gaps? direction=Vector3D(sin(radians(i)) * uniform(0,2), cos(radians(i)) * uniform(0,2), 10).unit_vector() orient=Quaternion(Vector3D(0,0,1), direction) m.make('mushroom',type='mushroom',pos=(100 + 14 * sin(radians(i)), -50 + 16 * cos(radians(i)), -1), bbox=[-0.5,-0.5,0,0.5,0.5,5 + uniform(0,2)], orientation=orient.as_list(), mass=0.1, mode="relative") a couple of giant spiders somewhere one field of carrots and one field of turnips ##### Extra things Blackum Decker needs to sell: bottle, bowl, cleaver, pickaxe, pole, scythe, bucksaw toolprices = [('bowl', 'price', '3') #things for Blackum Decker to sell need to be stated here with prices ('pole', 'price', '4') ('bottle', 'price', '4') ('cleaver', 'price', '3') ('axe', 'price', '5'), ('shovel', 'price', '5'), ('pickaxe', 'price', '6') ('scythe', 'price', '7') ('tinderbox', 'price', '8') ('bucksaw', 'price', '10')] toolmerc_knowledge=[('market', 'location', tool_stall_pos)] # tool-merchant stall = m.make('Tool Stall', type='stall', pos=tool_stall_pos, orientation=directions[2]) m.make('wall',type='wall',parent=stall.id,pos=(0,0,0),bbox=(-0.5,-1.5,0,0.5,1.5,0.8)) m.make('wall',type='wall',parent=stall.id,pos=(2,0,0),bbox=(0,-1.5,0,0.5,1.5,2)) tmerchant=m.make('Blackun Decker',type='merchant',desc='the tool merchant', pos=tool_merchant_pos,age=probability.fertility_age,sex='male') m.learn(tmerchant,(il.help,"add_help(['Get all your tools here.','Everything a settler needs is available at great prices.'])")) m.know(tmerchant, toolmerc_knowledge) m.know(tmerchant, toolprices) m.own(tmerchant, stall) tools=[] tooltypes=['shovel', 'axe', 'tinderbox', 'bowl', 'pole', 'bottle', 'cleaver', 'pickaxe', 'scythe', 'bucksaw'] #the different tools must be stated here for i in range(0, 15): tty = tooltypes[randint(0,9)] #the tools.append(m.make(tty,type=tty,pos=(uniform(-0.7, 0.7),uniform(-0.5,0.5),0.6),parent=stall.id,orientation=directions[randint(0,7)])) m.own(tmerchant,tools) ##### We need a weapon seller too who should sell: arrow, bow, weapon_stall_pos=(150**change**,138**change**,settlement_height) #needs changing weapon_merchant_pos=(150**change**,140**change**,settlement_height) #needs changing weaponprices = [('arrow', 'price', '3') ('bow', 'price', '20')] weaponmerc_knowledge=[('market', 'location', weapon_stall_pos)] # weapon-merchant stall = m.make('Weapon Stall', type='stall', pos=weapon_stall_pos, orientation=directions[2]) m.make('wall',type='wall',parent=stall.id,pos=(0,0,0),bbox=(-0.5,-1.5,0,0.5,1.5,0.8)) m.make('wall',type='wall',parent=stall.id,pos=(2,0,0),bbox=(0,-1.5,0,0.5,1.5,2)) wmerchant=m.make('Bob Gladior',type='merchant',desc='the weapon merchant', pos=weapon_merchant_pos,age=probability.fertility_age,sex='male') m.learn(wmerchant,(il.help,"add_help(['Get all your weapons here.','Everything a warrior needs is available at great prices.'])")) m.know(wmerchant, weaponmerc_knowledge) m.know(wmerchant, weaponprices) m.own(wmerchant, stall) weapons=[] weapontypes=['arrow', 'bow'] #the different weapons must be stated here for i in range(0, 15): wty = weapontypes[randint(0,9)] #the randint should go from 0 to the number of items -1 weapons.append(m.make(wty,type=wty,pos=(uniform(-0.7, 0.7),uniform(-0.5,0.5),0.6),parent=stall.id,orientation=directions[randint(0,7)])) m.own(wmerchant,weapons) ##### We need a grocer who sells and buys fruit and other non meat stuff: e.g. apple, loaf, food_stall_pos=(150**change**,138**change**,settlement_height) #needs changing food_merchant_pos=(150**change**,140**change**,settlement_height) #needs changing foodprices = [('apple', 'price', '1') ('loaf', 'price', '3')] foodmerc_knowledge=[('market', 'location', food_stall_pos)] # food-merchant stall = m.make('Food Stall', type='stall', pos=food_stall_pos, orientation=directions[2]) m.make('wall',type='wall',parent=stall.id,pos=(0,0,0),bbox=(-0.5,-1.5,0,0.5,1.5,0.8)) m.make('wall',type='wall',parent=stall.id,pos=(2,0,0),bbox=(0,-1.5,0,0.5,1.5,2)) fmerchant=m.make('**INNSERT NAME HERE**',type='merchant',desc='the food merchant', pos=food_merchant_pos,age=probability.fertility_age,sex='male') m.learn(fmerchant,(il.help,"add_help(['Get all your food here.','All the food you need at bargin prices.'])")) m.know(fmerchant, foodmerc_knowledge) m.know(fmerchant, foodprices) m.own(fmerchant, stall) foods=[] foodtypes=['', ''] #the different foods must be stated here for i in range(0, 15): fty = foodtypes[randint(0,9)] #the randint should go from 0 to the number of items -1 foods.append(m.make(fty,type=fty,pos=(uniform(-0.7, 0.7),uniform(-0.5,0.5),0.6),parent=stall.id,orientation=directions[randint(0,7)])) m.own(fmerchant,foods) ##### we need a carpenter who sells and buys wooden things: barrel, longtable food_stall_pos=(150**change**,138**change**,settlement_height) #needs changing food_merchant_pos=(150**change**,140**change**,settlement_height) #needs changing foodprices = [('', 'price', '') ('', 'price', '')] # food-merchant stall = m.make('Food Stall', type='stall', pos=food_stall_pos, orientation=directions[2]) m.make('wall',type='wall',parent=stall.id,pos=(0,0,0),bbox=(-0.5,-1.5,0,0.5,1.5,0.8)) m.make('wall',type='wall',parent=stall.id,pos=(2,0,0),bbox=(0,-1.5,0,0.5,1.5,2)) fmerchant=m.make('**INNSERT NAME HERE**',type='merchant',desc='the food merchant', pos=food_merchant_pos,age=probability.fertility_age,sex='male') m.learn(fmerchant,(il.help,"add_help(['Get all your food here.','All the food you need at bargin prices.'])")) m.know(fmerchant, foodmerc_knowledge) m.know(fmerchant, foodprices) m.own(fmerchant, stall) foods=[] foodtypes=['', ''] #the different foods must be stated here for i in range(0, 15): fty = foodtypes[randint(0,9)] #the randint should go from 0 to the number of items -1 foods.append(m.make(fty,type=fty,pos=(uniform(-0.7, 0.7),uniform(-0.5,0.5),0.6),parent=stall.id,orientation=directions[randint(0,7)])) m.own(fmerchant,foods) ##### we need a tailor who sells clothes: boots, hat ##### we need a cow seller: cow we need a huntsman at the castle who has dogs, sells + buys them when trained. + same for horses. we need a fisherwoman who buys + sells fish stuff that needs code: cow, bunny, dog, spider (giant)
Theorising on motion planning
For NPCs to use to go places, for clients to use when users says /go and either puts in cordinates or clicks on a position in the distance, or when they try to /pickup something further away - first they /go there then they /pickup
It seems I will have to finish this later.
Sear Config Tweaks
fog camera distance day length
finish later
planting fields
#two for loops one for columns one for rows #stuff the code will need to know #plantable = # the thing to be planted #furrowdist = # the distance between the furrows (the columbs in which the plantable is to be planted) #plantspacing = # the distance between each of the plants along the furrow carrotfield = m.make('field',type='ploughed_field',pos=(120,170,30),status=1.0,area={'points' : [ [0,0], [0,20], [20,20], [20,0] ], 'layer' : 8}, bbox=[20,20,0]) plantable = 'carrot' #4-3 this diagram shows which corners are which. 1 is the origin corner defiend in pos #| | #1-2 corner1 = [120,170,30] corner2 = [corner1[0] + 20,corner1[1],corner1[2]] conrer3 = [corner1[0] + 20,corner1[1] + 20,corner1[2]] furrowdist = 1 plantspacing = 1 c12diff = [(corner2[0] - corner1[0]),(corner2[1] - corner1[1]),(corner2[2] - corner1[2])] # the difference between corners 1 and 2 corner4 = [corner3[0]-c12diff[0],corner3[1]-c12diff[1],corner3[2]-c12diff[2]] frontfieldist = sqrt(c12diff[0]**2 + c12diff[1]**2 + c12diff[2]**2) # the distance along the front of the field numfurrow = frontfieldist / furrowdist # the number of furrows furrowincr = [c12diff[0]/numfurrow,c12diff[1]/numfurrow,c12diff[2]/numfurrow] # the increase in x,y,z of the start position of each furrow c14diff = [(corner4[0] - corner1[0]),(corner4[1] - corner1[1]),(corner4[2] - corner1[2])] # the difference between corners 1 and 4 sidefieldist = sqrt(c14diff[0]**2 + c14diff[1]**2 + c14diff[2]**2) # the distance along the side of the field numplants = sidefieldist / plantspacing # the number of plants in each furrow plantincr = [c14diff[0]/numplants, c14diff[1]/numplants, c14diff[2]/numplants] # the increase in x,y,z of the position of the plants along the lenght of the furrow for i in range(numfurrow): furrowstart = [corner1[0] + furrowincr[0]*i, corner1[1] + furrowincr[1]*i, corner1[2] + furrowincr[2]*i] # start a new furrow for j in range(numplants): plantpos = [furrowstart[0] + plantincr[0]*j, furrowstart[1] + plantincr[1]*j, furrowstart[2] + plantincr[2]*j] # calculate the plant position m.make(plantable,type=plantable,pos=(plantpos[0],plantpos[1],plantpos[2]),orientation=directions[randint(0,7)]) # make the plant field2 = m.make('field',type='ploughed_field',pos=(142,170,30),status=1.0,area={'points' : [ [0,0], [0,20], [20,20], [20,0] ], 'layer' : 8}, bbox=[20,20,0])
cow code
###### cow - like deer but not scared of humans #####mason.xml #the only additon is the reference to script <map> <map name="attributes"> <map name="bbox"> <list name="default"> <float>-1.5</float> <float>-0.5</float> <float>0</float> <float>2.25</float> <float>0.5</float> <float>2.0</float> </list> <string name="visibility">public</string> </map> <map name="mass"> <float name="default">80</float> <string name="visibility">public</string> </map> <map name="maxmass"> <float name="default">2000</float> <string name="visibility">private</string> </map> </map> <string name="id">cow</string> <string name="objtype">class</string> <list name="parents"> <string>character</string> </list> <map name="script"> <string name="language">python</string> <string name="name">world.objects.animals.Cow</string> </map> </map> ##### python script #This file is distributed under the terms of the GNU General Public license. #Copyright (C) 1999 Aloril (See the file COPYING for details). #This script is based on the deer script from atlas import * from world.objects.Thing import Thing try: from random import * except ImportError: from whrandom import * from Vector3D import Vector3D import atlas class Cow(Thing): def chop_operation(self, op): if self.mass<1: return(Operation("set",Entity(self.id,status=-1),to=self)) res = Message() ent=Entity(self.id,mode="dead",mass=self.mass-1) res.append(Operation("set",ent,to=self)) beef_ent=Entity(name='beef',parents=['beef']) if (len(op)>1): #to_=self.world.get_object(op[1].id) to_ = op[1].id else: to_=self res.append(Operation("create",beef_ent,to=to_)) return res ##### define_world.py ## TODO #the cow needs to avoid the fence as well but only a little bit. #the cow needs to browse grass cow_goals=[(il.avoid,"avoid(['orc'],30.0)"), (il.avoid,"avoid(['fire'],10.0)"), (il.forage,"forage('apple')"), (il.forage,"forage('mushroom')"), (il.browse,"browse(self, 'fir', 0.8)"),# I don't think that cows eat firs they should browse grass but I am not sure that would work yet. (il.flock,"flock()")] cows=[] xbase = uniform(-180,180)# this needs changing to the place where the cow field is ybase = uniform(-180,180) for i in range(0, 10): xpos = xbase + uniform(-20,20) ypos = ybase + uniform(-20,20) c=m.make('cow', type='cow', pos=(xpos, ypos, settlement_height)) cows.append(d) m.learn(cows,cow_goals)