Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Xik
Mar 10, 2011

Dinosaur Gum

Stick100 posted:

In short TDD is NOT recommended for game development for these exact reasons. Instead when you have an issue you want to implement, go implement it and afterwards consider if a covering unit test might be worthwhile. In some cases it will but in many it won't, unit tests can be great for code logic, but be very careful to not use too many as it can kill your ability to adapt (which is the essence of early game development).

It's arguable that if you are writing tests that break when the implementation changes, then they weren't good tests to begin with. Unit tests aren't for testing your implementation details.

If you have an hour to spare, this talk by Ian Cooper titled "TDD, where did it all go wrong" is pretty good. It definitely stamped out some incorrect assumptions I had about unit testing.

The closest I ever came to "Game Development" was some poo poo little roguelike made for a 7drl challenge. It was written in Javascript and had no unit tests. So I can't really talk about how the knowledge applies to game development. I guess in a perfect world, you test the "outside" api of the core logic of the game which is separated from anything else. In practise, I have no loving idea how that would work with something that traditionally relies so heavily on state like a video game.

On a sort-of-but-not-really related note. I recently read about the concept of the Component-Entity-System through a blog post by Chris Granger. I could probably see that approach being easier to unit test, but is starting to seriously drift away from the "how do I unit test" question.

Adbot
ADBOT LOVES YOU

Flownerous
Apr 16, 2012

Xik posted:

It's arguable that if you are writing tests that break when the implementation changes, then they weren't good tests to begin with. Unit tests aren't for testing your implementation details.

Edit: just realised this is basically what you said towards the end, my bad.

I think the main problem is that games are simulations (of fantasy universes in most cases), and so it's often hard to define a test for whether the simulation ran correctly. Even physics is difficult to predict without running the simulation yourself.

You try to ask "What is the postcondition of a jump?" and test for it. But the answer changes as the game design changes.

I'm also a game developer with zero understanding of TDD so maybe I have it wrong.

Flownerous fucked around with this message at 10:14 on Apr 3, 2014

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
It is also worth mentioning that TDD was largely popularized by users of dynamically typed programming languages like ruby and python. Strongly typed languages provide a safety net for common programmer errors, and often a large portion of TDD style test cases are devoted to verifying trivial integrity properties of programs which would be entirely unnecessary in a strongly typed language.

Problems which have well defined inputs and outputs and operate as a pure function (like a parser or a sorting algorithm) lend themselves well to automated testing, and when you find yourself solving this type of problem TDD can be an appropriate and helpful tool. Problems which are more like a continuous simulation with lots of persistent state evolving through time in response to inputs (the main portion of most games) are poorly suited to automated testing, and TDD can lead to tremendous incidental complexity for little benefit. Use the right tools in appropriate situations.

Paniolo
Oct 9, 2007

Heads will roll.
Yeah, TDD only ever made sense to me when working in a dynamic interpreted language where you have no idea if there's even syntax errors in your code until it's executed. There you need test coverage even of otherwise trivial code because it's basically replacing a lot of the static error checking that a compiler would do. (I have no idea why people don't realize this overhead completely wipes out any perceived productivity gains from working in those languages, but whatever.)

seiken
Feb 7, 2005

hah ha ha

Internet Janitor posted:

It is also worth mentioning that TDD was largely popularized by users of dynamically typed programming languages like ruby and python. Strongly typed languages provide a safety net for common programmer errors, and often a large portion of TDD style test cases are devoted to verifying trivial integrity properties of programs which would be entirely unnecessary in a strongly typed language.

Problems which have well defined inputs and outputs and operate as a pure function (like a parser or a sorting algorithm) lend themselves well to automated testing, and when you find yourself solving this type of problem TDD can be an appropriate and helpful tool. Problems which are more like a continuous simulation with lots of persistent state evolving through time in response to inputs (the main portion of most games) are poorly suited to automated testing, and TDD can lead to tremendous incidental complexity for little benefit. Use the right tools in appropriate situations.

I can't find the "like" button. How do I tweetshare this?

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!
Why do the Unity BitStream.Serialize() overloads have char, but not byte, when the documentation explicitly tells you that if you serialize a char only one byte will be serialized? I can't imagine any scenario where this is useful, and it causes me to have to allocated buffers twice the necessary size while they sit perpetually half-empty. Plus I have to cast between char and byte all over the place. Anyone reading my serialization code will think I'm insane.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
What that lecture calls "BDD" has actually gained some traction in game dev in the form of bots, which are really neat, but they have to be planned for early.

Small, isolated tests are incredibly difficult to make in a game where very few things act in isolation and it's difficult to get a program state suitable for input.

