« first day (727 days earlier)      last day (3283 days later) » 

12:00 AM
Sure, it forms a tree. But that tree is a representation of an object structure
 
There are 1326 unanswered questions
 
So in your code you would work with the object structure
shut up duga
2
And if you needed it for a longer time period, you would persist it in a database
it's only when you need to send it across the network that you would transform it to JSON
 
@JeroenVannevel Database is no practical, the JSON data is mapped at the beginning of each game
 
But that's entirely irrelevant, really. You just call your favorite json generator, send it and decode it again at the receiver's end
and you're back to using your object structure
If I understand you correctly, you just store that JSON, right? Simply saving the json to a file?
 
12:03 AM
It's certainly lightweight in the sense that it doesn't require a database but I'm not sure if assuming that also means it's faster
 
Your entire structure is a dictionary.
 
there are many optimizations an ORM framework provides (lots of caching)
 
Well, nested dictionaries.
 
Well, performance is not the top priority, "moddability" is right now
 
@sᴉɔuɐɹɥԀ What if I want a trigger that fires on multiple events?
 
12:04 AM
i.e., you try the game, like the engine, want to make your own game variation, you fork the repo and then modify the JS/JSON files
 
It's the same trigger in every sense, but it fires in 3 different scenarios.
Hmm...
 
Right, so you actually DO use it for data transfer
except you're the receiver
however..
No, still.
 
I guess so. The idea is that the JS/JSON is in regular communication with the core Java game server, so data is exchanged back & forth throughout the game
 
You're not really receiving, you're just reading your own configuration
Your app is not going to receive the configuration of a fork
The fork will generate its own configuration, no?
 
Basically. But those are technical details that are not that important right now. The server is included with the build
 
12:07 AM
I think the idea here is that a set of cards could be used across multiple forks of the game, right?
Without having to change the structure of the cards file to make it work with the other version of the game.
 
@nhgrif More or less. That, and also, that a different fork can make their own cards, effects, etc. using a default code base
(we would eventually include forks into the main game, so the user can choose as they started the client, which mod they would like to play; but that's somewhat out of scope to what I'm asking about)
 
I'm voting to close this question as off-topic because it is about a code reviewdsg 55 secs ago
@dsg Is every optimization question a code review question? — RaGe 17 secs ago
 
@sᴉɔuɐɹɥԀ First and foremost, be sure to include a $schema
JSON (/ˈdʒeɪsən/ JAY-sən), or JavaScript Object Notation, is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. It is used primarily to transmit data between a server and web application, as an alternative to XML. Although originally derived from the JavaScript scripting language, JSON is a language-independent data format. Code for parsing and generating JSON data is readily available in many programming languages. The JSON format was originally specified by Douglas Crockford. It is currently described by two competing standards...
 
I don't think this would do well on Code Review, likely get closed as stub code, unless more context is provided, e.g., the rest of the module/function. — Phrancis 22 secs ago
 
@nhgrif I'll keep that in mind, we're mostly conceptualizing right now though
 
12:13 AM
Yes, but all the same... if you include a $schema from square one, then it doesn't matter how flexible your implementation is.
The $schema value of the JSON data tells the library parsing it whether this is version 1 or version 2 or version 10.
 
Also, our JSON is different somewhat, because it's native JS (notice the lack of quotes around identifier), so the data really and truly is, just Plain Old JavaScript Object
 
So if in three years, you finally do have to make a schema change to add some new thing, you can without instantly invalidating three years worth of card set.
 
Fair point, I'll talk to the others about it
 
The old card sets simply won't have the new property you added.
Or won't be organized in the same manner.
But forks of the game potentially won't support the new card set schema until they've updated to handle it.
But that's how mods for any game work.
But as for the specific structure... I can buy the triggers each having their own value... but the value for each trigger should probably be an array rather than a dictionary?
 
Makes sense. We're really trying to keep it as "native" JS as possible so it may be the case that the JSON version may not even matter much if at all
 
12:18 AM
I don't know.
 
Actually, yes, I think an array would make more sense, good point
 
But... explain how actions:, targets: and other: are used?
Also, be sure when you code the application that it's okay if a trigger isn't present. The JSON object should only contain a trigger if it actually does something on that trigger.
 
in TCG Creation, yesterday, by Simon André Forsberg
{
  name: "Some Card",
  values: {
    health: 1,
    attack: 1
  },
  onEndOfTurn: {
      chance: {
          probability: 0.5,
          action: {
              draw: { target: "self" }
          }
      }
  }
}
 
That's not the same format as your thing you linked...
 
@nhgrif This is the concept for card effects
Yeah, that's the other JSON data that has the card library
You can see the trigger, the action and the target in that
 
