usc-csci201-fall2013 / simcity201

SimCity 201 Public Repository
1 stars 7 forks source link

Incorporating Each Team Member Restaurant #6

Open dwilczyn opened 10 years ago

dwilczyn commented 10 years ago

[I've made this a new issue, because I'm having trouble with jenniezhou's issue]

The question about incorporating EACH member's restaurant has come up several times and deserves a complete answer. Here goes:

-- Each of you has more work to do on your restaurant, i.e., incorporating the shared data. We have to grade that work somehow, so it might as well be a part of SimCity201. Each person will demo his contribution to SimCity201 and the restaurant is part of it. I'll have another post on this.

-- The architecture of your restaurants should very much be the architecture of SimCity. Agents started within gui panels, getting configuration messages from the gui, etc. But, agents are free-running once all this is done. More about the configuration issues below.

-- My role system offers flexibility without changing much of your existing code. It should work this way. Let's say you have 5 team members, so you have 5 different restaurants. You will have in your team system 5 versions of the customer role (call them CustomerRole1, CustomerRole2, etc.), 5 version of the HostRole (call them HostRole1, HostRole2, etc.) and so forth. If a PersonAgent is going to Restaurant1, then add the role CustomerRole1 to the PersonAgent and send the I'mHungry(Customer1Role) message to the instance of HostRole1 in the running system. And that is what in effect happens when YOU go to different restaurants, i.e., you have to be a different customer in each, adapting to the protocol of each restaurant. So, when a Person enters Restaurant1, he will send HostRole1 (the host of Restaurant1) the I'm hungry message using his CustomerRole1. That restaurant will now run EXACTLY as before, not knowing the difference between dealing with a CustomerAgent or this new CustomerRole. And why should it? They are identical except for the new class signature and maybe a couple of other details.

-- How does the PersonAgent find out all this information? Well how do I do this at home? Ignoring Google for now, I look up restaurants in my directory or phonebook or contact list and find their address, phone number, type, maybe some comments. Our PersonAgent won't need a phone number but will need the HostRole1 instance so he can send him the I'mHungry() message when he get to the restaurant. So, two questions: (1) How will your PersonAgent store that information, and (2) how will it get populated? The answer to the first is easy--use maps like you have many times before. I'll let you design that. Put an issue on the tracker if you have questions. The answer to the second is also easy because you've already done similar things in restaurants when you populated maps. In your configuration panels you will create all the objects for a SimCity201 run. Create the PersonAgent instances first, then as you create the other instances, tell the person agent about the ones he needs to know about. For restaurants: restaurant type, the restaurant host, the location (he has to get there) and maybe the menu. Your person agent has to have some data on which to decide where to go, doesn't he?

-- Each of your restaurants has to undergo simple changes to make all the above work. Changing the signatures and names of your restaurant agents to conform with my role-design is easy in Eclipse. I guarantee that you will be amazed at how beautiful all this performs once you get the hang of it. Start small. Build a SimCity with ONE PersonAgent and ONE Restaurant. Get the role-thing going. Then add Markets, then Banks, then Cars and roads. Get familiar with the Role design. Trust me on this.

vikrantsinghal commented 10 years ago

Do you want to see every student's restaurant incorporated in V1?

dwilczyn commented 10 years ago

Can I make this more clear? Each student's restaurant MUST be in the project.