JavaScript general utility module example

When I start a new project I often want to have a generic dumping ground for usual suspect type methods, in other words a kind of lodash like library only with methods that I am actually going to use in the project, and not a whole much of bulk that I am not going to be using like with lodash.

Many methods that I might park in this kind of library might ultimately end up in some other library that has to do with something more specific such as working with angles, or creating and working with canvas elements. However when first starting out I just need a place to put any and all methods that I might want to use in one or more additional modules, or libraries throughout an over all application. So I need to just park it in some kind of general utilities type library until I find a more appropriate home for it.

So in todays post I will be going over a general utility module and the kind of methods that I might place in such a module that will serve as yet another one of my JavaScript example type posts. While in the process of writing about the various method I may link to additional posts on various game prototypes, and projects that are relevant to use usage of these methods.

Read More

One to one functions in javaScript

This wraps up this week on writing more about authoring functions in javaScript, much of which had to do with writing functions in general actually rather than specifics of why they are written in javaScript alone. In one post I touched base on the topic of function domain which is a term for the full range of possibles when it comes to the range of arguments that can be passed to a function. Another post that I wrote recently was on the topic of monotonic functions which are functions that have to do with increasing return values as an argument approaches positive infinity. That is that a function is increasing monotonic if the return value stays the same or goes up as a x argument approaches positive infinity. There are a number of other terms with monotonic functions thorough that have to do with decreasing values also though.

However there is one general type of monotonic function that stands out for me and that is a strictly increasing monotonic function, which can be thought of as an example of a one to one function which stands out from other kinds of monotonic functions some of which can be many to one. So it would seem that the term monotonic refers to several kinds of functions some of which can be many to one style functions, however some such as strictly increasing monotonic functions are very much one to one. In this post I will be focusing mainly on the topic of one to one functions which interest me when it comes to the topic of making an experience point system.

Read More

Many to one functions in javaScript

This week I have been looking more into writing functions in javaScript, and as such I have also touched base on many topics that have to do with functions in general. One such topic is knowing what a many to one function is compared to a one to one function, along with many other topics such as what an independent variable is compared to a dependent variable, and what function domain and co domain is. These are all topics that have to do with functions in javaScript, but also functions in any language for that matter actually.

So in todays post I will be focusing mostly on what a many to one function is, which may some times also be freed to as a surjective function. Say you have a function that takes just one argument that is x, and will return a value that can be thought of as a y value. On top of this lets say that for any given x value that is passed to the function, there may be more than one other x value that will result in the same y value returned. Such a function is a many to one type function, rather than what would be called a one to one function. So then it is not possible to create an inverse function for a many to one function, as there would be a range of possible return values for a given known argument value, while it should be possible to create an inverse for a one to one function. In any case in todays post I will be writing many just about the topic of many to one.

Read More

Diminishing returns functions in javaScript

This week I have been expanding on the topic of functions in javaScript, and many various topics that might come up when making a game. One thing that I have run into now and then is the topic of making some kind of diminishing returns function that is involved in creating attribute values when creating some kind of upgrade system. Often a game might involve some kind of skill point, token, or value that will go up as a player advances in the game. Often this value will start out at zero, and each time the player levels up, or preforms some kind of task they end up getting certain amounts more of this value. The amount of this skill points or whatever they may be called can then be invested in one or more upgrades, and there is no limit as to how many that can invest in any one upgrade. However there is a catch when it comes to putting all skill points into a single upgrade and that is that they will never truly reach the max possible value that can be obtained, the reason why is because of, you guessed it, diminishing returns.

Read More

The domain of a function in javaScript

When getting into writing functions in javaScript there are the things that have to do with how functions work in javaScript, but then there are all kinds of things that have to do with functions in general. That is things that do not just apply to functions in javaScript, but any language for that matter. With that said todays post is on the subject of the domain of a function in javaScript.

A function domain as it some times might be called is the full range of arguments that are possible for a given function. So say I have a function that accepts a single argument that represents a singe side of a six sided die, in that case the range for the one argument would be the whole numbers 1 threw 6. However many functions will have a very wide range for an argument, and on top of that float numbers can be used. ALso often a function will have more than one argument, on top of having a wide range for one or more arguments. This can result in w very wide range of possibles for the domain of a function, making it hard to create a way to graph all possibles, or run threw all possible combinations of calls to make sure the function will always work as expected for all possible input values.

Read More