Skip to content

Instantly share code, notes, and snippets.

Pressman is a two-player board-game where opponents try to capture all of the other player's SOLDIERS. The SOLDIERS are round black and white pieces similar in size to checker pieces. The board is an 8x8 grid of 64 squares of alternating light and dark color (similar to a checkers or chess board) called the BATTLEFIELD.

At the beginning of the game one player has 28 white SOLDIERS and the other other has 28 black SOLDIERS. Players set up their pieces by filling up the first two rows that are closest to them with 16 of their 28 SOLDIERS as shown in the diagram below:

The remaining pieces are placed off to the side of the board for later use.

Movement and Capturing of SOLDIERS

The BATTLEFIELD is divided into eight vertical columns, called FILES, and eight horizontal rows, called FLANKS. All Pressman SOLDIERS move similar to a queen does in the game of chess. They can move horizontally along FLANKS, vertically along FILES, or diagonally.

from sys import argv
import random
city_map = {}
class City(object):
def __init__(self, name, aliens, neighbors={}):
self.name = name
# aliens in the city will be stored in an array
self.aliens = []
@paulmouzas
paulmouzas / data.csv
Last active August 29, 2015 14:26 — forked from eightysteele/data.csv
Unicode DictReader and DictWriter
id name age
0 aaron 34
1 tina 36
2 noah ©
<?php
require_once 'app/Mage.php';
Mage::app();
// $parent_category = new Mage_Catalog_Model_Category();
// $id = $parent_category->getId();
// print_r(id);
// $category = Mage::getModel('catalog/category');
// $category->load(7); // set parent to be root category
@paulmouzas
paulmouzas / update_categories.php
Last active September 28, 2015 18:20
update_categories.php
<?php
require_once 'app/Mage.php';
Mage::app();
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids){
foreach ($ids as $id){
<?php
// script to remove categories from navigation menu
// $children = Mage::getModel('catalog/category')->getCategories(7);
require_once 'app/Mage.php';
Mage::app();
$category = Mage::getResourceModel("catalog/category_collection")->addFieldToFilter("name" , "Aphex Twin");
$cat_det=$category->getData();
$category_id=$cat_det[0][entity_id];
require_once 'app/Mage.php';
Mage::app();
function getCategoryIdByName($categoryName) {
$category = Mage::getResourceModel("catalog/category_collection")->addFieldToFilter("name" , $categoryName);
$cat_det=$category->getData();
$category_id=$cat_det[0][entity_id];
return $category_id;
}
$dir = new DirectoryIterator("./getbyname");
<?php
include_once 'magento/app/Mage.php';
Mage::app();
$childproduct = Mage::getModel('catalog/product')->loadByAttribute('sku','red');
$parentproduct = Mage::getModel('catalog/product')->loadByAttribute('sku','mytestsku');
function _attachProductToConfigurable( $_childProduct, $_configurableProduct ) {
$loader = Mage::getResourceModel( 'catalog/product_type_configurable' )->load( $_configurableProduct );
$children = $_configurableProduct->getTypeInstance()->getUsedProductIds();
import MySQLdb
from MySQLdb.cursors import DictCursor
class DatabaseBridge():
def __init__(self, *args, **kwargs):
kwargs['cursorclass'] = DictCursor
self.cnx = MySQLdb.connect (**kwargs)
self.cnx.autocommit(True)
self.cursor = self.cnx.cursor()
@paulmouzas
paulmouzas / normalise.py
Created December 29, 2015 15:04 — forked from j4mie/normalise.py
Normalise (normalize) unicode data in Python to remove umlauts, accents etc.
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal