Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 158 159 [160] 161 162 ... 796

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

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #2385 on: May 05, 2012, 10:38:14 pm »

I was thinking exactly that.

"I just... tested."
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

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2386 on: May 06, 2012, 03:05:16 am »

Okay, I am having an issue. I am trying to take a direction vector <x,y,z> and another direction vector <a,b,c> and finding the change in angle between each set of planes (x,y),(x,z),(y,z). Not sure how to go about checking that out. I can make them each into Unit Vectors, which I think is necessary for this, but am not sure how to find the change in angle :(
angle = acos( [dot(Vector1, Vector2)] / [length(Vector1)*length(Vector2)] )
Unit vectors make it easy, as the lengths are both 1 by definition, so it becomes:
angle = acos( dot(Vector1, Vector2) )
acos can be found in every math library imaginable, dot product is just the sum of the piece-wise multiplication of the vectors;
for example:
Vector1 = 1, 2, 3
Vector2 = 4, 5, 6
dot(Vector1, Vector2) = 1*4 + 2*5 + 3*6

This same method can be used to find the angle between planes assuming you have their surface normals; which you probably do. The angle between the surface normals is the angle between the planes. Depending on what sort of planes you are working with, you may or may not have the normals from the plane equations. If you don't, normals can be found for a plane by taking 3 points on the plane, creating 2 vectors with them, and then finding the cross product.
Cross product is harder to memorize, but generally goes along the lines of:
ResultVector.x = V1.y*V2.z - V1.z*V2.y
ResultVector.y = V1.z*V2.x - V1.x*V2.z
ResultVector.z = V1.x*V2.y - V1.y*V2.x
With the pairs being multiplied swapped around depending on whether you are using a right or left handed cross product.
Dot products are really useful for all sorts of things; so reading up on them is good. Cross products are useful for finding lines perpendicular to 2 others in a 3D space and for 3D rotations.

I might like that Dark thing though, if there's one thing that bugs me about doing computer stuff, it's staring at a white screen all day.
In Visual Studio 2010 you can change the colors everything for everything. Tools -> Options..., Environment->General
You can change all the fonts, font size, background colors, and foreground colors. For every piece of text and such. It may be a bit tedious to get all the settings how you want them, but it may be worth it if you are one of the people who get eye strain from staring at blaring white too much. It will also put those changes into a config file somewhere, never bothered to find out where myself, but if you found that you could also drag said changes around to where ever you needed to code.

In fact, keeping a log of actions could make for a very interesting AI with learning capabilities. Maybe a sort of final boss that can watch the whole dungeon, and "takes notes" on what the PC does.
Implement an AI which utilizes bayesian reasoning combined with some expectiminimax, and you can do such a thing.


Why would they ask that? o_o
To test your approach.  In my experience, when you're asked a question like that, the correct response is to talk your way through your entire thought process from beginning to end, and don't stop
Very much this. Though even after you reach an answer, go back through and think about it some more, as they often want that too. Probably the most infamous question of this sort, though the manhole covers is a common one, is an old one Microsoft used to ask. "How Would You Move Mount Fuji?" It even has a book about it:
How Would You Move Mount Fuji? Microsoft's Cult of the Puzzle - How the World's Smartest Company Selects the Most Creative Thinkers

Working through such problems shows that you are capable of thinking through unexpected problems rationally and without panicking, as well as demonstrating your ability to pull other background knowledge about the way the world works in order to supplement your reasoning ability. Other variants I've heard of include estimating the number of gas stations in the United States.

Though whether you get these sorts of problems or mathematically based programming problems will vary from place to place. One company someone I know was looking at asked for applicants to create a program which would efficiently find the solution to a certain problem; he created use a brute force method, as the underlying mathematics was hidden enough for him to miss it. His brute force method took up to 25 seconds to compute an answer to the most complicated input, as it was essentially just a tangle of brute force and special cases. By finding a mathematical isomorphism and simplifying that into a much better algorithm, it can be found within a few dozen operations for any given inputs.
« Last Edit: May 06, 2012, 03:45:09 am by alway »
Logged

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2387 on: May 06, 2012, 08:17:13 am »

@Aqizzar: Same question that I gave to Mego :D Also, does the debug code look like something you could implement into your code for the purposes of debugging should anything start looking like it isn't working?

That sounds like an excellent idea.  I was planning just to use Trace statements, but that gets to be a pain in the ass to keep up with.  Just having the program buffer up a hundred or two lines of output and spit them into a logfile would make error-checking the action engine much easier.  It'd be a good thing to keep around for exception crashes later too, when the program gets too big for me to know what's crashing.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2388 on: May 06, 2012, 09:58:11 am »

To the learning boss thing, something like:
Boss: Oh hey, I'm weak against fire. This guy seems to be kicking some ass with his fire spells. But he only uses it every now and then even though he could come fight me really quick if he just spammed it all the time. Maybe he only has a limited amount of magic points? Ooh, I might be able to take advantage of that!
*Boss writes some notes to figure out how to restrict the player's available magic points*
Boss: Oh yes... that guy's goin down!

Lols, that would be pretty cool to be honest. I would love to have to tailor my play style with the knowledge that the level bosses are essentially looking over my shoulder to figure out my strengths and weaknesses by putting me into different situations as tests.
That sounds like something that could be handled using Rule induction or maybe Case-based reasoning.
Logged

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #2389 on: May 06, 2012, 08:43:48 pm »

So, I am trying to work with some pointers in C# to get a hang of them but I have a question about how the garbage collector works. I understand that using a pointer can be somewhat dangerous and that I should make sure that the referenced object actually exists before I try to use the pointer, but I don't completely understand the conditions under which the GC will clean up an object. I think that I might be able to put in some stuff to make sure that an object nullifies any pointers directed at it on cleanup. Not sure if that is all that possible, but I will have to play with it to make sure that my code explicitly forbids me from using a dead pointer. Any explanations for the C# GC would be appreciated :D Thanks in advance!
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2390 on: May 06, 2012, 08:54:54 pm »

Most things are already a pointer in C#. I hesitate to say everything because someone who knows more than me will likely jump in and say I'm completely wrong about that. In any event, as long as something within your code is referencing or holding a pointer to an object, that object won't be cleaned up on garbage collection. Or that is how it's been explained to me.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #2391 on: May 06, 2012, 09:13:43 pm »

C#'s garbage collection will delete your objects when they can no longer be reached. With typical simple "reference counting" (ala C++'s shared_ptr<X>), you'll have a memory leak if object x has a pointer to y and object y has a pointer to x. .NET uses a more complicated method to keep track of things, should be able to detect and clean this. When an object becomes unreachable, it's push into a queue of "can delete" objects. It'll then do it's best to make smart decisions of which objects to free from the memory, trying to keep memory as compact as possible.

Much better explanation here: http://www.simple-talk.com/dotnet/.net-framework/understanding-garbage-collection-in-.net/
Logged

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #2392 on: May 06, 2012, 09:47:51 pm »

Thankyou for the link Morley! :D That definitely helps me understand things better ^_^ That is essentially how I thought it worked, but wasn't entirely sure as I have been getting used to C++'s explicit memory allocation/deallocation procedures these past few weeks :D
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #2393 on: May 07, 2012, 11:52:57 am »

Had some tiny bit of time and started working on MNML a bit...

http://www.bay12forums.com/smf/index.php?topic=98412.msg3136580#msg3136580

Attempting to add strings significantly increases the complexity.
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.

kaenneth

  • Bay Watcher
  • Catching fish
    • View Profile
    • Terrible Web Site
Re: if self.isCoder(): post() #Programming Thread
« Reply #2394 on: May 07, 2012, 01:27:58 pm »

The problem is in light everything but the part with the code is grey or black. Everything.

This is what it looks like when you boot it up.
This is what it looks like with code.
This is what it looks like in a menu.
This is what the solution explorer looks like.


Ugh, looks like they are doing the 'Metro' style wrong. Did you send feedback? it does actually get read you know.
Logged
Quote from: Karnewarrior
Jeeze. Any time I want to be sigged I may as well just post in this thread.
Quote from: Darvi
That is an application of trigonometry that never occurred to me.
Quote from: PTTG??
I'm getting cake.
Don't tell anyone that you can see their shadows. If they hear you telling anyone, if you let them know that you know of them, they will get you.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2395 on: May 07, 2012, 09:08:43 pm »

As I recall, Visual Studio's color scheme changes depending on the version (freeware versions like C++ EE have a very different color scheme than paid versions); the grey could simply be to denote that it is the beta version.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2396 on: May 07, 2012, 09:19:08 pm »

The AP Computer Science Exam is tomorrow. Ugh.

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #2397 on: May 07, 2012, 09:45:23 pm »

Bring some magma and kill the AP Exam with it!
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

dizzyelk

  • Bay Watcher
  • Likes kittens for their delicious roasts.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2398 on: May 09, 2012, 12:33:27 pm »

So, I have a very fun problem. I spent a little while putting A* into the roguelike I'm writing. And I got tons of errors. Mostly referring to missing semi-colons then saying my Character class isn't declared. However, this is code that I haven't touched in several compiles that have worked. I kinda raged. I went through all my code and found 2 missing semi-colons, which I added in. Still not working. I went through and checked commands I knew were right against what cplusplus.com says about them. I've even taken all the pathfinding code out. So, now my code is exactly the same as it was before the last successful compile. But I'm still getting errors. I can't figure out how I've managed to create an error that persists after removing all the code I've put in. Can anyone here help?
Logged
Dwarf Fortress - Bringing out the evil in people since 2006.
Somehow, that fills me more with dread than anticipation.  It's like being told that someone's exhuming your favorite grandparent and they're going to try to make her into a cyborg stripper.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2399 on: May 09, 2012, 01:07:39 pm »

Which compiler&version are you using? I've noticed the newer versions of gcc are a lot better at finding the correct locations of missing semi colons and stuff (eg: at the end of your class declaration).
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))
Pages: 1 ... 158 159 [160] 161 162 ... 796