OneEightHundred fucked around with this message at 06:34 on Apr 4, 2014

Scaevolus
Apr 16, 2007

Internet Janitor posted:

Problems which have well defined inputs and outputs and operate as a pure function (like a parser or a sorting algorithm) lend themselves well to automated testing, and when you find yourself solving this type of problem TDD can be an appropriate and helpful tool. Problems which are more like a continuous simulation with lots of persistent state evolving through time in response to inputs (the main portion of most games) are poorly suited to automated testing, and TDD can lead to tremendous incidental complexity for little benefit. Use the right tools in appropriate situations.
If you have a deterministic game engine, you could record inputs and check that changes you make (optimizations, refactorings, ...) that shouldn't affect behavior don't by comparing game states.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Scaevolus posted:

If you have a deterministic game engine, you could record inputs and check that changes you make (optimizations, refactorings, ...) that shouldn't affect behavior don't by comparing game states.
"Record inputs" doesn't work well in practice because changes that deliberately affect behavior are frequent, which invalidates recordings. Recordings and deterministic simulations are really good things to have, but the main point of an automated test is that you don't have to remake the test. That's why I really wouldn't recommend the automated test route unless it involves making bots.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Flownerous posted:

I think the main problem is that games are simulations (of fantasy universes in most cases), and so it's often hard to define a test for whether the simulation ran correctly. Even physics is difficult to predict without running the simulation yourself.

You try to ask "What is the postcondition of a jump?" and test for it. But the answer changes as the game design changes.

Many programs are like simulations: take initial state, perform operation, capture result state. If that operation depends implicitly on a lot of non-input state, it's hard to test, but with TDD you sort of inherently avoid that, because you ipso facto have code that's reasonably testable.

You probably reason about the mechanics of the game in relatively isolated ways: "when they press jump, they arc through a height of X units and end Y units farther ahead." Not "when there's lava they jump over it if they jump from this close." One test approach could be to put the player at an origin, initiate a jump, track the height as you advance the simulation, and run a few steps of the simulation beyond where they hit back to zero to make sure they don't end up too low or whatever. This is easier if your player/physics logic is distinct from rendering and game setup, but many things will be.

I was a TDD skeptic for a long time, until I realized that it wasn't a way to end up with the same code and some more tests. You end up with different code, as an effect of writing it with tests front of mind. You might or might not find that different style of code to be desirable, but I found it way easier to work with, especially when I was iterating on a lot of parts and wanted confidence that changing the log format hadn't broken something else. The core of tests are that same kinda-functional input->output verification that most behaviour comes from (for me). If the code is amenable to testing, I'm also just more likely to actually write tests.

I'll admit that I'm a bit lapsed and sometimes end up trying to retrofit tests (usually after some very frustrating bug was introduced); I almost always wish I'd has tests in mind all along. The *trivial* game stuff I've done has so far let me write non-graphical/command-line tests for most mechanics, though it was annoying to build map/board state in some cases until I wrote a bit of tooling. The systems that were tied deeply into some other state were the ones that caused clenching when I had to change them (like shaders).

My background definitely influences my position here, though. I spent a decade-plus working on browsers, where test-friendliness of things determine whether "make sure we handle network timeout well" is :smug: or :emo:, and things like system text measurement can ruin your day. Diffs that decoupled systems were acts of righteousness, because they made things easier to work with, and less likely to suffer from breakage at a distance.

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:

Internet Janitor posted:

It is also worth mentioning that TDD was largely popularized by users of dynamically typed programming languages like ruby and python. Strongly typed languages provide a safety net for common programmer errors, and often a large portion of TDD style test cases are devoted to verifying trivial integrity properties of programs which would be entirely unnecessary in a strongly typed language.

Problems which have well defined inputs and outputs and operate as a pure function (like a parser or a sorting algorithm) lend themselves well to automated testing, and when you find yourself solving this type of problem TDD can be an appropriate and helpful tool. Problems which are more like a continuous simulation with lots of persistent state evolving through time in response to inputs (the main portion of most games) are poorly suited to automated testing, and TDD can lead to tremendous incidental complexity for little benefit. Use the right tools in appropriate situations.

Interesting discussion about all of this. Although I should have pointed out that for the particular case I'm interested in using TDD for is a tool, rather than a game.

The issue that I'm trying to resolve is that a lot of things in the tool are interconnected, and I need to make sure that everything is updating its values correctly in a predictable way. Also there are several operations that can be performed that need to be communicative, so moving, rotating and scaling an object yields the same results as scaling, rotating and moving an object.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

