Jump to content

  • Log In with Google      Sign In   
  • Create Account


Jaap85

Member Since 01 Sep 2011
Offline Last Active Jul 22 2014 02:45 PM

#4984102 Freeing up memory

Posted by Jaap85 on 26 September 2012 - 02:43 PM

Hello everybody,

I just created a small test program to see how it would worked after i compiled it. The program was created in Visual Studio using C#. The main thing it does, is adding content from a web page (by reading html source code) to a list.

At some point in the program, i try to remove items from the list (to clear memory usage). However, i run into a problem. I want to remove all items in a list that meet a certain criterium. My code is as follows:

foreach item in list:
> if item.status meets criterium
> list.remove(item)

However, this code doesn't work. The error i get is that i am not allowed to alter the list inside the for loop.

How could i fix this problem? Right now my (very simple) program uses about 2 GB of memory after running for an hour or so.

Thank you very much for your ideas and advice!


PS. if removing items of the list probably won't fix my memory issues i would be happy to hear any other ideas or tips.


#4971100 I need some guidance

Posted by Jaap85 on 19 August 2012 - 07:41 AM

If you like to get some guidance with your first project, but you don't want to create a platformer, you could try the book "Visual C# Game Programming for Teens". This helps you design a 2D RPG / dungeon crawler from the very beginning. Although it is not exactly what you are looking for eventually (which is i believe called 2.5D) it might suit you better than creating a platformer first. Or, depending on your learning curve, you could first finish the platformer, then the 2D RPG and finally move on to 2.5D.


#4970921 Realistic Encouragement vs Trolling Tear-down

Posted by Jaap85 on 18 August 2012 - 03:21 PM

also a beginner here and although i personally never felt discouraged by the forum members, this post definitely motivates me :)


#4969892 C# Learning Sources

Posted by Jaap85 on 15 August 2012 - 12:12 PM

Right now i am reading the book "Visual C# game programming for teens". I am not overly enthusiastic about this book, since it skips a lot of the concepts instead of explaining them in depth. If focuses more on creating a game, provided you already know some C#.

When i first started with C#, coming from Visual Basic, i used the following website which was useful to learn the very basics.

Hope this helps!

http://www.homeandlearn.co.uk/csharp/csharp.html


#4943948 My first year in game programming

Posted by Jaap85 on 28 May 2012 - 03:53 AM

Hello everybody,

About a year ago i started game programming, just for fun and for a challenge. I thought it would be nice to share my experiences here on this forum, mainly because it might help others who are currently just starting.

Please keep in mind that game programming is for me just a side hobby besides my own company (not IT-related), girlfriend and other hobbys. Since it is not my main focus, the progress i made in a year, could maybe also be made in a few months. On average i think i spend around four hours a week on programming.

When i started programming i almost had no knowledge of programming at all. The only things i knew were how to program in GWBASIC (a programming language from way back, like 1993 or so) and build a simple website in HTML. My backgrpund in general is that i am 27 years old, live in the Netherlands (which is why my English will be filled with errors ;-) and graduated in both Economics and Dutch Law at Erasmus University of Rotterdam.

When i wanted to start programming, my first problem was to select a language. At that time i was fairly unaware of all the discussions around the choice of a first programming language and just picked one. Since the name was quite similar to GWBASIC i went with Visual Basic and downloaded Microsofts IDE Visual Basic 2010. http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

The first thing i did, was finding some good tutorials. The best ones i found and used were these lessons, which are extremely detailed and very useful for a complete beginner: http://www.homeandlearn.co.uk/NET/vbNet.html

I managed to finish them quite fast and afterwards created my first program using really amateur stuff like picture boxes. My first game was Tic Tac Toe. It took me about 5 days to make it.

With Tic Tac Toe finished, i moved on to slightly more complex stuff and tried to create a simple board game like Ludo. The only problem here was that i wasn't familiar with creating classes so i ended up with a half-baked version of my game with over 150 global variables. That was when i decided that i had to be doing something wrong :)

After this setback i picked up some new tutorials for creating 2d tiled games from Youtube. The creator of this videos is Aardaerimus and he really gave me a lot insight into building a game loop and of course creating classes. I can highly recommend his tutorials. http://www.youtube.com/user/Aardaerimus?feature=watch