12:23 AM
I don't understand.
By the way, you guys might consider this...
Rather than: onTurnBegin:, try.... beforeTurnBegins: and afterTurnDidBegin:
(for every trigger time)
 
The naming doesn't match, but in short, this says... card "Some Card" has 1 health, 1 attack; and on end of turn, has a chance (with 0.5 probability) to perform the action "draw" [a card] into the player (self) hand
 
I'd change that onEndOfTurn: structure there though...
 
0
Q: Javascript: How can I optimize this line for performance?

Tito EstevesI would like to optimize the second line in my for loop(var phase). I believe moving parts of it outside of the loop would optimize performance. What can I move outside the for loop to improve performance? for (var i = 0; i < items.length; i++) { var phase = Math.sin((document.body.scrollTop / 1...

 
  beforeEndOfTurn: [
      event: {
          probability: 0.5,
          action: {
              draw: { target: "self" }
          }
      }
  ]
If probability: is ommited, 100% is assumed.
 
12:27 AM
I'm fairly certain some of those triggers are already implemented in Java and just need to be referenced to; but other things, specifically "actions" and "targets", will modify the Java ECS data map directly during the game
@nhgrif OK good thinking
 
chance: and probability: seem redundant.
 
Indeed
 
The event: in my example is unnecessary.
It should be just:
  beforeEndOfTurn: [
      {
          probability: 0.5,
          action: {
              draw: { target: "self" }
          }
      }
  ]
So a trigger that draws 1 card and 50% chance to draw two cards (total), would look like this:
 
That's probably closer to what I have in mind also
 
12:29 AM
you don't need the call to ToArray in .net 4+
 
  beforeEndOfTurn: [
      {
          action: {
              draw: { target: "self" }
          }
      },
      {
          probability: 0.5,
          action: {
              draw: { target: "self" }
          }
      }
  ]
 
also Count() defers to the Count property for some collections, including arrays see referencesource.microsoft.com/#System.Core/System/Linq/…
 
@nhgrif I might even be tempted to leave out action:
 
so yeah while Count/Length is preferred, Count() is not necessarily O(n), and in this case it is O(1)
 
Maybe... or maybe not
First rodeo here with JSON so, been learning a lot :D
 
12:32 AM
otherwise, have an upvote :)
 
  beforeEndOfTurn: [
      {
          draw: { target: "self" }
      },
      {
          probability: 0.5,
          draw: { target: "self" }
      }
  ]
like that?
 
Yeah pretty much
 
@mjolka drat, an error message deceived me! I thought it was weird but I fixed it together with another compile error (LINQPad)
they must've interfered
the Count() is a good remark. I looked at the source some time ago but totally forgot it
I'll edit those things in
 
@sᴉɔuɐɹɥԀ I think you guys should definitely consider counting these card effect event times as being just before or just after a certain event.
Most specifically, it allows card effects to be clearly separated from game mechanics.
 
  onEndTurn: [
      {
          drawCard: { target: "selfDeck" }
      },
      {
          probability: 0.5,
          drawCard: { target: "selfDeck" }
      }
  ]
 
12:38 AM
A place where this is confusing, for example... in MTG... if you have more than 7 cards in your hand at the end of your turn, you must discard down to 7.
 
@nhgrif It's possible it's already that way, Simon wrote that code so I can't tell you for sure
 
But what if I make a card that says "At the end of your turn, draw 10 cards."
 
@JeroenVannevel nice edit
 
Does the draw 10 cards event happen before or after then end-of-turn-must-discard-down-to-7 event?
 
@nhgrif I can see that, there are some other values involved in other parts of the code that handle max card in hand, max cards of each type, etc.
 
12:39 AM
This confusion is avoided if the card effects are happening at strictly different times from the game events.
 
@nhgrif Ah yes, makes complete sense
 
1. Resolve "before event" card events.
2. Resolve game mechanic events.
3. Resolve "after event" card events.
Also consider I make a card... "When you take damage in the amount of 5 or more, your opponent takes 1 damage."
If I'm at 5 life and my opponent is a 1 life, and he deals me 5 damage, who wins?
Who got to zero life first?
 
Race condition eh?
 
The card's mechanic should specify if it's beforeSelfDamage: or afterSelfDamage:
If the effect is beforeSelfDamage:, I win. I have killed my opponent before he killed me.
If it is afterSelfDamage:, I lose.
If we only have an onSelfDamage: event, we both think we've won and we argue endlessly about how the game should work. And no matter how the game resolves it, 50% of all people will file a bug report.
 
I'd say it is a tie.
 
12:43 AM
Is this related to a specific TCG or just a generalised discussion?
 
Generalized discussion.
Well... it's about a card game they're making.
 
Little bit of both, but mostly generalized
 
If I do a successful suicide attack, neither of us will be arguing about who won.
 
Also.
Achievement Unlocked: Earn Populist badge over a @jonskeet answer http://stackoverflow.com/help/badges/62/populist?userid=2792531
3
 
So, in a planned suicide, I won, because it went the way I want.
 
12:45 AM
We don't plan on allowing ties, at least for the time being... they are... messy
 
Well, let the suicide artist win then, because it went the way he planned.
 
You just need to turn all of your on events into before and after events.
Even if all of the current ones default to either before or after
 
@Hosch250 We'll cross that bridge when we get there, a bit early for this, though good information
 
OK.
 
Anyway, I'm going upstairs.
 
12:46 AM
See you.
 
Thanks @nhgrif for the great insight :D
 
So, I don't know what these games are all about, but if you ever want to discuss anything, I'll play the stuffed duck.
 
Not sure what "playing the stuffed duck" actually means lol.
 
0
Q: Printing all the permutations of a string in alphabetical order-ver1.1

SteephenI adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more changes required or any more suggestions. #include <iostream> #include<fstream> #include<algorithm> #i...

 
12:56 AM
0
Q: Bash script that checks if font is installed and installs it if necessary

John P.I'm new to writing bash scripts and I was wondering if I could get someone's advice on a part of the script I'm working on. Intended purpose of code Check if a font is installed by using fc-list and grep, if the particular font is not installed, offer to install it for the user. This snippet is...

 
This does not look too terribly insane, so far... I think
		chance: function (probability) {
		    var roll = Math.random();
		    if ((typeof probability) !== "number" && isNaN(probability)) {
		        return NaN;
		    } else if (roll <= probability) {
		        return true;
		    } else {
		        return false;
		    }
		}
 
First, where is number defined?
Second, these are a set of if statements returning a value.
 
It's a JS thing. (typeof foo) !== "number" is not checking whether it's the string "number", but rather if it's actually a number
 
chance: function (probability) {
    var roll = Math.random();
    if ((typeof probability) !== "number" && isNaN(probability)) {
        return NaN;
    }
    return roll <= probability;
}
OK.
 
Ah, that's quite handy!
 
1:00 AM
But, you don't need the else statement(s) really.
Groan...
My family got a keyboard (piano, not computer, although it is computerized) recently.
We already have a baby grand as well, but everyone is infatuated with this stupid keyboard.
I HATE it, it is making me insane!
 
Do you know the make/model? I'm curious
 
The grand sounds at least 100 times better.
Kawai.
Our grand is a GM-12.
It was supposed to be a GM-10, but the store was out of GM-10's because their last shipment of "GM-10"s contained GM-12's, so we got it at discount.
 
I must admit most prepackaged sounds on keyboards sound quite "canned". I prefer to just capture the MIDI data into the computer, then assign high-quality samplers to play the notes
 
Our tuner tuned for all the big radio stations and music universities for hours around, and he said our piano was one of the best he ever tuned.
 
Wow, that's quite the compliment
 
1:06 AM
I'm sure it has something to do with the acoustics of the house, and so on, but it is a great piano, and the keyboard is awful compared to it.
Same brand, not sure of the model.
 
Some OEMs are definitely better at either acoustic or electronic instruments. Roland makes fantastic electronic instruments, but only "OK" acoustic ones. Kawai may be the other way around.
 
If you want me, you can ping me. I'm going to read my PHIL essay and send it to the secondary editor (my mom).
We used to have a Yamaha, but it broke, and my sister needed a grand for the key or peddle action or something.
She is now a music teacher.
 
I got to play around with a Roland high-end drum eKit, I could hardly believe I was not playing real drums
 
Cool.
 
Thanks to using CodeReview, I posted my first "not terrible" question on StackOverflow:
7
Q: Generic Method to find the median of 3 values

LegatoI needed a method to get the median of 3 values, I thought it a good opportunity to write a generic method since I don't really have that practiced. I wrote this and it seems pretty straight-forward, though I get a warning, but it seems to work fine, according to my tests. I'm aware I could use ...

Before that my highest upvote was 2, lol.
Anyway, How's everyone doing. :) ?
@Hosch250 @sᴉɔuɐɹɥԀ You guys participate in the community challenge?
 
1:14 AM
curious results in those last rows
 
Word.
 
@Legato Yeah.
 
Link?
 
10
Q: CC C# calculator

Hosch250This is my basic C# calculator; I'm sure there is much that can be improved. This design is based on Bjarne Stroustrup's C++ calculator, a purposely be-bugged version of which can be found at his website. enum Operators { Addition, Subtraction, Multiplication, Division, Modulo } static cla...

Why?
 
1:16 AM
@Legato Not this time, been busy with stuff :\
 
Thanks for the +, @Legato
 
Jeoren's answer is WOW.
 
That's why it got accepted.
 
I'm sure I would've upvoted earlier if I saw it.
 
The stupidest mistake was the static one, I thrashed that problem out with C++ two summers ago.
 
1:18 AM
I can't award bounty right away, lol
 
Yeah.
Maybe I'll get more votes :)
 
@JeroenVannevel it's for you though. ;)
 
Give other answerers a chance to perhaps earn the bounty with a new answer
 
pft
I wouldn't compete with that.
 
1:20 AM
That's mostly a technicality ;)
 
@Mat'sMug: told you: SUPERIOR ANSWERS
Thanks legato, appreciate it
 
@Quill I just reviewed your edit and rejected it because you edited the code.
The indentation can be covered in a review.
 
Following your bulleted points has allowed me to run the update-dabase thank you. — Matthew Verstraete 44 secs ago
Feels good baby
 
@JeroenVannevel monking! ..what's that about?
 
@Mat'sMug Nothing special, just me being superior
 
1:22 AM
eh, I'm just a mug
 
More upvotes for @JeroenVannevel awesomesauce. :D
brb, looking for meta post.
 
In Windows 8.1, I can see which apps are open on the Task Bar without opening it by the little white line.
In Windows 10, there isn't a box, just a bar at the bottom, so I can't see what is open with the TB closed.
 
This makes me wonder if people feel that their answer wouldn't meet a certain standard? I personally can relate to such. Sometimes, I worry that whatever I can answer is obvious/won't be helpful to the asker, or deals with too few points. An answerer's task definitely requires more work and the very notion that one could go through someone else's code and have whatever their contribution be considered unhelpful is dissuading. I can come nowhere near some of the fantastic answers I've received here, and it's not something that I take lightly. — Legato 2 days ago
Case in point, Jeroen. xD
Maybe I should hack something up for the CC...
 
You are too late UTC time.
You still have a few hours my time.
Not sure where you are.
 
NJ.
 
1:28 AM
eh, there's no deadline for
 
But, you can't tag it CC anymore, or can you?
 
@JeroenVannevel Is Blue Moon a legit Belgian beer? I got an IPA version (which is delicious) and was just curious
 
I suppose it isn't officially marked closed yet.
 
it just naturally dies down at one point
 
On a semi-related note...
 
1:29 AM
> Blue Moon Belgian White is a Witbier style beer brewed by Coors Brewing Company in Golden, CO
 
I'm aiming to write JavaScript that will shorten @JeroenVannevel's life by the least amount possible ;)
 
The name didn't ring a bell though so I just looked it up
no Dutch version of it either
 
I love how the simple things on SO get the highest upvotes.
 
Oh, yikes. That's unfortunate, because it's a damn good beer
 
It's probably just an American beer hopping on our reputation
 
1:31 AM
I'd put it up there with Hoegaarden, nice fresh summery aroma
 
I'll think of something simple.
 
I don't experiment much with different beers. I'm a simple person: if I like something then I'll only rarely try alternatives since in my mind there's basically nothing to gain
 
When Americans put their mind to something, they are the best.
 
and I like simple food
 
Even rioting (and arresting rioters).
 
1:33 AM
So my favorite beer is Jupiler though sometimes I would dare to venture for some Duvel
 
I don't drink, but I like my foods without condiments.
The closest I've been to being drunk was when I ate an apple almost as large as a watermelon.
3
Well, not seriously, but it was larger than my fist.
 
We're like opposites
I have been drinking beer since I was 1 year old
Yes, that says 1
Piedbœuf brown tablebeer, 1.5% alcohol
 
@Hosch250 i'm going to star that just because i have no idea how else to react to that statement
 
@mjolka Lol.
 
@mjolka ditto.
 
1:42 AM
@JeroenVannevel Americans have to live with the unfortunate constraint that reasonable alcohol consumption is viewed as bad as excessive alcohol consumption. It's pretty stupid, really; IMO.
 
that and the whole 21 years old thing
 
Canada is a lot more permissive, thanks to absence of prohibition and more Europe-like laws
 
@Hosch250 Sure, whatever. At least you told me
 
do you have to put your alcohol in paper bags on the street?
I recall reading something like that
 
@Quill I had to be told that too
 
1:43 AM
@JeroenVannevel I think it depends on which state
 
Such a silly thing
 
I've never seen it, and my neighbors drink regularly.
 
Are these Community Challenges monthly?
 
As for recycling, yes.
 
Lots of stores will bag your alcohol in a paper or plastic bag by default
 
1:44 AM
@JeroenVannevel you don't? not even for open containers?
 
In Ghent you often see students drive around with crates of beer on their bikes
I typically keep my jenever bottle in one hand while I'm driving
 
We have big green bins with a yellow cover for the recycling company to pick up.
@JeroenVannevel Whoa, you'd get a DUI here.
 
@mjolka I don't what? What's an open container?
 
@JeroenVannevel USA is very strict about having an open alcohol bottle in your possession.
 
Oh, open like that
 
1:46 AM
(i.e., unsealed)
 
@Legato not really. at one point we just say "hey, it seems like it's been a while since the last , shall we?"
 
I see, okay, neat.
 
Lol no, people walk around with beer cans all the time when they go to parties
 
Do you track how often people are posting questions with the tag/adding the tag?
 
@JeroenVannevel What about liquor?
 
1:46 AM
Same here.
 
beer/wodka/jenever/malibu/etc
 
You just can't go driving/boating/whatever while drinking.
 
@JeroenVannevel Will you sponsor me to immigrate to Belgium?
 
@Legato the system does that - click here:
> 70 questions tagged, 3 featured
 
In exchange, I'll handle all the JavaScript you throw at me on your behalf ;D
 
1:48 AM
Besides, it's not like anyone would enforce it either. There's no army of police patrolling the street at night
 
@Mat'sMug Isn't that the total amount of questions with the tag though? Or does the tag disappear/reset?
 
@sᴉɔuɐɹɥԀ tempting..
 
yeah it is.. but you can tell what challenge they relate to just by looking at the titles ;)
(sort by "newest")
 
