Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 288 289 [290] 291 292 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907010 times)

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4335 on: April 15, 2013, 05:23:41 am »

RAWWR! (a good one this time) I have battle microsoft for the entire weekend, and I emerge victorious...

The most raw scaffolding of the dicebox is online at the new website, and I managed to transfer all* the old rolls over just fine.

http://dicebox.org/Dice/Roll/List

Oh crap, I have to be at actual work soon.

*all meaning the subset that were made since the last time i updated the dicebox. The 10s of thousands of old rolls from the early part of the last decade can't effectively be moved.

When you first mentioned MVC, I was going to be a typical geek and sound off on Python and Django. Now that I see your use case, though, I can say Django makes that kind of thing dead simple. Define one object to represent your roll, one method to control the new roll form, one method to handle displaying rolls, and one template for each of the two methods.
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4336 on: April 15, 2013, 09:07:05 pm »

Whoever attempted the roll "6*4d6-1d6"?

I should note that it doesn't do exactly what you might have wanted it to due to the order of operations. In this case it roles 4d6 and subtracts an independent 1d6, thus giving it a range of values from -2 to 23 even if it will typically be close to what 4d6 keep the highest 3 will provide.

But! you inspired me to add a "keep" notation. To Roll 4d6 and keep the highest 3? the expression is 4d6k3, 6 times? 6*4d6k3. Quick and easy for D&D games.

Other features include comma separated rolls to supplement the * notation for cases where you want a list of dissimilar dice.

Override order of operations with (). (6d6)d6 is different than 6d(6d6)

Roll "exploding dice" with x, 3x6 will roll 3 six sided dice and if a 6 is rolled, it will be rerolled and added to the total indefinitely.

In order to make this die roller more useful for all types of games, I should probably add analogues to keep and explode for the dice lists.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4337 on: April 16, 2013, 02:17:29 am »

Whoever attempted the roll "6*4d6-1d6"?

I should note that it doesn't do exactly what you might have wanted it to due to the order of operations. In this case it roles 4d6 and subtracts an independent 1d6, thus giving it a range of values from -2 to 23 even if it will typically be close to what 4d6 keep the highest 3 will provide.

But! you inspired me to add a "keep" notation. To Roll 4d6 and keep the highest 3? the expression is 4d6k3, 6 times? 6*4d6k3. Quick and easy for D&D games.
That was me :P I was attempting what you think I attempted (well, without trying really hard), and trying to break it at the same time (again without trying really hard) :) It did actually do 6*(4d6-1d6), I think.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4338 on: April 16, 2013, 11:50:03 am »

I need to change the * operator... it isn't friendly with URL's and one thing I am trying to do is pretty much the entire application available with easy to read urls.

For instance I would like to be able to filter the list by going to the url "/Dice/Roll/List/ExpressionEqualTo/6*3d6/Page/1".
but this presents a number of challenges.
1: * isn't well defined for use in urls and causes asp.net to throw a fit.
2: asp.net routes don't like having catchall variables anywhere except the end of a url, so I need to put "Page/1" before the filter criteria.

What the hell is a good single character multiplication symbol other than * and x? I would rather not have different definitions for different cases.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4339 on: April 16, 2013, 02:03:31 pm »

I need to change the * operator... it isn't friendly with URL's and one thing I am trying to do is pretty much the entire application available with easy to read urls.

For instance I would like to be able to filter the list by going to the url "/Dice/Roll/List/ExpressionEqualTo/6*3d6/Page/1".
but this presents a number of challenges.
1: * isn't well defined for use in urls and causes asp.net to throw a fit.
2: asp.net routes don't like having catchall variables anywhere except the end of a url, so I need to put "Page/1" before the filter criteria.

What the hell is a good single character multiplication symbol other than * and x? I would rather not have different definitions for different cases.
First off, I'd recommend adding a search function as a site feature instead of directly as a URL, then the entry line can escape the search term and the search page can subsequently unescape it from the URL arguments. This way you don't have to worry about special characters in URLs.

Second, I read your post, thought about it, and suddenly there was this whole system. Have a gander.
Spoiler: Dice roll notation (click to show/hide)
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4340 on: April 16, 2013, 02:17:07 pm »

