How to make an Idle game or incremental game?

Started by
26 comments, last by CubeUser 6 years, 5 months ago

One int between 0-9 for each number in the total value would be an array of at least 300 elements for a "full" use idle game I guess? I would really love to see a C sharp library that works with unity that has something like that, or soe similar method to store huge values with precision like that, unless "double" works. I will start experiementing soon, I had trouble after a reinstallation that screwed the VS 2017 installation up and I had to downgrade Unity a few version numbers because of some internal server service not working.

Languages I have been in touch with: Unity3D, C#, Lua, VB, VB.net, Blitz3S, BlitzMax, DarkBasic, C++

Advertisement
On 11/15/2017 at 8:47 PM, CubeUser said:

One int between 0-9 for each number in the total value would be an array of at least 300 elements for a "full" use idle game I guess?

Using arrays like this is fast and powerful, remember that repative tasks is what computers are made for.

Upgraded version of the example I showed above.

Spoiler

 



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberSystem : MonoBehaviour {

	//This class is made so that we can work with very large digits.
	public class BaseTen
	{
		//String for out
		public string TheBase;

		//When we make a new BaseTen() we want a string input
		public BaseTen (string NumberAsString){
		TheBase = NumberAsString;
		}


		//So we can add a base into this one
		public void AddBaseIn(BaseTen InBaseTen){
			//Wen the base is smaller we need to increase it's size
			while ( TheBase.Length - InBaseTen.TheBase.Length  < 0){//negative means TheBase smaller
				TheBase = "0"+ TheBase;
			}
			//Now add the numbers
			int Index =0;
			string tempString = "";
			sbyte[] ArrayA = new sbyte[TheBase.Length];
			foreach(char Digit in TheBase){
				//Add the two inside the array to keep it whole. 
				///We also need to start from the smallest:((x-1) - index)
				ArrayA[Index] += sbyte.Parse(TheBase.Substring((TheBase.Length - 1) - Index,1));

				if (Index < (InBaseTen.TheBase.Length)) {
					ArrayA [Index] += sbyte.Parse (InBaseTen.TheBase.Substring ((InBaseTen.TheBase.Length - 1) - Index, 1));
				} else {
					ArrayA [Index] += 0;
				}

				//Pass over the one if it's larger than 9
				if (ArrayA [Index] > 9) {
					ArrayA [Index] -= 10;
					//Add the one to the next index if there is space in the array
					if (Index + 1 <= (ArrayA.Length-1)) {
						ArrayA [Index + 1] += 1;
						tempString = ArrayA [Index] + tempString;//reverse
					} else {// if there isn't space Add 1 to the front
						tempString = ArrayA [Index] + tempString;
						tempString = "1" + tempString;
					}
				} else {//If the number is under 9
					tempString = ArrayA[Index]+tempString;//reverse
				}

				Index +=1;
			}
			TheBase = tempString;//Set the base to the new value
		}//AddBaseIn


		//To allow adding of a string to a base
		public void AddStringIn(string InBaseTen){
			//Wen the base is smaller we need to increase it's size
			while ( TheBase.Length - InBaseTen.Length  < 0){//negative means TheBase smaller
				TheBase = "0"+ TheBase;
			}
			//Now add the numbers
			int Index =0;
			string tempString = "";
			sbyte[] ArrayA = new sbyte[TheBase.Length];
			foreach(char Digit in TheBase){
				//Add the two inside the array to keep it whole. 
				///We also need to start from the smallest:((x-1) - index)
				ArrayA[Index] += sbyte.Parse(TheBase.Substring((TheBase.Length - 1) - Index,1));

				if (Index < (InBaseTen.Length)) {
					ArrayA [Index] += sbyte.Parse (InBaseTen.Substring ((InBaseTen.Length - 1) - Index, 1));
				} else {
					ArrayA [Index] += 0;
				}

				//Pass over the one if it's larger than 9
				if (ArrayA [Index] > 9) {
					ArrayA [Index] -= 10;
					//Add the one to the next index if there is space in the array
					if (Index + 1 <= (ArrayA.Length-1)) {
						ArrayA [Index + 1] += 1;
						tempString = ArrayA [Index] + tempString;//reverse
					} else {// if there isn't space Add 1 to the front
						tempString = ArrayA [Index] + tempString;
						tempString = "1" + tempString;
					}
				} else {//If the number is under 9
					tempString = ArrayA[Index]+tempString;//reverse
				}

				Index +=1;
			}
			TheBase = tempString;//Set the base to the new value
		}//AddStringIn
			

	}//Class

	BaseTen NumberA = new BaseTen ("11");//First large number
	BaseTen NumberB = new BaseTen ("22");//Second large number

	public void BtnDebug(){
		System.Diagnostics.Stopwatch Timer = new System.Diagnostics.Stopwatch();
		Timer.Start();

		NumberA.AddBaseIn(NumberB);
		print (NumberA.TheBase);

		Timer.Stop();
		Debug.Log(Timer.Elapsed);

	}
}

 

 

 

Be warned that expanding the above code will require a understanding of how the math works. You would be better off building your own version.