With these new tutorials i started to create some new games but was never able to finish them because of lacking skills or motivation.

In fall of 2011 my programming time was limited because i enrolled in Stanford University's AI Class. This class made me learn a lot about AI concepts, even though it didnt provide any practical examples, just the theoretical framework. I really liked learning about A*, minimax and learning algorithms.

When i finished the programming class, i decided i had two goals in programming:

1. Create a chess AI that can beat me, my dad and my girlfriend (we are all average players, so it should be possible)

2. Create a simple game that i can run on my XBOX (using C#/XNA).

Besides these goals, i also promised to myself that i would try to minimise the number of projects i was working on at the same time and also try to finish projects. I started by finishing two small games i was working on.

1. Sinterklaas
This is a bit hard to translate, but Sinterklaas is a Dutch holiday that is a bit like Christmas (although the presents don't come from the Northpole but from Spain). Traditionally Sinterklaas rides the roofs of the houses (by horse) and throws his present through the chimney. I tried to create a game based on this idea but replaced the horse with a plane. Finally i created a game where Sinterklaas was flying in a plane above the roofs and you would have to throw the right present in the right chimney.

This was the first time i worked with a deadline (Sinterklaas arrives on the 5th of december) and fortunately i finished in time. We all played the game on Sinterklaas and actually had some fun doing it. This was the first time after my Tic Tac Toe game that i actually felt the satisfaction of finishing a game.

2. Diamond Grabber
When Sinterklaas had passed, i wanted to create a game that used some theory from my AI class. I decided to make a 2d tiled game where a maze is randomly generated. When the game starts diamonds are dropped at random in the maze and you have to rush to get them. The most fun part was to create an AI that would rush to the diamonds as well. After some work i finally created an AI that operated perfectly using A*. This game was finished in january and was also my first game that came with a few settings (such as the speed of your AI opponent and the number of diamonds.

With these two games finished, i started something completely different. I learnt about Project Euler and found it very challenging so i gave it a go. In the past 4 months i solved 26 problems and arrived at level 1. Although Euler is not game related, it definitely helped me to think about processing time (since all problems on Euler can be solved in a clever way which takes less than 1 second, but most of them can also be solved in a way that takes over 10 minutes). If you like math problems, be sure to check out: http://projecteuler.net/

Somewhere in february i went back to game programming again and created my final game in VB.net which was an implementation of a simple board game (once again, based on Ludo) that i invented as a little kid. The game itself is not very interesting, (unless you are still a little kid ;-) ) but it felt good to make it, because it was the first game i ever made myself (although at first not on a computer).

The game was finished on 29 february and i uploaded it at SourceForge (https://sourceforge.net/projects/letourdusjap/).

After creating this game i left Visual Basic because i wanted to focus more on my final goals. One of these goals is creating a XBOX game and as far as i know this is best possible (or even only possible) in C#. Therefore i decided i should learn C#.

A funny thing happened when i told some friends i was learning the programming language "C hash", because that's what i thought it was pronounced. It really took me about a month to realise i was programming "C sharp" :)

My first steps into learning C# were the same as with VB.net, the tutorials from Home and Learn, but this time for the C# language: http://www.homeandlearn.co.uk/csharp/csharp.html. As an IDE i used once again Microsoft's Visual Studio: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express

When i got the basics of C#, i went on to decide what games i should make. Since i had two different endgoals, i wanted to work towards both of them simultaneously.

First i decide i want to create a RPG, not yet on the XBOX, but still on the PC using GDI+ instead of XNA. When i was able to do this, i would then move on to XNA and try to start developing on XBOX. To get some help with building the RPG i bought a book called Visual C# Game Programming for Teens (http://www.bol.com/nl/p/visual-c-game-programming-for-teens/1001004010525579/). I am currently halfway through the book and i am not yet sure whether i can recommend it. Some examples in the book are quite useful, but others are not that useful at all in my opinion.

Secondly i wanted to get experience with the minimax algorithm which i plan to use in my chess game. So, i went on to create a Connect Four game and currently i am trying to implement a minimax (soon to be negamax) algorithm into it. Just today i finally got the basics working and i am planning to use the coming weeks to improve it with stuff like heuristics, alpha-beta pruning, etc. When i get this one working correctly i might give chess a try or maybe i try another simple game first. The first version of the Connect Four game is also on SourceForge: https://sourceforge.net/projects/connectfour85/

Besides these two project i am currently also following the Udacity course 101, where you learn to build a search engine in Python. This project is not my main focus, but it is a fun side project that allows me to learn another new language.


Well, that's about it, these are the things i have done in my first year in game programming. Although it may not look like very much yet, i had fun doing it and i think i learnt a lot in the process. I hope my story can help or inspire other starting programmers. The most important lessons i learned in the past year are:

1. Keep track of your progress to keep yourself motivated

2. Finish your projects, also to keep yourself motivated

3. Start small, if something is too easy for you, you will know soon enough and can always move up the goals

4. Just pick a language, if you like programming dont wine to much about which language to use. If you really dont like it, you can always change

5. Show your projects to others. I always show them to my girlfriend who know nothing about programming but can be very critical of my work :)

6. Determine your endgoals (or at least goals that you want to attain in 2-3 years) and work towards them

7. Experiment with different problems, languages and IDE's. Maybe you will discover something that suits you better than what you are currently using.

Good luck and thanks for reading!!!


#4941609 Connect Four AI

Posted by Jaap85 on 20 May 2012 - 02:45 AM

Well, it took me some time, but i have finally created a minimax recursive algorithm (not yet negamax, will try that later).

For reference, my entire code is below. I dont use a heuristic function yet, i just try to see if a certain gamestate is a winner.

public AIMove RecursiveMiniMaxAI(int Depth, int MaxDepth, gamestate StateOfBoard, int Player)
		{
			//Depth is level of gamestate (initially 0)
			//Maxdepth is maximum search depth (set at creation of board)
			//StateofBoard is current gameboard
			//Player is the moving player. 1 = human, 2 = computer
			//Human Maximises, Computer Minimises
			//AI Move is the move to make
			Trace.WriteLine(Depth);
					  
			AIMove ReturnMove = new AIMove();
			//BestScore & Move
			int BestMove = -1;
			int BestScore;
			if (Player == 2) // Minimizing
				BestScore = 999;
			else
				BestScore = -999;
		  
			if (Depth == MaxDepth)
			//We are at the bottom of the search space and evaluate this level
			{
				ReturnMove.Score = EvaluateBoard(StateOfBoard, StateOfBoard.Column);
				ReturnMove.Move = StateOfBoard.Parent.Column;
			}
		  
			else
			{
				//Check for possible moves
				List<int> MoveList = new List<int>();
				MoveList = GenerateListOfMoves(StateOfBoard);
				if (MoveList.Count == 0)
				{
					ReturnMove.Score = EvaluateBoard(StateOfBoard, StateOfBoard.Column);
					ReturnMove.Move = StateOfBoard.Column;
				}
				else
				{
					if (Player == 2)  // Minimizing
					{
						//Perform minimax for each child
						for (int i = 0; i < MoveList.Count; i++)
						{
							//Make a move and create a new gamestate
							int j = GetStateNumber(Depth+1);
							AIStates[Depth + 1, j] = new gamestate(StateOfBoard, MoveList[i], size);
							//Place a token in the new Gamestate
							PlaceToken(AIStates[Depth + 1, j],MoveList[i], Player);
						  
							//Call minimax on the child
							ReturnMove = RecursiveMiniMaxAI(Depth + 1, MaxDepth, AIStates[Depth + 1, j], 1);
							//Evaluate return
							if (ReturnMove.Score < BestScore)
							{
								BestScore = ReturnMove.Score;
								BestMove = ReturnMove.Move;
							}
						}
					}
					else // Maximizing player
					{
						//Perform minimax for each child
						for (int k = 0; k < MoveList.Count; k++)
						{
							//Make a move and create a new gamestate
							int j = GetStateNumber(Depth + 1);
							AIStates[Depth + 1, j] = new gamestate(StateOfBoard, MoveList[k], size);
							//Place a token in the new Gamestate
							PlaceToken(AIStates[Depth + 1, j], MoveList[k], Player);
							//Call minimax on the child
							ReturnMove = RecursiveMiniMaxAI(Depth + 1, MaxDepth, AIStates[Depth + 1, j], 2);
							//Evaluate return
							if (ReturnMove.Score > BestScore)
							{
								BestScore = ReturnMove.Score;
								BestMove = ReturnMove.Move;
							}
						}
					}
					//Hier wordt de ReturnMove aangepast
					ReturnMove.Score = BestScore;
					ReturnMove.Move = BestMove;
				}
			}
			//string Data2;
			//Data2 = ReturnMove.Score.ToString();
			//Data2 += "/";
			//Data2 += ReturnMove.Move.ToString();
			//Trace.WriteLine("ReturnScore & Move: " + Data2 + " || At Depth " + Depth.ToString());
			return ReturnMove;
		}

The results i got out of this code are wrong and i think i managed to isolate the issue. When this piece of the function executes:

//Perform minimax for each child
						for (int i = 0; i < MoveList.Count; i++)
						{
							//Make a move and create a new gamestate
							int j = GetStateNumber(Depth+1);
							AIStates[Depth + 1, j] = new gamestate(StateOfBoard, MoveList[i], size);
							//Place a token in the new Gamestate
							PlaceToken(AIStates[Depth + 1, j],MoveList[i], Player);
						  
							//Call minimax on the child
							ReturnMove = RecursiveMiniMaxAI(Depth + 1, MaxDepth, AIStates[Depth + 1, j], 1);
							//Evaluate return
							if (ReturnMove.Score < BestScore)
							{
								BestScore = ReturnMove.Score;
								BestMove = ReturnMove.Move;
							}
						}

It doesnt run the FOR function multiple times. Even when MoveList.Count = 3, it only runs once, calling itself and when it returns to Evaluate the return, the function doesnt start over again for its next Move on the MoveList. The value of i is still 0, and MoveList.Count is still larger than zero.

If i remove the recursive function call, the code does re-iterate the for loop.

Does anybody know where i went wrong and how i could fix this?

Thank you very much in advance!


#4927597 c#: creating a dynamic textbased inventory for pnc adventure

Posted by Jaap85 on 02 April 2012 - 01:12 PM

I think a first approach would be to create an object class with generic methods for the possible actions like break, open, etc.

Then you can create subclasses for the different type of objects and determine for all these subclasses whether items are breakable or not.

Finally you can create the actual different object (like safe1, safe2, etc.) and give them their place in the game world.

Is that what you are looking for? Or am i thinking completely in the wrong direction?


#4906180 How to create a balanced card game?

Posted by Jaap85 on 25 January 2012 - 01:15 PM

hello,

i am still very new to this forum as well :)

In my opinion the best way to do this, is start simple and build from there through lots of testing. Maybe you could even build an AI to test new options in a further stage. But human testing is almost always necessary i guess.

When thinking in terms of MtG, start simple. Maybe first you only create mana (lands) and creatures. Afterwards you can create enchantments and maybe abilities for creatures like Flying. When you get this working, try to expand it further with new expansions.

MtG also started way simpler than it is today. I used to play it actively a couple of years ago, but when i returned to it last month, a huge amount of new features had been added to it.

Hope this helps a bit!


#4902932 When planning to make a game, should I cover everything before actually start...

Posted by Jaap85 on 15 January 2012 - 06:26 AM

i am a beginning programmer but have somewhat more experience in managing web & web design projects.

with these last projects, i prefer the iterative method by far, because its impossible to predict everything beforehand.


#4900334 Creating my second game AI

Posted by Jaap85 on 07 January 2012 - 08:32 AM

hello everybody,

Recently i participated in the Stanford AI course online and since then i tried to create some AI into my games (i am very new to programming). Last week i finished a game which implemented a very basic version of A*, just a simple 2D pathfinder trying to move to the goal in a labyrinth before the player does.

Right now i would like to give a go at developing an AI for a board game. Since i am still very new at this i would like to start at something not to difficult. Does anyone have any suggestions for a relatively simple board game that i can model an AI for?

Thanx!


PARTNERS