source: git/modules/openmath/kuchenessen_demo.py @ 913156

spielwiese
Last change on this file since 913156 was 913156, checked in by Michael Brickenstein <bricken@…>, 18 years ago
*bricken: initial version git-svn-id: file:///usr/local/Singular/svn/trunk@8995 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 951 bytes
Line 
1# -*- coding: utf-8 -*-
2#imports and basic objects
3import sys
4sys.path.insert(0,"/Users/michael/sing3/modules/openmathserver")
5import CD.gametheory as gametheory
6from objects import OMApply
7from context import Context
8from os import pipe
9from subprocess import Popen,PIPE
10from omxmlreader import *
11context=Context()
12
13#our cake
14rectangle_list=[(4,3),(3,3),(1,1),(2,4),(4,2)]
15print "Eingabeliste", rectangle_list
16#create Openmath representation
17cake=gametheory.cake_to_OM(rectangle_list)
18task=OMApply(gametheory.left_wins_sym,[cake])
19task=context.XMLEncodeObject(task)
20
21
22
23
24#open a pipe
25p=Popen(["python", "/Users/michael/sing3/modules/openmathserver/openmathhashunger.py"],
26    stdout=PIPE,stdin=PIPE)
27p.stdin.write(task)
28p.stdin.close()
29
30#parse it
31root=readStream(p.stdout)
32builder=OMFromXMLBuilder()
33doc=builder.build(root)
34
35#output
36erg=doc.getValue()
37if erg:
38    print "Spieler 1 gewinnt"
39else:
40    print "Spieler 1 gewinnt nicht"
41p.stdout.close()
Note: See TracBrowser for help on using the repository browser.