Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
uglyPenguins -- lists, properties and a challenge
Old
JeremyShafer
Guest
 
Status:
Posts: n/a
Default uglyPenguins -- lists, properties and a challenge - 08-04-2008, 07:25 PM

There's nothing like an example. I've attached an example world that highlights my frustrations w/ alice.

It illustrates either A) my ineptitude or B) some deficiencies in Alice or C) a little bit of Both.

Please take a look at the uglyPenguins world. The penguins themselves are quite cute. It's the code that is ugly. All I wanted to do initially was add a "score" property to each penguin, randomly assign the score, and then display the score in a 3d text object.

I order to do this, I had to remove the scores attribute from the penguin objects, and put that in a list all it's own.

Then I wanted a way to update the scores... but you can't do that through a list. I ended up creating a very ugly method to do this.

So ... here's my challenge to the Alice community. Can someone make me an elegantPenguins that improves on this code?
Attached Files
File Type: a2w uglyPenguins.a2w (627.2 KB, 97 views)
   
Reply With Quote
Less Ugly Penguins
Old
groucho
Guest
 
Status:
Posts: n/a
Default Less Ugly Penguins - 08-05-2008, 07:52 AM

I don't have a complete solution, since to my knowlegde OOP is not fully integrated into Alice. Maybe Dick or DrJim have a more elegant way of dealing with the problem.

My "less ugly" solution is still ugly in the sense that it does not access the score property of the penguins or the text property of the 3D-text directly (I doubt that this is possible in present Alice at all). This uglyness is, however, hidden in a single world method "setPenguScore".

The advantage is that you can use the score property of the penguins and do not have to use a separte list. Also, a list for the 3D-text scores is not necessary.
Attached Files
File Type: a2w LessUglyPengus.a2w (1.12 MB, 97 views)
   
Reply With Quote
Old
JeremyShafer
Guest
 
Status:
Posts: n/a
Default 08-05-2008, 08:54 AM

Thanks Groucho. You're right, that is less ugly!
   
Reply With Quote
Ugly Object Oriented Penguin (OOP)
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Ugly Object Oriented Penguin (OOP) - 08-05-2008, 04:01 PM

You can eventually find a way to use lists and attach object parameters to other objects with Alice 2.0 - see attached.

Unfortunately (and with apologies to Opus) it is probably even uglier code than the previous two examples.

Alice 3.0 will really be welcome.
Attached Files
File Type: a2w Ugly OOP.a2w (503.2 KB, 86 views)

Last edited by DrJim; 08-05-2008 at 04:04 PM.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.