Monthly Archives: June 2013

HS Day 20: Sleeping In (Again)

I seem to have a problem with Thursdays – I woke up around 1pm today and didn’t get in to Hacker School until 2:30. I had planned on actually being social and joining some people for lunch today as well, which I was sad to miss. Nobody in particular, but I’ve been eating a lot of lunches on my own and I want to start hanging out with people a bit more.

Speaking of, Javier is into SC2 (although he watched more Brood War), so we’re going to put together a little party for the MLG spring championships next weekend at Hacker School. We’ll see if anyone else ends up showing up, though. I’m not sure how many fans of SC2 there are at HS, since it’s kind of a specific hobby.

I spent the afternoon putting together the technical blog post for LACE, the Latency-Aware Collision Engine, which you can read right here on my blog! I came up with the acronym  this afternoon as well 🙂

At 5:30 I gave a 2 minute presentation on the engine, and then after everyone else’s presentations, gave a short demo of the tag game I’ve been working on implementing.

Hung out and talked StarCraft with Javier afterward, then played some SC2 on my own and surfed the web until 8:45, at which point I hopped on the 1 to Penn Station, where I got on an Amtrak to Washington D.C. to visit my Dad for the weekend!

From an Amtrak train somewhere on the East Coast,

–Erty Seidel

A Fix for Ultimate Tic-Tac-Toe?

A few days ago, Ben Orlin of mathwithbaddrawings.com posted Ultimate Tic-Tac-Toe, which described a nested game of Tic-Tac-Toe – In lieu of describing the game again, I’ll direct you to his post if you haven’t already read it.

The problem with UTTT is thus: the Orlin Gambit is too strong, and Ben admits it in his later edit. There, he says that sending a player to an already won board means that they can go anywhere.

This means that a game start goes like this. X takes the center, which forces O to take a non-center square:

uttt01

uttt02

Then X can take the center again, forcing O again to take a non-center square. Since the center square is more desirable than any other, by a longshot, the game almost deterministically ends up in this state:

uttt03

But with the new rules, O can now take any large square they like, but if they take a center small square, then X will be able to choose where to go. Assuming that center squares are the most desirable, the game will end up something like this. (Someone with more time should investigate if there is a better move for O when they get their first free move…)

uttt04

Notice that it is X’s move, and they already have the center square in 2/3 of the squares! That said, O does have the center square overall, so perhaps this is balanced? It just seems like a lot of moves forced by the game, since the player has otherwise made a “bad” move and worsened their position.

More analysis is needed to see if O taking a not-center-small-square for their fourth turn would turn out well.

So, to fix this, I have a rule change that should alleviate this problem: If a player chooses the center square of a small board, the other player can choose any large board to play in. For example, if X takes the center of the center square on their first move, then O can take the center of any other square.

So now we have a starting game that looks like,

X takes the center of the center:

uttt01

Since X took a center square, O can choose which large square to play in:

uttt05

Now X chooses which large square to play in:

uttt06

But this means O also gets to choose a square! By now, the game is already up to the players! So we don’t have a forced game past, perhaps, the first move or so. Eventually we will end up with some configuration of (assuming center squares are desirable):

uttt07

So here, O has at least one more square! And since our assumption that center squares are desirable probably doesn’t hold, either player could force the other to play in a side-large-square at any point up to this.

I hope this “fixes” the game of Ultimate Tic-Tac-Toe and makes it a fun and much deeper game for everyone! I’ll work on getting a javascript version here on the blog eventually. (I’m going to D.C. for the weekend so no promises).

From an Amtrak Train somewhere in New Jersey,

–Erty Seidel

 

 

 

LACE: Latency-Aware Collision Engine in Javascript

Code for this is at https://github.com/ertyseidel/collisions

Motivation

In a multiplayer game, it is useful to be able to do collision detection on the server, to ensure that your players aren’t cheating or moving incorrectly. When we take latency into account, and the other myriad problems that can come about when we deal with packets, this problem suddenly becomes very difficult.

Say we have three players (p1, p2, p3) and they each have a client that sends packets containing location data to the server. To keep things simple, we’ll say that these packets contain the player’s coordinates (x, y). So, mapping these players at t=0, we get:

fig-1

