Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
December 2001: [Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068) |
[Freeciv-Dev] Re: Cleaning up gotohand.c (PR#1068)[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[ It looks like last version of the email didn't made it. ] On Tue, Dec 04, 2001 at 06:37:25PM +0000, Gregory Berkolaiko wrote: > send me your code, let's see if I can finish it. See attached files from the goto-agent. Remove the agent code, add air unit support (I have ideas how to do this), add the player to the interface (if you want to use it in the server) and move this to common/goto. > suppose I write a get_warmap_cost function > what I don't know how to do is to print the file:line info of the code > that called get_warmap_cost Make get_warmap_cost a macro. > Any comments on the below? > > > > generate_warmap tell you answer to the question > > > "where unit A can go from where it is now"? > > > > > > if you want an answer to the question > > > "where unit A can go from city C which is over there" > > > you'd have to access _really_generate_warmap directly. > > > > > > Example: > > > http://www.freeciv.org/lxr/source/server/settlers.c?v=cvs#L960 > > > > > > There punit wants to know where ferryboat can take him by sea from > > mycity > > > (ferryboat is somewhere far away). > > > > > > Two lines below punit want to know where it can go by land: another > > > place where land- and sea- warmaps must coexist. What do you think about (python like syntax so intention matters): positions=[] if settler is aboard of ship: a=generate_sea_warmap(boat) for each position in square: if is shore and good tile: positions.append(current_position, a.get_distance(position)) else: if settler is in coastal city: a=generate_sea_warmap(coastal city position) boat=a.find_nearest_boat() if have boat: boat_dist=a.get_distance(boat) for each position in square: if is good tile: positions.append(current_position, boat_dist) a=generate_land_warmap(settler) for each position in square: if is good tile: positions.append(current_position, b.get_distance(position)) for each position in positions: evaluate based on distance using amortize and co choose one Is this equivalent (in the result) to the current implementation? And yes I agree that this method is nasty. Raimar -- email: rf13@xxxxxxxxxxxxxxxxx "There are three ways to get something done. Do it yourself, hire someone to do it for you or forbid your kids to do it."
goto_agent.h
goto_agent.c
|