Numbers.thumb.jpg.117539158fe2817cbb8b277564295206.jpg

This image shows my performance test. I ran it 5 times very fast to test the time it takes. It on average it took a little more than a tenth of a second (1 second /10). That is faster than the Unity button animation.

Feel free to try it.

On 11/8/2017 at 5:06 PM, CubeUser said:

Thank you, but the claim that it is simple to make such games is not going well together

Incremental games is the basics of the basics.

A good example is that I am a artist, not a programmer. A real programmer would run my little number system here into the ground. Python is a example of what a programmer can do, there is no math function it can't run.

 

Edit:

I had to reduce the size of the number. It was causing problems with the web page. Just fill in any large numbers you want.

20 hours ago, Scouting Ninja said:

Using arrays like this is fast and powerful, remember that repative tasks is what computers are made for.

Upgraded version of the example I showed above.

  Hide contents

 




using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberSystem : MonoBehaviour {

	//This class is made so that we can work with very large digits.
	public class BaseTen
	{
		//String for out
		public string TheBase;

		//When we make a new BaseTen() we want a string input
		public BaseTen (string NumberAsString){
		TheBase = NumberAsString;
		}


		//So we can add a base into this one
		public void AddBaseIn(BaseTen InBaseTen){
			//Wen the base is smaller we need to increase it's size
			while ( TheBase.Length - InBaseTen.TheBase.Length  < 0){//negative means TheBase smaller
				TheBase = "0"+ TheBase;
			}
			//Now add the numbers
			int Index =0;
			string tempString = "";
			sbyte[] ArrayA = new sbyte[TheBase.Length];
			foreach(char Digit in TheBase){
				//Add the two inside the array to keep it whole. 
				///We also need to start from the smallest:((x-1) - index)
				ArrayA[Index] += sbyte.Parse(TheBase.Substring((TheBase.Length - 1) - Index,1));

				if (Index < (InBaseTen.TheBase.Length)) {
					ArrayA [Index] += sbyte.Parse (InBaseTen.TheBase.Substring ((InBaseTen.TheBase.Length - 1) - Index, 1));
				} else {
					ArrayA [Index] += 0;
				}

				//Pass over the one if it's larger than 9
				if (ArrayA [Index] > 9) {
					ArrayA [Index] -= 10;
					//Add the one to the next index if there is space in the array
					if (Index + 1 <= (ArrayA.Length-1)) {
						ArrayA [Index + 1] += 1;
						tempString = ArrayA [Index] + tempString;//reverse
					} else {// if there isn't space Add 1 to the front
						tempString = ArrayA [Index] + tempString;
						tempString = "1" + tempString;
					}
				} else {//If the number is under 9
					tempString = ArrayA[Index]+tempString;//reverse
				}

				Index +=1;
			}
			TheBase = tempString;//Set the base to the new value
		}//AddBaseIn


		//To allow adding of a string to a base
		public void AddStringIn(string InBaseTen){
			//Wen the base is smaller we need to increase it's size
			while ( TheBase.Length - InBaseTen.Length  < 0){//negative means TheBase smaller
				TheBase = "0"+ TheBase;
			}
			//Now add the numbers
			int Index =0;
			string tempString = "";
			sbyte[] ArrayA = new sbyte[TheBase.Length];
			foreach(char Digit in TheBase){
				//Add the two inside the array to keep it whole. 
				///We also need to start from the smallest:((x-1) - index)
				ArrayA[Index] += sbyte.Parse(TheBase.Substring((TheBase.Length - 1) - Index,1));

				if (Index < (InBaseTen.Length)) {
					ArrayA [Index] += sbyte.Parse (InBaseTen.Substring ((InBaseTen.Length - 1) - Index, 1));
				} else {
					ArrayA [Index] += 0;
				}

				//Pass over the one if it's larger than 9
				if (ArrayA [Index] > 9) {
					ArrayA [Index] -= 10;
					//Add the one to the next index if there is space in the array
					if (Index + 1 <= (ArrayA.Length-1)) {
						ArrayA [Index + 1] += 1;
						tempString = ArrayA [Index] + tempString;//reverse
					} else {// if there isn't space Add 1 to the front
						tempString = ArrayA [Index] + tempString;
						tempString = "1" + tempString;
					}
				} else {//If the number is under 9
					tempString = ArrayA[Index]+tempString;//reverse
				}

				Index +=1;
			}
			TheBase = tempString;//Set the base to the new value
		}//AddStringIn
			

	}//Class

	BaseTen NumberA = new BaseTen ("11");//First large number
	BaseTen NumberB = new BaseTen ("22");//Second large number

	public void BtnDebug(){
		System.Diagnostics.Stopwatch Timer = new System.Diagnostics.Stopwatch();
		Timer.Start();

		NumberA.AddBaseIn(NumberB);
		print (NumberA.TheBase);

		Timer.Stop();
		Debug.Log(Timer.Elapsed);

	}
}

 

 

 

Be warned that expanding the above code will require a understanding of how the math works. You would be better off building your own version.