The server knows these positions, so we can assume that we have a fully updated representation. Then time begins to pass, and the players start to send updates with their new locations. At t = 10, let’s say we receive a packet from player 1. Thus we are in the following state:

fig-2

 

Player 1 has moved, but players 2 and 3 haven’t received any updates from their clients! If we have a collision here, there’s no way to check yet. There’s no guarantee that player 2 isn’t colliding with player 1 right now according to player 2. Let’s run a few more frames:

fig-3

 

Can you spot the collision? Answer: Right in the center, where 1 and 3 cross, at time 18 or so (assuming each snapshot took 10 time).

Algorithm

So obviously we need some sort of interpolation and time-checking for this! Let’s look at how the main update function works.

The first thing we need to do is figure out what “step” we’re on. We do this by setting a stepSize, something like 25; this is the “bucket size” for each time step on the server.

E.g., with a step size of 25, all the packets received between time 100 and time 124 inclusive will be in the time = 100 bucket.

Let’s get some packets! We start out with knowledge of all our players positions at time 0 (It’s actually more complex than that and handles players entering/leaving, but for now let’s say we know where everyone is at t=0).

Then we get a packet from player 1 at t= 56:

But let’s say the next time we get a packet is at time 105, from player 1:
fig-4

The next thing we do is interpolate player 1’s position for the missing row, t=25. We do this by linearly interpolating between P1’s x and y values, given the time between the updates (green values are interpolated):

fig-5

 

Now let’s get a packet from P2 and P3 in the T=100 bucket. Then we do collision detection on P2 and P3 at t=100, since there is more than one data point at that timestamp.

fig-6

And interpolate the values of P2 and P3 back to t=0:

fig-7

 

Right here, we perform collision detection between P2 and P3 at t=75, and between all three players at t=50 and t=25. Essentially, whenever we add data to a row, we do collision detection against the other existing data in that row. This means that we don’t have  to wait until all of the data for a row are in before we try collision detection across them. It also means we can detect collisions in the past, and the game can retroactively decide to act on that collision, or not.

There’s one last step at this point – we remove the rows at t=0 and t=25 since we’ve already collision checked all of the players at these points, and t=50 is the data from which every player will interpolate from this point forward. Thus our table ends up looking like:

fig-8

until we receive more data from the users.

There are functions dealing with adding and removing users, but you’ll have to explore the code to see that.

Todo

Setting a step-size that is much smaller (I use t=5ms) allows us to do very fast server-side collision checking. This is nice, since we don’t have to do collision detection AND rendering on any given computer.

The main problem facing this is that we currently only do collision detection against other players  – I have no idea how it will fare with more complex objects or things that don’t move.

I’d love to see if this library works for other people writing javascript multiplayer games, and since this is alpha-level development, forks and pull-requests are greatly appreciated!

From Manhattan,

–Erty

 

 

HS Day 19: Nearing Success. Also, Internet.

Started the day on time at Hacker School, in a new morning meeting group: Russel, named after Steve Russell, the inventor of Spacewar!, one of the first videogames. He also did some of the first implementations of LISP, way back in the day.

Thomas, Nina, Carl, Tom, and George will be the new faces I see every morning, although I’m sad Jimmy isn’t in our group (Russell, Jimmy, get it?).

Spent the morning working on the collision detection library. I feel bad, because I kept telling Jade that I wasn’t going to work on it anymore, then I would start doing something else, and then I would suddenly know how to fix the library and would go do that. Then I would show Jade, and she would be, good job not working on it.

Went to Pret for lunch, then took the subway home, because it’s internet time! I’ve been tethering from my phone for the last 19 days since there’s no internet at the apartment, but since I had some room in my budget, I called up Time Warner and had them install internet today! The guy was super nice and the setup was very fast – It was a bit offputting, since I spent the last year battling TWC’s YouTube throttling practices at school – so I was ready for a battle which never came.

We had to climb around the building quite a bit to find the cable input, and it turns out whoever remodeled the building last cut a bunch of the cables right at the wall so that they’re unusable anymore. Luckily, the one cable they left happened to be the one that connected to Imogen’s room, so there’s a router and modem on her window now.

But yeah, 15 MBps internet at the apt, woo!

