Logeek
, (*1)
Introduction
Logeek is a PHP engine for learning basic programming by simulating movement of element through a board. It's concepts are similar to LEGO Mindstorms or Android and iPhone games like Robot School., (*2)
Requirements
Only PHP 5.3 (namespaces)., (*3)
Installation
This library is available on Packagist under alias thunderer/logeek
., (*4)
Usage
// first create Board object with desired dimensions
$board = new Thunder\Logeek\Board(5, 5);
// then add field types and actions allowed on this board
$board->addFieldTypes(array('ground' => '.'));
$board->addActions(array(new MoveAction()));
// load board using field aliases
$board->loadFromString('...');
// add actors and exits
$board->addExit('exit', 2, 0);
$board->addActor('robot', 0, 0, 'right');
// add program for your actor, function "main" will be run
$compiler = new Compiler();
$functions = $compiler->compile($board, '
function main
move 2
');
// run the simulation (print board size before and after)
echo $board->renderBoard();
$board->runActor('robot');
echo $board->renderBoard();
// check if everything is correct
assert(true === $board->isActorAtExit('robot', 'exit'));
Program syntax is a simple Python-like programming language with significant white-space (indentation of 2 spaces). Number as the first token in line means repeating that line that number of times. Currently implemented actions are as follows:, (*5)
-
Basic:, (*6)
- rotate left|right
- move length|variable
- pick up|down
- open
-
Loops:, (*7)
- for iterations
- while variable is|not value
-
Conditions:, (*8)
-
Structure:, (*9)
-
Sensors:, (*10)
- sensor-type variable
- sensor-distance variable
- sensor-proximity variable
Sample simulations are implemented in tests/LogeekTest.php
, it's easy to look, change and experiment with them., (*11)
License
See LICENSE file in the root of this repository., (*12)