Numbers.thumb.jpg.117539158fe2817cbb8b277564295206.jpg

This image shows my performance test. I ran it 5 times very fast to test the time it takes. It on average it took a little more than a tenth of a second (1 second /10). That is faster than the Unity button animation.

Feel free to try it.

Incremental games is the basics of the basics.

A good example is that I am a artist, not a programmer. A real programmer would run my little number system here into the ground. Python is a example of what a programmer can do, there is no math function it can't run.

 

Edit:

I had to reduce the size of the number. It was causing problems with the web page. Just fill in any large numbers you want.

Thank you, but as you say, the maths would be the issue, because for a Prestige points system, estimating the amount of prestige points will involve things like Square Root. Doing that with this method... well :-/.... So it might mean there are some libraries available somewhere for use with Unity3D, I just hope there are, if I ever want to exceed xxE+300, below XXE+300, double would probably do,  As for the "Basics" you are talking of, yes. I saw a lot of tutorial on youtube and there are web pages on how to create the curves on how "hard" the game should be (i.e how much patience it should require to play, and at some points be frustratingly slow but suddenly fast again for a little while). One person on Youtube did a very through educational video, but the game used just single so the game he claimed to have developed, some infect-the-world- type game with viruses, germs and bacteria. Just to test it, I ran that  and pushed it real hard. Not long before it showed "NaN" and stalled. As for Python, I try to avoid those languages, I am finishing a project as we speek written in one of those kind of languages, it will be the last I do with them. They are made to be easy to use, but the problem they tend to be slow and easy to make errors in them.

Languages I have been in touch with: Unity3D, C#, Lua, VB, VB.net, Blitz3S, BlitzMax, DarkBasic, C++

1 hour ago, CubeUser said:

As for Python, I try to avoid those languages, I am finishing a project as we speek written in one of those kind of languages, it will be the last I do with them. They are made to be easy to use, but the problem they tend to be slow and easy to make errors in them.

They are slow because they have support for things C# doesn't. Browsing there libraries could give you the answers you need.

1 hour ago, CubeUser said:

estimating the amount of prestige points will involve things like Square Root. Doing that with this method... well :-/

No reason you couldn't. The system I made here is a base 10 system, as in the one we use in our day to day lives. All of the math you know can be done using this system, you just really need to understand how it works.

For example to find a Square root you would only need to know what a Square Root is.

1 hour ago, CubeUser said:

So it might mean there are some libraries available somewhere for use with Unity3D

If you find them consider sharing them with people here. 

I found a few but they all died in production or just use doubles and decimals.

The upgraded version of my code, the one using strings, was something someone else tried and gave up on. It's why I want to finish it.

 

Most suggestions and info I found on incremental games is:

Use an array system. Use the largest number set you have (Decimals) or fake it by writing "100 billion" "2 googol" and so forth.

There got to be libraries for this, as there are many games out there. Either Double is far better in practic use in a game than it looks like when you show inconsistencies, and the games use them plus a routine that checks the end of the string for any "E+xxx" and translate it, or, there is some library they use for stuff that needs to go beyound "e+300", I have seen one of those games actually and it is written in Javascript, I have checked and there is a compiler+runtime for javascript that was included in the same folder. But as you stated, I will start looking for this. General C# libraries, how could they be made to work in Unity3D?

Languages I have been in touch with: Unity3D, C#, Lua, VB, VB.net, Blitz3S, BlitzMax, DarkBasic, C++

My suggestion:

  1. Create a new class, which you'll use for all your values. (Initially, this class is just a wrapper for a double.)
  2. Use the class and develop the game.
  3. If, after actually developing something and seeing it in practice, the double implementation doesn't work, upgrade it.

All changes required will be in contained in that 1 single class, and you can start developing the game immediately.

Hello to all my stalkers.

1 minute ago, Lactose said:

My suggestion:

  1. Create a new class, which you'll use for all your values. (Initially, this class is just a wrapper for a double.)
  2. Use the class and develop the game.
  3. If, after actually developing something and seeing it in practice, the double implementation doesn't work, upgrade it.

All changes required will be in contained in that 1 single class, and you can start developing the game immediately.

Well I would not see why doubles does not work, Indeed I did not know Doubles was so powerful a data type so I thought the games used something else (Some games do but that's another story). And I asked it here on this forum, Just after I asked though, I found that someone had claimed that Adventure capitalist would use Double, and when I really divided the max exponent 300 down, I found it might be true. I did some crude experiments with an old Visual Studio compiler on my old XP machine. The only thing that could be a problem would be finding out the exponent string or amount of decimals to "render out" a number that the player sees. In VisualBasic you would use something similar to "If Instr(1, val(TheDouble), "E+15" >1), but that thing might be in C# as well. But I got very confused about the long array of values someone also suggested. With all complicated maths involved for upgrades, prestige etc, double is made for that and it would work out of the box, so I think your answer will be what I would go for for now. Thank you

Languages I have been in touch with: Unity3D, C#, Lua, VB, VB.net, Blitz3S, BlitzMax, DarkBasic, C++

This topic is closed to new replies.

Advertisement