Took the train back to Hacker School and worked with Jade and Mary on the collision library. Actually – it works! Mostly! It crashes every once in a while on a corner case, but the basic functionality is going strong and I was able to implement a simple game of tag using it! I want to finish the technical blog post about it tomorrow so that I can present it and have the details online for people to look at.

I called Greta on my way to Chipotle for dinner, and she convinced me to try somewhere else. Probably 50% of the meals I’ve eaten so far in NYC have been Chipotle.  I tried a cafe that I had been to before, but it was closed. I tried a cafe that I hadn’t been to before, and it was closed too. So I went to Chipotle.

I also really want to do a non-technical presentation for everyone (on “why do we make tech”) but I haven’t had time for it (too much SC2, testing out the new internet! )

Went home around 6, finished the second draft of a résumé, and played a bunch of StarCraft with Mike! It’s nice to be able to play instead of just watch (since my phone has good throughput but bad latency.

Blogging, Bed.

From Brooklyn.

–Erty

Keeping track of your competency as a programmer

Especially for Hacker School students, but really for anyone: If you’re looking for a way to discretely measure your progress through Hacker School, check out the following resources:

If you don’t really know what you want to work on, choose whatever is your lowest level in the Programmer Competency Matrix, or an example in the eight levels of programmer that you don’t understand, and ask someone more knowledgeable about it!

From Brooklyn,

–Erty

HS Day 18: Debugging and Poker

Spent a while on the phone with Time Warner Cable last night before going to bed. Since rent here is under what I had budgeted, but the apartment doesn’t have internet (I’ve been using my phone), so tomorrow between 2-4, I’m getting 15MBps internet installed. Still well within my budget, and now I can play StarCraft at night 😀

Last night I decided to put my phone on the other side of the room when I go to sleep, so that I have to get out of bed to turn off my alarm in the morning. It worked – I was on the subway right on time this morning to get to Hacker School at 10:30.

Every morning at Hacker School we meet with a group of 6 people and tell them about our projects and goals for the day. I met with my morning check-in group for the last time today, at least in its current form; we’ll be meeting with new morning check-in groups starting tomorrow. My check in group was really cool, but I’m also excited to get to know new people through the morning check-in groups. I like the check in groups – for one, it keeps me honest about at least trying to show up on time, because I know that there are people expecting me there at 10:30. It’s also great to have a place where we can talk about our accomplishments without feeling like we’re bragging. It’s important for people who are learning to have encouragement from their peers, and the morning meeting groups are a great place for positive feedback.

After morning meeting I made a breakfast run to Jazzy’s where I got a bacon egg and cheese bagel. It was delicious – they make it right in front of you with just the basic ingredients, which at least feels healthier than getting the same thing from a fast food stop. Mainly because the egg is actually egg, I think.

Mel, the current resident, gave a talk starting at 11 about learning styles and how they relate to programming and hacker school. We started out by taking a survey about learning styles (you can take it yourself at http://www.engr.ncsu.edu/learningstyles/ilsweb.html). I scored Global/Intuitive/Visual/Active, which I pretty much already knew, but it was good to get the words to attach to it.

Afterward I spent some time working with Derek on his website, mainly updating the CSS to reflect a more modern and clean design.

Then I spent at least 2.5 hours working with Jade on the collision detection, mostly bugfixes.

At that point, I was totally burned out, and put out a call on the internal chat for anyone who might want to hang out with me, play chess, get dinner, etc.. Nabil answered the call and we played chess (I won but only barely – and he let me take-backsies a couple of moves), and then we played portal chess (I won the demo game and he won the real game). It was a lot of fun, and it was great to get to know Nabil; he taught high school math before coming to Hacker School, which is something I might end up doing some day.

I ate a Chipotle burrito and watched some WCS (StarCraft 2), then played some games with Javier, Dan, Nick, Pedro, Alan, and Sunil. We chatted and had a beer, which was a lot of fun. Headed home on the D train afterward, which makes my walking a lot shorter on the Manhattan side, but longer on the Brooklyn side. The Brooklyn walking is a lot quieter though, so I think this might be my new route. The D only makes two stops before mine as well, so no more worrying about express/local trains.

Got off at Barclays Center / Atlantic, and walked to Target (running into Alyssa on the way in!). Bought a table and a wifi router for the new internet, and walked home with the table on my head.

Chatted with Greta and Evan, blogged, derped on the internet, and now it is time for bed. Internet tomorrow!

From Brooklyn,

— Erty

HS Day 18: Collision Detection

Woke up this morning around 10:30, which is of course when I’m supposed to be at Hacker School. Emailed Nick to tell him that I was going to be late, and started heading into the city.

The R seems to be running express these days, so the trip was a lot shorter than usual. I think I’m starting to figure out where and when to switch trains, although I still can’t figure out which ones are express/local and when. The Q seems to get me in to town fast (across the bridge) so I’ve just started aiming for that one all the time, and the walk on this end isn’t terrible (about 12 blocks if I don’t get lost).

Spent pretty much all day at Hacker School working on the collision detection for Node Tag with Jade, who happens to also be working on a javascript multiplayer game and needs the same thing – a server side collision detection library. Mel (the current resident), Richard, and… Mike? (Can’t remember his name right now) all helped out while we were drafting the ideas on a whiteboard. It’s… complex, but under 100 lines of code so far. For the main library, at least.

We’re most of the way done with it, but there’s some final debugging to do. I’m planning on posting a technical article about it on here tomorrow.

Working on the collision detection library.

Working on the collision detection library.

I wasn’t feeling well at the end of the day, so I sat in a hallway, ate chipotle leftovers, and watched the final match of Dreamhack 2013! Tuned in right as it was starting – serendipitous. Also just spelled serendipitous right the first time, which is pretty much anti-ironic.

Took the 1 to the ebay offices with Richard, who is a New Yorker and knows his way around the city. I am seriously considering buying a compass so that I can know which way to turn when I leave a subway.

Mel’s talk was excellent – it covered programming and education, both of which I am very interested in. She tied theories of education into theories of programming (how is learning not like test-driven development and what does that mean?). Tomorrow she’s giving a talk on learning styles which I really want to attend.

Left after the main lecture because I still wasn’t feeling all up to snuff. Started feeling better on my walk home so I sat at a cafe and helped a Lawrence student access the Gaming Club Steam accounts. Walked home again, went out again and bought some beer, walked back home. Had one beer, watched some starcraft.

Decided to sign the apartment up for internet, since it’s well within what I budgeted for housing, and working off of my phone has started to get frustrating. It’s great for emergency internet but not the best for streaming video, playing SC2, etc. So, internet for the apartment. The wait time for TWC was long, but the rep I got was really nice and helped me set everything up quickly. Probably one of the better experiences with customer service I’ve had in a while, actually. Now if they just didn’t have a monopoly or throttle YouTube…

I digress. Today was a good day and now it’s time to post this on the internet and go to bed.

From Brooklyn,

–Erty Seidel

 

HS Day 16 & 17: StarCraft

By combining two days into one post, I’ll be able to catch up to today and be back on schedule for blogging!

I mentioned in my last post that I fell asleep without setting an alarm (on purpose). It was very nice to sleep in, and I woke up around 1 of my own volition. Hungry, I walked down all the way to Barclays Center, about a dozen blocks from home. I saw Luscious, which happened to be the sandwhich shop that Nick and I went to on our way to Punderdome. I got an Italian sandwich and sat outside, but the wifi wasn’t very fast, so I packed up and went home.

The awesome patio of Luscious sandwich shop. If only they had better wifi...

The awesome patio of Luscious sandwich shop. If only they had better wifi…

About 3/4 of the way home, I realized that I hadn’t paid for my sandwich! So, I walked back and paid. On the way, though, I noticed a little coffee shop called Venticinque, which seemed nice and sold iced chai. So I sat there for about three hours and worked on a résumé for my résumé service, and watched… Dreamhack? WCS? I’m not even sure anymore. I watched some StarCraft 2.

Saw this in a window while out walking around. Lol'd a little.

Saw this in a window while out walking around. Lol’d a little.

I then got a hankering to play some SC2. But! There are no tables at the house! So I tried to play on the floor, on the couch, on the kitchen counter. Nope. So I took the bus in to Manhattan and sat at Hacker School until about 2am, playing StarCraft and looking up strategies for the LAN the next day.

STARCRAFT :D

STARCRAFT 😀

Took the train home and went to sleep. I still can’t figure out which trains are local/express when. I’m beginning to think it’s random.

This morning (It’s today, now!) I woke up around 10, and took the R into Manhattan, where I caught the 7 into Flushing. (lol flushing lol okay I’m done). There was a mom and kid across from me who started chewing gum, both making smacking noises for five stops or so. That kind of thing doesn’t really bother me but it was amusing that they both did it. The kid dropping the wrapper on his way out bothered me though. I’m really trying to get over my visceral reaction to littering, since the city is pretty much entirely man-made anyway. I can understand being angry about finding trash in wilderness, but NYC is pretty much as far away from wilderness as one can get. Still, I have an almost physical reaction to people dropping trash, so it might take me a while to get over that.

For anyone wondering, that’s the #1 reason for my near-hatred of people who smoke. I have been known to yell at people who drop their cigarette butts on the ground in front of me. Not in NYC, so that’s… an improvement, if you look at it that way? Also I can’t stand being around people who smoke because it makes my eyes itch. Your freedom stops where someone else’s freedom begins. Do they have a right to smell like smoke or do I have a right to fresh air?

I arrived at the Cybercraft internet cafe around noon, which is when the tournament had been posted to start, but there wasn’t really anyone there. I bought a membership at the cafe and bought into the tournament ($35 total, which wasn’t too bad, considering New York). The main thing that weirded me out was that there was no music playing at the cafe, so it was just the clicking of mice and keyboards. Eventually the cafe started filling up, though, and I found myself sitting right next to none other than Axslav! He’s a professional caster and ex-pro player, and we chatted about new york and stuff. He’s pretty well known in the SC2 scene though, so it was super cool to get to chat with him – and play against him for a match! He destroyed me, of course.

I lost 2-0 and 2-0 in the tournament (results here – I am “Revx”). Someone (not a hardcore gamer, by the sound of it) asked, “Why do non-pros even show up, if they know there are going to be pros here?) Answer: Because it was still an awesome experience, and I got a lot better by playing against and watching matches by people who are a lot better than me.

I also met Yuna, one of the translators and organizers for Clarity Gaming (based in Long Island). She was super nice and chatted with me about Clarity for a while, as well as just general talk about the area. I really enjoyed being able to hang out with people who really have a hand in eSports in such an informal atmosphere. I might have nerded out a bit on Axslav a bit, though, so if you’re reading this, I’m sorry for being a fanboy.

Caught the train home around 6 and didn’t get here until 9, mainly due to getting lost in Brooklyn (I went north when I should have gone south). I spent the time chatting with my dad, though (happy fathers’ day!), so that was good.

Now I’m just blogging and derping around on the internet. Gonna head to bed soon – I’m tired from gaming all day, and ready to get back to programming tomorrow. Well, or more gaming.

As I noted today, programming and pro gaming are only a few letters apart…

From Brooklyn,

–Erty

 

p.s. Photos from the concert on Friday!

The stage, from where we were sitting. I did promise not to complain :)