I mostly meant if it's being checked on a weekly basis. I'm sure it makes sense to say "Seems like it's been a while, let's have a new one" but I was just wondering if there's an actual system in place for seeing how many you have over a period of time.
I see.
 
@Legato SEDE and SQL?
 
1:50 AM
nah, it's all pretty informal
 
By the way
<-- what's this number?
You guys have it too.
 
networkwide rep
lala
darn it
more spam
 
Network as in all of stackexchange?
 
This
Is
My
Earned
Rep
 
1:52 AM
that 26k from SO, 8k from CR and a bunch from other places
 
Makes sense.
Hmm, "earned rep" So not counting the +100 bonus they give you ,right?
 
it started with @rolfl bitching about a pretty bad implementation of rock-paper-scissors in Python IIRC.. so he suggested we all implement our own over a weekend.. ah, got the meta post:
20
Q: CR Weekend Challenge

Mat's MugThose of you that weren't following what's going on in the chat room might have been taken by surprise by a recent avalanche of Rock Paper Scissors Lizard Spock posts. This is how it started: OK, weekend challenge.... we all solve the Rock Paper Scissors Lizzard Spock problem with our 'favou...

 
1.4k (exact) from PPCG, going on 7K here.
No, counting that too.
 
Only reason I didn't guess that's what mine was since it didn't add up.
Really?
 