AntiPseudonym posted:

Interesting discussion about all of this. Although I should have pointed out that for the particular case I'm interested in using TDD for is a tool, rather than a game.

The issue that I'm trying to resolve is that a lot of things in the tool are interconnected, and I need to make sure that everything is updating its values correctly in a predictable way. Also there are several operations that can be performed that need to be communicative, so moving, rotating and scaling an object yields the same results as scaling, rotating and moving an object.

You're confusing validation tests with unit tests. Unit testing is making sure each individual component in your program does what you intended it to do. It's a different kind of testing - validation or integration testing generally - that checks how components interact, and while those tests are incredibly valuable they're not part of TDD.

As to how to write those tests: break your program into smaller pieces and program to interfaces. If your program is so heavily interconnected that you're having trouble accessing the data you need to verify that an operation worked, that's an indicator that your program is badly designed.

ErIog
Jul 11, 2001

:nsacloud:
You should also try to parameterize everything you might ever possibly want to change later on. This makes stuff easier to change later, and then also allows for proper unit testing where you pass various sets of parameters to a function and get testable output back. The functions themselves should be mostly ignorant of any constant values. Algorithms you can imagine yourself trying to optimize for speed later on in development are a good example of a thing you should probably build a test for. You know you'll probably want to adhere to that algorithm, but the details of how that happens are something that might change. Testing can help you avoid changing the algorithm in subtle ways while attempting to optimize it. Places where you think to yourself, "A lot of other pieces of code rely on this thing working a certain way..." are also places where tests can be really useful to make sure that those things, in fact, don't change.

You don't necessarily need to be building tests from the outset and doing a full-on TDD, but building tests in the alpha stage could be massively helpful moving forward to avoid breaking things unwittingly during the optimization or porting process.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So Shader Forge is half off today ($40) and looks really goddamn powerful. Has anyone had any experience with this and is there any reason I wouldn't be able to take advantage of it with a 2D game?

https://www.assetstore.unity3d.com/...#/content/14147

Jewel
May 2, 2009

Yodzilla posted:

So Shader Forge is half off today ($40) and looks really goddamn powerful. Has anyone had any experience with this and is there any reason I wouldn't be able to take advantage of it with a 2D game?

https://www.assetstore.unity3d.com/...#/content/14147

Shader forge is fantastic. I can't think of much it'd help with in 2D though. Could be used, just depends on the game I guess! If you had a big wall with glowy pipes that had a pulse going through them, this would definitely work for that. If you had just plain sprites with normal mapped lighting or something, I'd use builtin stuff.

retro sexual
Mar 14, 2005
Just launched our greenlight campaign for Guild of Dungeoneering today, any votes & shares much appreciated!
http://steamcommunity.com/sharedfiles/filedetails/?id=246445759

Also the trailer is here:
https://www.youtube.com/watch?v=mDyA7h50fjw

Nybble
Jun 28, 2008

praise chuck, raise heck

retro sexual posted:

Just launched our greenlight campaign for Guild of Dungeoneering today, any votes & shares much appreciated!
http://steamcommunity.com/sharedfiles/filedetails/?id=246445759

Also the trailer is here:
https://www.youtube.com/watch?v=mDyA7h50fjw

Upvoted. This definitely looks like it could be some good fun. Love games where you don't have direct control of the character!

Hughlander
May 11, 2005

Unity peep...

Are the extensions compatible with C++ 11 at all? I have a static library for iOS that uses C++11, when making an extension for it I'm having a conflict since the Unity static lib uses the C++ 03 standard library while I need the clang C++11 standard lib. Any way to resolve this?

xgalaxy
Jan 27, 2004
i write code

Hughlander posted:

Unity peep...

Are the extensions compatible with C++ 11 at all? I have a static library for iOS that uses C++11, when making an extension for it I'm having a conflict since the Unity static lib uses the C++ 03 standard library while I need the clang C++11 standard lib. Any way to resolve this?

Weird. I've used C++ 11 stuff as native plugins with Unity without problems before.

RoboCicero
Oct 22, 2009

"I'm sick and tired of reading these posts!"
Eurgh. As a note of warning, if you sign up for AdMob and at any point in your life you want to use AdSense make sure you have an approved Adsense account first. It looks like if you do it the other way around Adsense will pretty much lock you out of using the account forevermore. You could potentially make a new Google Account, but you'll have to be careful that the personal details are different because otherwise Google will helpfully note that it has the same details as an "approved adsense account" and then deny the request.