The stage, from where we were sitting. I did promise not to complain 🙂

Wooooo!

Wooooo!

Barclays Center from outside, after the concert.

Barclays Center from outside, after the concert.

HS Day 15: The Postal Service

Today started out okay but ended up excellent. I intended to go to a tech talk in DUMBO, which is in north Brooklyn, but ended up sleeping through my alarm. I was supposed to be at Hacker School at noon to run a D&D campaign, but missed my stop on the subway and ended up about three stops north of where I was supposed to be. So, I called an Uber (which took 10 minutes to arrive), and then got stuck in traffic. What was supposed to be a 25-minute subway ride ended up taking an hour and a half.

I ended up not playing D&D anyway, since there was only one person – Matt – at Hacker School who wanted to play. Ian showed up a bit later, but at that point we had pretty much given up on playing anyway and rescheduled for next Friday… which I just realized I won’t be here for, so I guess the Friday after next is when we’ll start?

Joe came over and helped me out with a weird bug I was having with my Node.js multiplayer tag game. I’m really hoping to implement collision detection on Monday and get that project done and over with so I can get back to Budgeted. I really don’t want to have any projects that I start and abandon at Hacker School. Since I have the time, resources, help, and energy to actually complete things here, no excuses.

A while ago, I mentioned that I was going to see The Postal Service – today was that day. I left my backpack at work and took the E to the into Brooklyn to Barclays Center, where the show was going to be.

