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.
...
That still doesn't solve many of my problems
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...
Dungeon.add_item(name, type, modifier)
or
Dungeon.add_item(name, type, modifiers={'base': 10, 'magic': 5})
Offline
Magnie wrote:
ohaiderstudios wrote:
Magnie wrote:
Sure. That works I guess....
That still doesn't solve many of my problems
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...
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!!!!!
Offline
ohaiderstudios wrote:
Magnie wrote:
ohaiderstudios wrote:
...
That still doesn't solve many of my problems
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...
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.
Offline
Magnie wrote:
ohaiderstudios wrote:
Magnie wrote:
I'm being more and more convinced that decorators will help with this...
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.
What about LSTC? Could you host the 2.0 server?
Offline
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.
What about LSTC? Could you host the 2.0 server?
2.0 is up.
Offline
Much progress has been made.
I've done most of the networking protocol, thanks to code from Magnie's other networking projects
Don't worry, credit will be given.
Offline
Magnie wrote:
playzooki wrote:
Magnie wrote:
I don't either, all I know is that it wraps around the function you write.What about LSTC? Could you host the 2.0 server?
2.0 is up.
YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY!!!!
Offline
Anyone want to go on? (Chat.PY 2.0 remember)
Offline
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).
Offline
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!)
Offline
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
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!)
Here, updated. Should work now!
(Apologies for the crazy algorithm and the nested loops/generators There must be a simpler way...)
Last edited by blob8108 (2012-10-20 13:24:56)
Offline
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!)
Here, updated. Should work now!
(Apologies for the crazy algorithm and the nested loops/generators There must be a simpler way...)
Sweet, thank you.
Offline
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!)
When you have done that, shouldn't it be called 3.1 chat.py?
Offline
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!)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
Why isn't anyone ever on 2.0?
Offline
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. 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)
Offline
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. Maybe have a set for each channel, and then just test it using the "in" operator?
My current structure for channels is like this:
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?).
Offline
I know Wait.. you just told me (trolololololol)
Offline
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
Offline
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?).
Offline
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:
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.
Last edited by blob8108 (2012-11-05 16:34:23)
Offline
Molybdenum wrote:
Why isn't anyone ever on 2.0?
I am. Derp.
Offline