This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#226 2012-10-16 00:30:05

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:


First you want to use classes, now operators?????

What's next, functions?

I was hoping for something like:

Code:

Dungeon().add_item('Magic Sword', 'some statement that could be "exec"-ed')

Sure. That works I guess.

tongue ...

That still doesn't solve many of my problems  hmm

So let's say that this item restores 10 hp...

Code:

Dungeon().add_item('Potion', 'self.hp += 10')

Sound good?

EDIT: how about an additional 'type' argument that specifies consumable/weapon/armor/misc?
This would make classification easier.
A weapon's code would look like:

Code:

Dungeon().add_item('Magic Sword', 10, 'weapon')

with 10 being the attack bonus

I'm being more and more convinced that decorators will help with this...  tongue

Dungeon.add_item(name, type, modifier)

or

Dungeon.add_item(name, type, modifiers={'base': 10, 'magic': 5})

Offline

 

#227 2012-10-16 18:13:11

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

ohaiderstudios wrote:

Magnie wrote:


Sure. That works I guess.

tongue ...

That still doesn't solve many of my problems  hmm

So let's say that this item restores 10 hp...

Code:

Dungeon().add_item('Potion', 'self.hp += 10')

Sound good?

EDIT: how about an additional 'type' argument that specifies consumable/weapon/armor/misc?
This would make classification easier.
A weapon's code would look like:

Code:

Dungeon().add_item('Magic Sword', 10, 'weapon')

with 10 being the attack bonus

I'm being more and more convinced that decorators will help with this...  tongue

Dungeon.add_item(name, type, modifier)

or

Dungeon.add_item(name, type, modifiers={'base': 10, 'magic': 5})

I JUST DON'T UNDERSTAND DECORATORS!!!!!

DON'T JUDGE MEEEEE!!!!!


Fork Clamor on GitHub!

Offline

 

#228 2012-10-16 21:07:52

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:


tongue ...

That still doesn't solve many of my problems  hmm

So let's say that this item restores 10 hp...

Code:

Dungeon().add_item('Potion', 'self.hp += 10')

Sound good?

EDIT: how about an additional 'type' argument that specifies consumable/weapon/armor/misc?
This would make classification easier.
A weapon's code would look like:

Code:

Dungeon().add_item('Magic Sword', 10, 'weapon')

with 10 being the attack bonus

I'm being more and more convinced that decorators will help with this...  tongue

Dungeon.add_item(name, type, modifier)

or

Dungeon.add_item(name, type, modifiers={'base': 10, 'magic': 5})

I JUST DON'T UNDERSTAND DECORATORS!!!!!

DON'T JUDGE MEEEEE!!!!!

I don't either, all I know is that it wraps around the function you write.  smile

Offline

 

#229 2012-10-17 14:17:02

playzooki
Scratcher
Registered: 2012-02-07
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

ohaiderstudios wrote:

Magnie wrote:


I'm being more and more convinced that decorators will help with this...  tongue

Dungeon.add_item(name, type, modifier)

or

Dungeon.add_item(name, type, modifiers={'base': 10, 'magic': 5})

I JUST DON'T UNDERSTAND DECORATORS!!!!!

DON'T JUDGE MEEEEE!!!!!

I don't either, all I know is that it wraps around the function you write.  smile

What about LSTC? Could you host the 2.0 server?


I iz a sig. So there. CLICK ME ITS SO IMPORTANT!!!!

Offline

 

#230 2012-10-17 16:45:13

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

playzooki wrote:

Magnie wrote:

ohaiderstudios wrote:


I JUST DON'T UNDERSTAND DECORATORS!!!!!

DON'T JUDGE MEEEEE!!!!!

I don't either, all I know is that it wraps around the function you write.  smile

What about LSTC? Could you host the 2.0 server?

2.0 is up.

Offline

 

#231 2012-10-17 17:19:59

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Much progress has been made.

I've done most of the networking protocol, thanks to code from Magnie's other networking projects  tongue

Don't worry, credit will be given.


Fork Clamor on GitHub!

Offline

 

#232 2012-10-19 15:27:11

playzooki
Scratcher
Registered: 2012-02-07
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

playzooki wrote:

Magnie wrote:


I don't either, all I know is that it wraps around the function you write.  smile

What about LSTC? Could you host the 2.0 server?

2.0 is up.

YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY!!!!


I iz a sig. So there. CLICK ME ITS SO IMPORTANT!!!!

Offline

 

#233 2012-10-19 18:27:15

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Anyone want to go on? (Chat.PY 2.0 remember)


Fork Clamor on GitHub!

Offline

 

#234 2012-10-19 18:31:20

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

When is 3.0 going to work? I really want MolyBot back, and I don't want to change it for 2.0 (since 2.0 has broadcasts instead of vars for sending messages).


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#235 2012-10-19 19:33:37

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

ohaiderstudios wrote:

Anyone want to go on? (Chat.PY 2.0 remember)

Ok


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#236 2012-10-19 21:13:38

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Molybdenum wrote:

When is 3.0 going to work?

Until I have a break from school. I'm probably going to end up recoding it again and possibly recode chat3 to use indexing or caching rather than searching through every single user to see if they are in the channel or not.

blob8108: How's the parser coming along? The RSC protocol uses double double-quotes ("") for a single double-quote. (Thanks MathWizz for the info!)  smile

Offline

 

#237 2012-10-19 23:21:12

laser314
Scratcher
Registered: 2010-07-16
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Bit art is still down.


http://alpha.scratch.mit.edu/scratchr2/static//images/logo_sm.png 2.0 Alpha Tester!http://i49.tinypic.com/1zckcqb.png

Offline

 