Turns out my friend from Conserve, Chris, was also going to the show along with his Girlfriend, Haley. I met up with them at Barclays Center, and we quickly found that there were very few places where we could get dinner. We ended up going to Applebees, which was packed but not overflowing with people like a lot of the other places we tried. We chatted about Conserve and reminisced for a while, ate our food, and arrived at the show about halfway through the opening act, which was a husband and wife synthpop band. I said goodbye to Chris and Haley there and met up with Amandine, who was the other person who had purchased tickets from Yael.

Amandine and I talked about Hacker School and physics and stuff for a while, then turned our attention to the stage as The Postal Service came on.

I’m not going to say any of the things that were wrong with the concert, because I’d much rather focus on the amazingly cool things about it.

“Hi Brooklyn” – Ben

“Hi Ben” – Brooklyn

The Postal Service has not released an album in ten years. The lead singer – Ben Gibbards, is the lead singer of one of my other favorite bands – Death Cab for Cutie. I love the lyrics of both groups, and of the 32 albums I keep on my phone, 9 of them have Ben Gibbards as the lead. To be able to sing along with him was really cool.

My favorites were  Recycled Air, We Will Become Silhouettes, and of course, Such Great Heights. The crowd all stood for that last one, and we danced and sang along. Ben acknowledged how amazing it was that he was on a sold-out tour for a ten-year-old album. I will reiterate that this is one of the 32 albums I keep on my phone. It’s one of the most meaningful and self-relevant albums I own.

