<commit_before>﻿using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using QuakeConsole;

namespace Sandbox
{
    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public class SandboxGame : Game
    {        
        private const Keys ToggleConsole = Keys.OemTilde;
        private const float ConsoleBackgroundSpeedFactor = 1/24f;        
        private static readonly Color BackgroundColor = new Color(0x1d, 0x1d, 0x1d, 0xff);
        private static readonly Color SelectionColor = Color.DarkGray;
        private static readonly Vector2 ConsoleBackgroundTiling = new Vector2(2.5f, 1.5f);

        private readonly GraphicsDeviceManager _graphics;

        private readonly ConsoleComponent _console;
        private readonly PythonInterpreter _pythonInterpreter = new PythonInterpreter();
        private readonly ManualInterpreter _manualInterpreter = new ManualInterpreter();
        private readonly RoslynInterpreter _roslynInterpreter = new RoslynInterpreter();
        private readonly CameraControllerComponent _camera;

        private SpriteBatch _spriteBatch;
        private BasicEffect _effect;

        private Cube _cube;

        private SpriteFont _lucidaConsole;
        private SpriteFont _arial;                
        
        private Matrix _consoleBgTransform = Matrix.Identity;

        private KeyboardState _previousKeyState;
        private KeyboardState _currentKeyState;

        public SandboxGame()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _console = new ConsoleComponent(this)
            {
                Padding = 10.0f,
                FontColor = Color.White,
                InputPrefixColor = Color.White,
                BackgroundColor = Color.White,                
                BottomBorderThickness = 4.0f,
                BottomBorderColor = Color.Red,
                SelectionColor = SelectionColor,                
                LogInput = cmd => Debug.WriteLine(cmd) // Logs input commands to VS output window.
            };            
            Components.Add(_console);

            _camera = new CameraControllerComponent(this);
            Components.Add(_camera);

            // Add search path for IronPython standard library. This is so that Python engine knows where to load modules from.
            _pythonInterpreter.AddSearchPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib\\"));

            // Import threading module and Timer function.
            _pythonInterpreter.RunScript("import threading");
            _pythonInterpreter.RunScript("import random");
            _pythonInterpreter.RunScript("from threading import Timer");            

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _graphics.PreferredBackBufferWidth = 1280;
            _graphics.PreferredBackBufferHeight = 720;            
            Window.AllowUserResizing = false;            

            IsMouseVisible = true;
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _effect = new BasicEffect(GraphicsDevice) { VertexColorEnabled = true };

            _arial = Content.Load<SpriteFont>("arial");
            _lucidaConsole = Content.Load<SpriteFont>("lucida_console");

            _camera.LoadContent();            

            _cube = new Cube(GraphicsDevice, _effect);

            // Set console's font and interpreter.
            _console.LoadContent(_arial, _roslynInterpreter);            
            _console.BackgroundTexture = Content.Load<Texture2D>("console");            

            // Register variables and types of interest with the Python interpreter.
            _pythonInterpreter.AddVariable("cube", _cube);
            _pythonInterpreter.AddVariable("console", _console);
            _pythonInterpreter.AddVariable("pythonInterpreter", _pythonInterpreter);
            _pythonInterpreter.AddVariable("manualInterpreter", _manualInterpreter);
            _pythonInterpreter.AddVariable("roslynInterpreter", _roslynInterpreter);
            _pythonInterpreter.AddType(typeof (Utilities));
<commit_msg>[Sandbox] Default interpreter to PythonInterpreter<commit_after>﻿using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using QuakeConsole;

namespace Sandbox
{
    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public class SandboxGame : Game
    {        
        private const Keys ToggleConsole = Keys.OemTilde;
        private const float ConsoleBackgroundSpeedFactor = 1/24f;        
        private static readonly Color BackgroundColor = new Color(0x1d, 0x1d, 0x1d, 0xff);
        private static readonly Color SelectionColor = Color.DarkGray;
        private static readonly Vector2 ConsoleBackgroundTiling = new Vector2(2.5f, 1.5f);

        private readonly GraphicsDeviceManager _graphics;

        private readonly ConsoleComponent _console;
        private readonly PythonInterpreter _pythonInterpreter = new PythonInterpreter();
        private readonly ManualInterpreter _manualInterpreter = new ManualInterpreter();
        private readonly RoslynInterpreter _roslynInterpreter = new RoslynInterpreter();
        private readonly CameraControllerComponent _camera;

        private SpriteBatch _spriteBatch;
        private BasicEffect _effect;

        private Cube _cube;

        private SpriteFont _lucidaConsole;
        private SpriteFont _arial;                
        
        private Matrix _consoleBgTransform = Matrix.Identity;

        private KeyboardState _previousKeyState;
        private KeyboardState _currentKeyState;

        public SandboxGame()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _console = new ConsoleComponent(this)
            {
                Padding = 10.0f,
                FontColor = Color.White,
                InputPrefixColor = Color.White,
                BackgroundColor = Color.White,                
                BottomBorderThickness = 4.0f,
                BottomBorderColor = Color.Red,
                SelectionColor = SelectionColor,                
                LogInput = cmd => Debug.WriteLine(cmd) // Logs input commands to VS output window.
            };            
            Components.Add(_console);

            _camera = new CameraControllerComponent(this);
            Components.Add(_camera);

            // Add search path for IronPython standard library. This is so that Python engine knows where to load modules from.
            _pythonInterpreter.AddSearchPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib\\"));

            // Import threading module and Timer function.
            _pythonInterpreter.RunScript("import threading");
            _pythonInterpreter.RunScript("import random");
            _pythonInterpreter.RunScript("from threading import Timer");            

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _graphics.PreferredBackBufferWidth = 1280;
            _graphics.PreferredBackBufferHeight = 720;            
            Window.AllowUserResizing = false;            

            IsMouseVisible = true;
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _effect = new BasicEffect(GraphicsDevice) { VertexColorEnabled = true };

            _arial = Content.Load<SpriteFont>("arial");
            _lucidaConsole = Content.Load<SpriteFont>("lucida_console");

            _camera.LoadContent();            

            _cube = new Cube(GraphicsDevice, _effect);

            // Set console's font and interpreter.
            _console.LoadContent(_arial, _pythonInterpreter);            
            _console.BackgroundTexture = Content.Load<Texture2D>("console");            

            // Register variables and types of interest with the Python interpreter.
            _pythonInterpreter.AddVariable("cube", _cube);
            _pythonInterpreter.AddVariable("console", _console);
            _pythonInterpreter.AddVariable("pythonInterpreter", _pythonInterpreter);
            _pythonInterpreter.AddVariable("manualInterpreter", _manualInterpreter);
            _pythonInterpreter.AddVariable("roslynInterpreter", _roslynInterpreter);
            _pythonInterpreter.AddType(typeof (Utilities));

{'fraction_non_alphanumeric': 0.07260080426040648, 'fraction_numerical': 0.007173133355070101, 'mean_word_length': 2.2231173380035028, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '6068765', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2172, 'n_words': 572}