part1
#!/usr/bin/env php
<?php
/** Day 16 Part 1 & 2
*
*/
require(__DIR__.'/functions.php');
if (@$argv[1] == 'sample'){
$input = file_get_contents(__DIR__.'/sample.txt');
} else if (@$argv[1] == 'sample2'){
$input = file_get_contents(__DIR__.'/sample2.txt');
} else if (@$argv[1] == 'sample3'){
$input = file_get_contents(__DIR__.'/sample3.txt');
} else if (@$argv[1] == 'sample4'){
$input = file_get_contents(__DIR__.'/sample4.txt');
} else {
$input = file_get_contents(__DIR__.'/input.txt');
}
$lines = explode("\n", trim($input));
$lines = array_map('trim', $lines);
//$tiles = str_split(trim($input));
$tiles = array_map('str_split', explode("\n", trim($input)) );
define('DEAD_BEAM', -1);
define('UP', 0);
define('RIGHT', 1);
define('DOWN', 2);
define('LEFT', 3);
define('X_POSITION', 0);
define('Y_POSITION', 1);
define('BEAM_DIRECTION', 2);
$beam_direction = 0;
$game = new Game();
foreach ($tiles as $tile_row){
//$game->row();
foreach ($tile_row as $tile){
echo $tile;
//$game->tile();
}
echo "\n";
}
$game->play($tiles, 0, 0,RIGHT);
$game->show_energized();
$game->show_directions();
//print_r($game->beam_locations);
echo "\n";
echo "\n";
echo "\n";