They ended with Natural Anthem, which breaks down into noise, and finishes with a kind of catharsis, which was a great choice. The crowd cheered for a full five minutes, and then they came back on for an encore with a new song as well as Brand New Colony, which ends with them repeating “Everything Will Change”, which the crowd sang along with. A sold-out crowd. They only have one album which came out long ago so everyone knew the lyrics.

It was awesome.

I looked into getting tickets to see Vampire Weekend or Phoenix, but I won’t be in NYC for either of the dates. Sad day. Definitely going to go to more shows in Boulder/Denver.

Realized that I was actually about 10 blocks from home, and that I should have brought my backpack with me and dropped it at the apartment. Sigh. Took the subway into Manhattan and picked up my stuff at Hacker School and headed home – learned that I had been taking the slow train this whole time (since the slow train wasn’t running I had to take the fast train) so hopefully that will speed up my commute a lot from now on. I just have a bit longer of a walk, but home is 3 stops instead of 10.

Drank a beer and surfed the internet until about 3am, at which point I fell asleep without an alarm set because I had nothing to do tomorrow. Yeah.

From Brooklyn,

Erty

HS Day 14: Thursday

I’m writing this on Friday, because somehow I managed to not blog yesterday! This will be a short post so I can get on to Friday.

Took the R into Manhattan in the morning and arrived at Hacker School right about on time. Gave a presentation on MySQL and relational databases to a group of interested people (I forgot to mention: I gave a presentation on sockets and network programming on Wednesday).

Worked on my Node.js app (previously Wanderer, now NodeTag) for a while, implementing some prediction on movement as well as smoother player movement. I met with Mary – one of the facilitators and an expert on javascript gaming – for half an hour and she gave me some great advice about how to proceed. It’s going to take quite a bit of work to implement, but the main idea is to do interpolation on player movement between updates.

I did another non-technical presentation (this will be my last – the facilitators asked me to focus on technical from now on, which is fine) about using different viewpoints (e.g. first or second person) when writing GUIs. I think it’s very important to have a good user/software interface, so I’m very interested in minor details like this.

Stayed a bit late and played some StarCraft – I’m going to a LAN on Sunday and I want to not be too terrible. That said, I lost all my games.

There were some people at Hacker School sitting around drinking beer and playing munchkin when I left. I was going to join them, but  I wanted to get up early the next day for a tech breakfast in DUMBO.

From Brooklyn,

Erty