<commit_before>﻿using System;
using System.Threading;
using System.Windows.Forms;

namespace ISGPAI.Game
{
	public partial class GameForm : Form
	{
		private World _world;
		private Thread _gameThread;
		private long _timeSinceLastUpdate;
		private bool _playing;

		public GameForm()
		{
			InitializeComponent();
			InitializeGame();
		}

		/// <summary>
		/// Setup the gameloop and start it.
		/// </summary>
		private void InitializeGame()
		{
			_world = TestWorldFactory.CreateWorld();
			_gamePanel.World = _world;

			_gameThread = new Thread(GameLoop);
			_playing = true;
			_timeSinceLastUpdate = DateTime.Now.Ticks;
			_gameThread.Start();
		}

		/// <summary>
		/// The game loop. Updates and invalidates the game. Painting happens
		/// in the OnPaint method of GamePanel.
		/// </summary>
		private void GameLoop()
		{
			while (_playing)
			{
				long elapsedTicks = DateTime.Now.Ticks - _timeSinceLastUpdate;
				_timeSinceLastUpdate = DateTime.Now.Ticks;
				_world.Update((double)elapsedTicks / TimeSpan.TicksPerSecond);
				_gamePanel.Invalidate();
			}
		}

		/// <summary>
		/// Stops the gameloop, so the program will close.
		/// </summary>
		protected override void OnFormClosing(FormClosingEventArgs e)
		{
			base.OnFormClosing(e);
			_playing = false;
		}
	}
}
<commit_msg>GameForm.GameLoop() now has a Thread.Sleep(1) to prevent the game from going too fast.<commit_after>﻿using System;
using System.Threading;
using System.Windows.Forms;

namespace ISGPAI.Game
{
	public partial class GameForm : Form
	{
		private World _world;
		private Thread _gameThread;
		private long _timeSinceLastUpdate;
		private bool _playing;

		public GameForm()
		{
			InitializeComponent();
			InitializeGame();
		}

		/// <summary>
		/// Setup the gameloop and start it.
		/// </summary>
		private void InitializeGame()
		{
			_world = TestWorldFactory.CreateWorld();
			_gamePanel.World = _world;

			_gameThread = new Thread(GameLoop);
			_playing = true;
			_timeSinceLastUpdate = DateTime.Now.Ticks;
			_gameThread.Start();
		}

		/// <summary>
		/// The game loop. Updates and invalidates the game. Painting happens
		/// in the OnPaint method of GamePanel.
		/// </summary>
		private void GameLoop()
		{
			while (_playing)
			{
				long elapsedTicks = DateTime.Now.Ticks - _timeSinceLastUpdate;
				_timeSinceLastUpdate = DateTime.Now.Ticks;
				_world.Update((double)elapsedTicks / TimeSpan.TicksPerSecond);
				_gamePanel.Invalidate();
				Thread.Sleep(1);
			}
		}

		/// <summary>
		/// Stops the gameloop, so the program will close.
		/// </summary>
		protected override void OnFormClosing(FormClosingEventArgs e)
		{
			base.OnFormClosing(e);
			_playing = false;
		}
	}
}

{'fraction_non_alphanumeric': 0.10763765541740675, 'fraction_numerical': 0.0007104795737122557, 'mean_word_length': 2.710144927536232, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '59572', 'n_tokens_mistral': 1026, 'n_tokens_neox': 871, 'n_words': 217}