Well, I think.
 
1:53 AM
I don't think so.
 
Hmm.
 
I have 2.7k on CR, and 3k in total, but I'm a part of 10 other sites, not that I use them much.
 
Oh, the number is maybe cached?
 
Seems like it's only really counting my CR + SO rep, which are the only sites I've gained anything from, which again, makes sense.
 
Maybe it refreshes weekly like SEDE?
 
1:55 AM
Yeah, I thought that too.
 
nope. hold on.
@Legato check again
^^ above says 3,093
now should say 3,103
 
I don't always see it. xD
But I do believe you, thank you for the upvote. :D
Still though...not sure where exactly the numbers are coming from.
 
it
takes
4
lines
 
I see 3093
Ohhh, thanks, that makes sense.
 
ah, must be the 5-minutes lock-in delay
 
1:57 AM
Guess it takes a while to update.
 
I've seen it increase as the chat goes
 
On Sundays when SEDE updates?
 
I hardly ever chat on Sundays
 
Oh, I don't know.
 
must have been monkey rep. grows faster than SE can cache it.
 
1:59 AM
@Mat'sMug Saturday night for us.
 
That 24h lock is probably a good thing. I think I'd probably start a bounty bonus giving spree otherwise.
 
7PM for me (daylight time).
@Legato You've gotta have some rep.
Also, the more rep you have, the more people vote on you.
 
^^ true
 
Ah...
 

« first day (727 days earlier)      last day (3283 days later) »