This seems to have been around for over half a year already. This is barely game development related, but as I was hoping to put up a web version of my game and reap my 2 bucks a month from ad clicks it's a bit annoying having to jump through all these hoops.

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!
Does anyone know of articles or blog posts on the topic of building a diagnostics UI into a 3D and/or multiplayer game? I want to get an early start on this in my current project (alongside getting the networking model ironed out). The sort of thing I'm thinking of are: visualizations of player interpolation/server-position/extrapolation, stats on player latencies and packet dropping, probably other stuff I didn't think of yet or forgot.

I'd also like to create a debug UI for tuning network features so on a client I can do stuff like disable syncing to server, or disable prediction etc. without having to rebuild or even leave the game. But I think I already have an idea how to build that UI (although if there's a really good write-up on that then I want that too!).

Hughlander
May 11, 2005

xgalaxy posted:

Weird. I've used C++ 11 stuff as native plugins with Unity without problems before.

I misspoke, what I meant was CXX standard library. We use libc++ (Clang's C++11 runtime) internally for all projects and Unity is linked against libstdc++ (GNU's C++ runtime.) Which I believe still has issues around things like shared_ptr is still TR1 and not std...

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
What book to the cool kids use to learn Unity these days? I'm pretty familiar with C# so I don't need anything that covers the programming language side of things, just a guide to the Unity IDE and how Unity-specific code snaps together.

Thanks!

Locus
Feb 28, 2004

But you were dead a thousand times. Hopeless encounters successfully won.
I'd say just do one or two of their tutorials, then just google "how do I do _X_ in unity". Every question has been asked in the Unity forums! And they have documentation on all the functions on their site too.

Of course, this requires an Internet connection, so a book has advantages.

dizzywhip
Dec 23, 2005

I agree, I spent a few hours with the project tutorials and that was plenty for me to become comfortable in Unity. I did roll-a-ball and then about half of space shooter and didn't bother with the stealth one. Since you're coming from a programming background that should be plenty to get you started.

Obsurveyor
Jan 10, 2003

The "Unity 4.x Cookbook" would be a good place to start if you want a book. It has Mecanim coverage which is nice, especially because all the videos on it that Unity 3D has produced are out of date so they're harder to follow in one viewing. There's also a bonus chapter on the legacy animation system you can download from Packt Publishing's website.

You could also run through "Unity 3.x Game Development Essentials". I flipped through it real fast and most of it still applies to 4.x. Just don't use Javascript. Chapter 10 is on the legacy animation system but you should still know how to use it.

Both of these books are available on Safari, if you have a subscription. If you don't, you can get the Cookbook for $18 off packtpub.com with the coupon "bawdanu"(I just looked up on retailmenot). It's probably not worth spending money on the U3.xGDE unless it's like $5.

P.S. Don't use Javascript(or Boo).

Corbeau
Sep 13, 2010

Jack of All Trades
Tutorials are the place to start, not books. Just tinker around with very very simple projects to get the hang of individual systems, at which point you can start combining one or two. Mostly you just learn by trying things out and seeing what happens, then referring to the manual to figure out why it didn't do what you expected.

And yes, use C#. Unity doesn't actually use Javascript at all; instead it uses Unityscript, which is basically an object oriented language with Javascript syntax. So there's no reason to use that when you could just pick up C# and have a language that's actually used elsewhere as well.

Stick100
Mar 18, 2003

dizzywhip posted:

I agree, I spent a few hours with the project tutorials and that was plenty for me to become comfortable in Unity. I did roll-a-ball and then about half of space shooter and didn't bother with the stealth one. Since you're coming from a programming background that should be plenty to get you started.

One Note: The stealth tutorial is pretty useful but it requires many features that are present in Pro only. I got about 1/2 of the way through and then they go into light probes and other neat things and then BAM! no warning it just doesn't work unless you're using Pro. So the tutorial just falls flat without Pro.

Because of this I wouldn't suggest the Stealth tutorial.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

The space shooter tutorial is really easy to go through. I think it is perfect to do first.

Zizi
Jan 7, 2010
Another vote for tutorials. I will also throw in hitting the #sagamedev channel on SynIRC. A lot of us in there know Unity rather well.

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!
The space shooter tutorial is way better than the stealth one as a general unity tutorial, but the stealth one IS doable without pro. It's just some lighting related stuff that you'll have to improvise or leave out. All the animation, AI, general scripting stuff, etc. are fine.

My personal preference was the method someone suggested above of doing separate tutes and then combining them. That plus well documented engines (eg. GoldSrc, Source) that do stuff different or better than unity are good resources for implementing anything else.

xzzy
Mar 5, 2009