#238 2012-10-20 12:45:00

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

laser314 wrote:

Bit art is still down.

It's going to be down for a while since I've been having a lot of bugs occurring.

Offline

 

#239 2012-10-20 13:23:53

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

blob8108: How's the parser coming along? The RSC protocol uses double double-quotes ("") for a single double-quote. (Thanks MathWizz for the info!)  smile

Here, updated. Should work now!  smile

(Apologies for the crazy algorithm and the nested loops/generators  tongue  There must be a simpler way...)

Last edited by blob8108 (2012-10-20 13:24:56)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#240 2012-10-20 22:50:52

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

blob8108 wrote:

Magnie wrote:

blob8108: How's the parser coming along? The RSC protocol uses double double-quotes ("") for a single double-quote. (Thanks MathWizz for the info!)  smile

Here, updated. Should work now!  smile

(Apologies for the crazy algorithm and the nested loops/generators  tongue  There must be a simpler way...)

Sweet, thank you.  smile

Offline

 

#241 2012-10-27 15:12:05

playzooki
Scratcher
Registered: 2012-02-07
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

Molybdenum wrote:

When is 3.0 going to work?

Until I have a break from school. I'm probably going to end up recoding it again and possibly recode chat3 to use indexing or caching rather than searching through every single user to see if they are in the channel or not.

blob8108: How's the parser coming along? The RSC protocol uses double double-quotes ("") for a single double-quote. (Thanks MathWizz for the info!)  smile

When you have done that, shouldn't it be called 3.1 chat.py?


I iz a sig. So there. CLICK ME ITS SO IMPORTANT!!!!

Offline

 

#242 2012-10-27 15:20:53

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

playzooki wrote:

Magnie wrote:

Molybdenum wrote:

When is 3.0 going to work?

Until I have a break from school. I'm probably going to end up recoding it again and possibly recode chat3 to use indexing or caching rather than searching through every single user to see if they are in the channel or not.

blob8108: How's the parser coming along? The RSC protocol uses double double-quotes ("") for a single double-quote. (Thanks MathWizz for the info!)  smile

When you have done that, shouldn't it be called 3.1 chat.py?

LSTC will change, but the project will probably be the same. So, the server version will change, but it will still be called Chat.PY 3.0 (or 3).

Offline

 

#243 2012-10-27 15:30:10

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Why isn't anyone ever on 2.0?


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#244 2012-10-27 16:41:50

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

I'm probably going to end up recoding it again and possibly recode chat3 to use indexing or caching rather than searching through every single user to see if they are in the channel or not.

Just as a random observation that might have escaped you: I found out recently that hash-table lookups are really fast in Python — so searching dicts and sets is very efficient.  smile  Maybe have a set for each channel, and then just test it using the "in" operator?

Last edited by blob8108 (2012-10-27 16:42:06)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#245 2012-10-27 19:26:03

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Molybdenum: Probably because no one really knows we downgraded.

blob8108 wrote:

Magnie wrote:

I'm probably going to end up recoding it again and possibly recode chat3 to use indexing or caching rather than searching through every single user to see if they are in the channel or not.

Just as a random observation that might have escaped you: I found out recently that hash-table lookups are really fast in Python — so searching dicts and sets is very efficient.  smile  Maybe have a set for each channel, and then just test it using the "in" operator?

My current structure for channels is like this:

Code:

self.channel_data = {'scratch' : {'ranked' : {'Magnie' : '*'},
                                  'whitelist' : ['Magnie'],
                                  'blacklist' : [],
                                  'mutelist': [],
                                  'flags' : 'b',
                                  'motd' : 'Welcome!'}}

Or basically: dicts, strings, and arrays (is there a difference between lists/arrays and sets?).  tongue

Offline

 

#246 2012-10-27 19:54:08

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

I know  tongue  Wait.. you just told me (trolololololol)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#247 2012-10-28 00:34:51

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

Code:

self.channel_data = {'scratch' : {'ranked' : {'Magnie' : '*'},
                                  'whitelist' : ['Magnie'],
                                  'blacklist' : [],
                                  'mutelist': [],
                                  'flags' : 'b',
                                  'motd' : 'Welcome!'}}

Yo dawg, we heard you like dictionaries...

I've been too busy to go on Chat.PY 2 right now


Fork Clamor on GitHub!

Offline

 

#248 2012-10-28 09:32:16

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Magnie wrote:

Molybdenum: Probably because no one really knows we downgraded.
ically: dicts, strings, and arrays (is there a difference between lists/arrays and sets?).  tongue

sad


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#249 2012-11-05 16:33:38

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

is there a difference between lists/arrays and sets?

Yes — sets are unordered lists which can only contain unique values. They're optimised so that testing a set to see if it contains a value (using the "in" operator) is much faster. You can test this thus:

Code:

In [15]: import time

In [16]: def timeit(x):  
    start = time.time()
    x()
    end = time.time()
    return end - start
   ....: 

In [17]: big_list = range(2560000)

In [18]: big_set = set(big_list)

In [19]: timeit(lambda: 'x' in big_list)
Out[19]: 0.20299482345581055

In [20]: timeit(lambda: 'x' in big_set)
Out[20]: 3.0994415283203125e-06

You can also do set operations, too, like union and intersection. They're pretty cool.  smile

Last edited by blob8108 (2012-11-05 16:34:23)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#250 2012-11-06 02:29:30

NeilWest
Scratcher
Registered: 2010-01-06
Posts: 1000+

Re: Little Server That Can (Chat.PY, Bit Art, etc.)

Molybdenum wrote:

Why isn't anyone ever on 2.0?

I am. Derp.

Offline

 

Board footer