<commit_before>package
{//old version still on github if this gets too screwed up
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	[SWF(width="650", height="500", backgroundColor="#000000", frameRate="24")]
	
	public class Mukik extends Sprite
	{
		public var background: Background = new Background();
		public var snake:Snake;
		public var b:int = 45;//variable for the box size of the game... the size of the square of the snake's body parts and the blocks.
		public var xTurn:int;
		public var yTurn:int;
		private var board: Array = new Array();
		private var rock:Rock;
		private var rocks:Array = new Array();
		public var symbol:SymRock;
		private var symRocks:Array = new Array();
		//public var boxMap:Object = new Object();  //hopefully dont need this
		public var size:int = 3; //length of the snake
		public var snakeBods:Array = new Array();
		public var bod:SnakeBod;
		private var tail:SnakeTail = new SnakeTail();
		public var vx:int;
		public var vy:int;
		public var bvx:int;
		public var bvy:int;
		//public var path:Array = new Array(size);//idk
		public var dir:String; //l,r,u,d for the direction the snake is going.
		public var turn:Boolean = false;
		public var bounce:Boolean = false;
		public function Mukik()
		{
			board = 
				[
					[0,0,0,0,0,0,0,0,0,0,0],
					[0,0,0,0,0,0,0,0,0,0,0],
					[0,0,4,2,3,1,2,2,4,0,0],
					[0,0,2,0,0,0,0,0,1,1,4],
					[4,1,1,0,0,0,0,0,3,0,0],
					[0,0,3,0,0,4,1,3,2,0,0],
					[0,0,3,0,0,3,0,0,1,0,0],
					[0,0,4,0,0,2,0,0,1,0,0]
				];
			createGame();
			setupListeners();
			
		}
		public function createGame():void {
			snake = new Snake(0);		
			addObject(background, 0, 0);
			
			
			
			for (var i:int=0;i<board.length;i++) {
				for (var j:int=0;j<board[0].length;j++) {
					if (board[i][j] > 0) {       //if the board has something other than zero put a rock there.
						rock = new Rock();
						addObject(rock, j*50 + 50, i*50 + 50);
						rocks.push(rock);
						
						if(board[i][j] == 1) {    //if the number is one put a hidden triangle there
							symbol = new SymRock(0);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 2) {    //if the number is two put a hidden square there
							symbol = new SymRock(1);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 3) {    //if the number is three put a hidden cross there
							symbol = new SymRock(2);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 4) {    //if the number is four put a hidden skull there
							symbol = new SymRock(3);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
					}
				}
			}
			
			addObject(snake, 200, 50);  
			addBody(size);
			dir = 'r';
		}
		public function addObject(object:Sprite, xpos:int, ypos:int):void {			
			stage.addChild(object);
			object.x = xpos;
			object.y = ypos;
		}
		public function setupListeners():void {
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			//stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);  //not needed for constant movement.
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		public function addBody(size:int):void {
			
			//Add the body segments
			var p:int = 0;    //placeholder for putting on the snake bods
			for(var i:int = 0; i<size; i++){
				bod = new SnakeBod();
				p += b;
				addObject(bod, snake.x-p, snake.y);				
				bod.rotation = 90;
				snakeBods.push(bod);
			}
			p += b;
			addObject(tail,snake.x-p, snake.y);
			tail.rotation = 90;
			snakeBods.push(tail);
		}
		
		
		
		public function enterFrameHandler(event:Event):void {
			//var p:int = 0;
			snake.x += vx;
			snake.y += vy;
			
			for(var i:int = 0; i<size+1; i++) {
				snakeBods[i].x += vx;
				snakeBods[i].y += vy;
			}
			//set the vision
			<commit_msg>started new algorithm for remembering the path of the snake head<commit_after>package
{//old version still on github if this gets too screwed up
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	[SWF(width="650", height="500", backgroundColor="#000000", frameRate="24")]
	
	public class Mukik extends Sprite
	{
		public var background: Background = new Background();
		public var snake:Snake;
		public var b:int = 45;//variable for the box size of the game... the size of the square of the snake's body parts and the blocks.
		public var xTurn:int;
		public var yTurn:int;
		private var board: Array = new Array();
		private var rock:Rock;
		private var rocks:Array = new Array();
		public var symbol:SymRock;
		private var symRocks:Array = new Array();
		
		public var size:int = 3; //length of the snake
		public var snakeBods:Array = new Array();
		public var bod:SnakeBod;
		private var tail:SnakeTail = new SnakeTail();
		public var vx:int;
		public var vy:int;
		public var bvx:int;
		public var bvy:int;
		//public var path:Array = new Array(size);//idk
		public var dir:String; //l,r,u,d for the direction the snake is going.
		public var turn:Boolean = false;
		public var bounce:Boolean = false;
		private var path: Array = new Array(size+1);  //this three dimensional array holds the number of snake body segments (including the tail) of path[i][x,y,r] = [x position, y position, and rotation being 0,1,2,3] for 0=vertical 1=90 degrees clockwise 2=180 and 3=270!  This will be stored 10 times for each segment to follow the path of the snake head.
		private var pCount:int = 0; //path counter
		private var bodyCount:int = 0;  // counter for active body
		public function Mukik()
		{
			board = 
				[
					[0,0,0,0,0,0,0,0,0,0,0],
					[0,0,0,0,0,0,0,0,0,0,0],
					[0,0,4,2,3,1,2,2,4,0,0],
					[0,0,2,0,0,0,0,0,1,1,4],
					[4,1,1,0,0,0,0,0,3,0,0],
					[0,0,3,0,0,4,1,3,2,0,0],
					[0,0,3,0,0,3,0,0,1,0,0],
					[0,0,4,0,0,2,0,0,1,0,0]
				];
			createGame();
			setupListeners();
			
		}
		public function createGame():void {
			snake = new Snake(0);		
			addObject(background, 0, 0);
			
			
			
			for (var i:int=0;i<board.length;i++) {
				for (var j:int=0;j<board[0].length;j++) {
					if (board[i][j] > 0) {       //if the board has something other than zero put a rock there.
						rock = new Rock();
						addObject(rock, j*50 + 50, i*50 + 50);
						rocks.push(rock);
						
						if(board[i][j] == 1) {    //if the number is one put a hidden triangle there
							symbol = new SymRock(0);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 2) {    //if the number is two put a hidden square there
							symbol = new SymRock(1);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 3) {    //if the number is three put a hidden cross there
							symbol = new SymRock(2);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
						if(board[i][j] == 4) {    //if the number is four put a hidden skull there
							symbol = new SymRock(3);
							addObject(symbol, j*50 + 50, i*50 + 50);
							symRocks.push(symbol);
							symbol.visible = false;
						}
					}
				}
			}
			
			addObject(snake, 200, 50); 
			path[0][0] = [snake.x, snake.y, 1];
			addBody(size);
			dir = 'r';
		}
		public function addObject(object:Sprite, xpos:int, ypos:int):void {			
			stage.addChild(object);
			object.x = xpos;
			object.y = ypos;
		}
		public function setupListeners():void {
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			//stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);  //not needed for constant movement.
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		public function addBody(size:int):void {
			
			//Add the body segments
			
			for(var i:int = 0; i<size; i++){
				bod = new SnakeBod();
				
				addObject(bod, path[i][0], path[i][1]);	//use path to place the bodies		
				bod.rotation = 90;
				snakeBods.push(bod);
			}
			
			addObject(tail,path[size][0], path[size][1]);
			tail.rotation = 90;
			snakeBods.push(tail);
		}
		public function addPath(x:int, y:int, r:int):void {
			var rot:int;
			if (r == 0) {rot=0;}
			else if (r == 90) {rot=1;}
			else if (r == 180) {rot=2;}
			else {rot=3;}
			while(pCount < 10) {
				path[0][pCount] = [x,y,rot];
			}
			if (pCount == 10) {
				pCount = 0;
				for(var i:int = 0; i < size; i++) {
					path.pop();
					path[i] = path[i+1];
				}
				
				bodyCount += 1;
				
				if (bodyCount == size+1) {
					bodyCount = 0;
				}
			}
			if (r == 0) {rot=0;}
			else if (r == 90) {rot=1;}
			else if (r == 180) {rot=2;}
			else {rot=3;}
			
			pCount += 1;
		}
		
		
		public function enterFrameHandler(event:Event):void {
			//var p:int = 0;
			snake.x += vx;
			snake.y += vy;
			addPath(snake.x, snake.y, snake.rotation);
			for(var i:int = 0; i<size+1; i++) {
				snakeBods[i].x += vx;
				snakeBods[i].y += vy;
			}
			//set the vision
			
{'fraction_non_alphanumeric': 0.15138933248163525, 'fraction_numerical': 0.043330139465559456, 'mean_word_length': 2.8094079480940795, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '6906511', 'n_tokens_mistral': 4440, 'n_tokens_neox': 3438, 'n_words': 925}