Oh, there will be a search form in the application, but I definitely prefer the clean look of that kind of url, particularly since I already wrote the paging portion for the list (it isn't published yet).

I actually have a formal disambiguated grammar defined for a slightly older definition of my dice syntax, i would have to double check it, but I believe the only thing missing is the keep notation.


    Tokens: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + | - | d | ( | ) | , | * | x
    List    -> Sum List2
    List2    -> , Sum List3 | * Sum List3 | ϵ
    List3    -> , Sum List2 | ϵ
    Sum    -> Dice Sum2
    Sum2    -> + Dice | - Dice | ϵ
    Dice    -> Number Dice2
    Dice2 -> d Number Dice2 | x Number Dice2 | ϵ
    Number -> Digit MoreDigits | ( Sum )
    MoreDigits -> Digit MoreDigits | ϵ
    Digit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

frostshotgg

  • Bay Watcher
  • It was a ruse
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4341 on: April 16, 2013, 05:12:02 pm »

Forth is a horrible coding language. I despise it.
It doesn't follow simple layer rules nor linearity, it encourages bad programming habits, and is generally a mess.

Also fuck local variables. I swear every time someone uses them the human race as a whole loses a few hundred brain cells.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4342 on: April 16, 2013, 05:15:48 pm »

Also fuck local variables. I swear every time someone uses them the human race as a whole loses a few hundred brain cells.
... Did I read that right? What's wrong with local variables? S:
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

frostshotgg

  • Bay Watcher
  • It was a ruse
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4343 on: April 16, 2013, 06:07:58 pm »

Also fuck local variables. I swear every time someone uses them the human race as a whole loses a few hundred brain cells.
... Did I read that right? What's wrong with local variables? S:
Well, mutable ones. Those things are like the devil's asshole when you're trying to fix some godawful spaghetti code. I've tried to fix so many programs only to discover I fucking CANT without rewriting the whole thing because whoever the fucktard original coder was used so many mutable local variables that I can't even figure out which one is causing the problem in the first place. Just ugh.
There was a reason after I started learning to code oh so long ago that I stopped. Making new things is fun. Fixing other people's broken shit isn't.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #4344 on: April 17, 2013, 12:39:10 pm »

You know, personally when I'm refactoring legacy code to tidy it up...I tend to find it kinda fun in a masochistic way. It's this weird kind of puzzle that develops a nice rhythm to it.

Wrap class in tests
Reorder large function and break it down into small functions
Bring out functions into dependencies
Wrap those dependencies in tests
Bring dependencies up to be injected
Replace original injected dependencies with mocks in the tests
Repeat...

Then you now have these nice tested dependencies that together form the logic of the system. Which is very easy to work with.
« Last Edit: April 17, 2013, 12:47:29 pm by MorleyDev »
Logged

Twiggie

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4345 on: April 17, 2013, 02:35:21 pm »

Bring out functions into dependencies

sorry, would you mind explaining what exactly this means? maybe with an example? thanks
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4346 on: April 17, 2013, 10:56:09 pm »

Well, made another not so minor update to the DiceBox. Lots of simple visual tweeks, but I have not really prettied it up yet.

There is a little thing that people ALWAYS get wrong when designing a website. Lets say you have a paged list of data, like http://dicebox.org/Dice/Roll/List, and you want to display the latest data first, and your old data isn't going to change much if at all.

Most people simply do an order by descending on their dataset and be done with it. But this means your old, unchanging, archived data will be different for each page for each time that a new element is added to your list. This makes caching very difficult and eats up your cpu, memory and bandwidth allocations, and it makes it more difficult for someone to bookmark into a page of that history to find specific data.

In this case, I turned that around. The list is in order, not descending. However, I default to the LAST page in the list instead of the first, and on the individual list pages the rolls are presented in reverse order, so that the newest rolls are always on top. The content of every page starting with the path http://dicebox.org/Dice/Roll/List/Page/5 is invariant where 5 is a number greater than 0 and less than the current number of pages. Links to those pages will always return the same data. Those pages can be cached essentially forever.

I also added some kick ass filtering to that list. This was a pain because .net LINQ was having difficulty applying bog standard filtering with more than 1 filter, so I had to write the query in raw sql. That part was rather easy, but figuring out that LINQ was screwed up was bad. Again, the filters go directly into the url, making it clean and easily human readable.

what does this link return? http://dicebox.org/Dice/Roll/List/created/is/2012/expression/endswith/d100/total/lessthan/50
why it returns the list of dice rolls that where created in 2012, with expressions ending in d100 and with a total less than 50.

It will probably be a few more weeks of work before it is in good shape (its still missing a few features and invalid data in filtering rarely produces productive error messages). After that I can get back to working on Archipelago and generating desert islands and tropical death traps.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4347 on: April 18, 2013, 03:13:51 am »

There is a little thing that people ALWAYS get wrong when designing a website.
Although your solution is more logical from a caching perspective, it's not wrong to do it in the way people expect it to work.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4348 on: April 20, 2013, 07:20:14 am »

So I'm writing something new: "Blast", a compiler and linker for DF raws and mods, quite like Minecraft Forge + FML. For that purpose, I've invented a DF preraw metalanguage, not unlike PHP for HTML, that evaluates to DF raws. The syntax is similar to DF's raw syntax, but with braces and semicolons instead of brackets and colons (called templates, not tags). Mods can be placed in a mods/ folder, and running blast.pl compiles and links all mods into the raw/ folder, either to be played immediately or to be exported as a static mod that does not require Blast. Every mod may contain a mod.pl script that defines custom code-based templates, although there is already a base template that can define simple format-style templates. I plan to add hooks into the vanilla DF raws that allow vanilla raw objects to be modified (for example adding extra [PERMITTED_SOMETHING:x] tags to the vanilla entities), and also ore/reaction/tool/toy/weapon/armor/bodypart/etc... dictionaries to prevent duplicates of those things. Mods made with Blast can be perfectly compatible and playable with each other (except maybe for balance), although you are free to write total conversions with Blast too, and release them statically. I'll make a thread in the mods section when it's usable enough to be released.
Logged

Slayerhero90

  • Bay Watcher
  • Time for Taako's opinion.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4349 on: April 20, 2013, 12:16:48 pm »

Why don't you rename it Blast Furnace?
Logged
My tumblr.
Yeah no I don't haunt here anymore. Peace
Pages: 1 ... 288 289 [290] 291 292 ... 796