Guild of Dungeoneering showed up on Boing Boing this morning:

http://boingboing.net/2014/04/14/build-the-dungeon-not-the-adv.html

They apparently hate the audio!

shimmy
Apr 20, 2011
I am using Unity ScriptableWizards to automate creating rooms and such in the editor. It's very easy to launch these wizards from a custom option in the File/Edit/GameObject/etc menus, but it would be really great if I could launch them from a script, in my case, a CustomEditor that puts a button in the script in the inspector. It seems so simple but I am getting nowhere.

bobthenameless
Jun 20, 2005

I don't know if this is beneficial to anyone else or not or if I'm silly for even doing this, but: http://bobthenameless.github.io/fmod-studio-docs/

For some reason it annoyed me to have to open up the FMOD .chm file to look at the FMOD API instead of getting a good result from google for "FMOD Studio API" like a lot of other APIs, so I started converting the .chm file into a gh-pages deal.

It's still not in a very good usable format, and for now it's literally a bulk table of contents from just the API section of the .chm cleaned up and rearranged a bit, but hopefully I can turn it into something useful eventually. And I have no idea of the license of the docs of a freely downloadable API with assorted commercial licenses, but I'm not trying to claim it's anything but a repackaging of the normal docs, and once i get it to a better state I'll send fmod an email and find out for sure.

It's also no-where near fully automated so it'll probably be just for the current version for now.

bobthenameless fucked around with this message at 19:18 on Apr 21, 2014

Flownerous
Apr 16, 2012

shimmy posted:

I am using Unity ScriptableWizards to automate creating rooms and such in the editor. It's very easy to launch these wizards from a custom option in the File/Edit/GameObject/etc menus, but it would be really great if I could launch them from a script, in my case, a CustomEditor that puts a button in the script in the inspector. It seems so simple but I am getting nowhere.

There's probably a direct way to launch them, but if that fails you should just be able to call EditorApplication.ExecuteMenuItem

Alexander DeLarge
Dec 20, 2013
After Garry Newman came out speaking against the uLink networking API and their attempt to silence his outspokenness about the lack of support, I'm kind of reluctant to be using Unity at this point because I was really relying on uLink. Are there any alternatives? I really don't want to use the cloud solution, I want functioning netcode so I can build off of it and create dedicated server tools and all that good stuff.

Alexander DeLarge fucked around with this message at 12:26 on Apr 22, 2014

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Alexander DeLarge posted:

After Garry Newman came out speaking against the uLink networking API and their attempt to silence his outspokenness about the lack of support, I'm kind of reluctant to be using Unity at this point because I was really relying on uLink. Are there any alternatives? I really don't want to use the cloud solution, I want functioning netcode so I can build off of it and create dedicated server tools and all that good stuff.

I think even with Photon you can do your own dedicated servers, but I'm not sure if they require you to use their software for the servers you host or not. I remember not being that impressed with Photon's offerings.

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!

Alexander DeLarge posted:

After Garry Newman came out speaking against the uLink networking API and their attempt to silence his outspokenness about the lack of support, I'm kind of reluctant to be using Unity at this point because I was really relying on uLink. Are there any alternatives? I really don't want to use the cloud solution, I want functioning netcode so I can build off of it and create dedicated server tools and all that good stuff.

This, raw Unity3D API, or just use .NET?

Stick100
Mar 18, 2003

Alexander DeLarge posted:

After Garry Newman came out speaking against the uLink networking API and their attempt to silence his outspokenness about the lack of support, I'm kind of reluctant to be using Unity at this point because I was really relying on uLink. Are there any alternatives? I really don't want to use the cloud solution, I want functioning netcode so I can build off of it and create dedicated server tools and all that good stuff.

Take a look at TNet.

http://forum.unity3d.com/threads/163681-Released-TNet-Tasharen-Networking-Framework

It's from the creator of NGUI and it's a full networking solution. People seem pretty happy with it.

Adbot
ADBOT LOVES YOU

retro sexual
Mar 14, 2005

xzzy posted:

Guild of Dungeoneering showed up on Boing Boing this morning:

http://boingboing.net/2014/04/14/build-the-dungeon-not-the-adv.html

They apparently hate the audio!

This was pretty good for me, given it was a single paragraph about the game! They sent about 3.5K visits to the Dungeoneering page on my site which led to about 40-50 pre-orders. (I don't know for sure because I haven't set up a thank you page for post-purchase redirect + corresponding GA 'goal' yet)

I hadn't pitched them specifically when I did my media blitz on the 9th (trailer release + greenlight day), but I bet it was a knock on effect from that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply