initial merge of AI and GUI versions