예제 #1
0
파일: game.py 프로젝트: DenprogIS/Chess
 def __init__(self):
     self.__map = Map(is_auto_init=True)
     self.__color_current_move = PieceColor.WHITE
     self.__checked_king = CheckedKingGetter(self.map).get_checked_king()
     self.__game_is_finished = False
     self.__map_cvs = MapCVS()
     self.__map_cvs.add_map(self.map)
예제 #2
0
    def setUp(self):
        self.c1 = Country.from_json([[[0, 0], [200, 200], [100, 300]]])
        self.c2 = Country.from_json([[[0, 0], [200, 0], [200, 200]]])

        self.c3 = Country.from_json([[[0, 0], [0, 300], [100, 300]]])
        self.c4 = Country.from_json([[[200, 200], [100, 300], [500, 500]]])
        self.c_map = Map([self.c1, self.c2, self.c3, self.c4])
예제 #3
0
 def __init__(self, countries_map: Map, palette):
     super(Visualizer, self).__init__()
     countries_map.calc_incident_countries()
     self.colorer = Colorer(countries_map, palette)
     self.countries_to_polygons = self.update_map()
     self.reset_action = None
     self.highlighted_country = None
     self.initUI()
예제 #4
0
 def setUp(self):
     self.two_colors_map = Map.from_file("./test_maps/2color.json")
     self.four_colors_map = Map.from_file("./test_maps/4color.json")
     self.piece_country_map = Map.from_file(
         "./test_maps/2country_with_pieces.json")
     self.two_colors_map.calc_incident_countries()
     self.piece_country_map.calc_incident_countries()
     self.four_colors_map.calc_incident_countries()
     self.palette = Palette.from_json('palette.json')
예제 #5
0
 def save(self):
     self.add_country()
     name = "./maps/map_{}.json".format(str(uuid.uuid4()))
     new_map = Map(self.countries)
     with open(name, 'w') as f:
         f.write(new_map.to_json())
     msg = QtWidgets.QMessageBox()
     msg.setText("Saved to {}".format(name))
     msg.setWindowTitle("Saved")
     msg.exec_()
예제 #6
0
def build_game_with_2maps_winning_picks_team1_and_team3():
    game = Game(None, team1.id_team, team3.id_team, None, 2, 1, team1.id_team,
                3, "Mapa 1", "Mapa 2", "", "", "Mapa 3", team1.actual_rank,
                team3.actual_rank)
    game.team1 = team1
    game.team2 = team3
    map1 = Map(game.id_game, "Mapa 1", 9, 6, 7, 6, 0, 0, 16, 12)
    map2 = Map(game.id_game, "Mapa 2", 8, 7, 8, 4, 0, 0, 16, 11)

    game.maps = [map1, map2]

    return game
예제 #7
0
def build_game_with_3maps_winning_picks():
    game = Game(None, team1.id_team, team2.id_team, None, 2, 1, team1.id_team,
                3, "Mapa 1", "Mapa 2", "", "", "Mapa 3", team1.actual_rank,
                team2.actual_rank)
    game.team1 = team1
    game.team2 = team2
    map1 = Map(game.id_game, "Mapa 1", 9, 6, 6, 2, 0, 0, 16, 8)
    map2 = Map(game.id_game, "Mapa 2", 7, 8, 6, 8, 0, 0, 13, 16)
    map3 = Map(game.id_game, "Mapa 3", 7, 8, 6, 8, 0, 0, 13, 16)

    game.maps = [map1, map2, map3]

    return game
예제 #8
0
    def __init__(self, loc, **args):
        Canvas.__init__(self, loc, args)

        self.minX = None
        self.minY = None
        self.maxX = None
        self.maxY = None
        self.box = None
        self.clickNum = 0

        self.currentImage = None
        self.canvasImage = None
        self.map = Map(Map.MAPS[2])

        self.bind('<Button-1>', self.click)
예제 #9
0
def auth_viewer(data):
    print rooms()
    token = data['token']
    print token, "viewer", type(token)
    if token not in game:
        game[token] = Map()
    join_room(token)
    emit('result', {'token': token, 'data': game[token].to_json()})
예제 #10
0
class TestMap(TestCase):
    def setUp(self):
        self.c1 = Country.from_json([[[0, 0], [200, 200], [100, 300]]])
        self.c2 = Country.from_json([[[0, 0], [200, 0], [200, 200]]])

        self.c3 = Country.from_json([[[0, 0], [0, 300], [100, 300]]])
        self.c4 = Country.from_json([[[200, 200], [100, 300], [500, 500]]])
        self.c_map = Map([self.c1, self.c2, self.c3, self.c4])

    def test_calc_incident_countries(self):
        self.c_map.calc_incident_countries()
        self.assertTrue(self.c2.is_neighbour(self.c1))
        self.assertTrue(self.c4.is_neighbour(self.c1))

    def test_set_sizes(self):
        self.assertTrue(self.c_map.width, 500)
        self.assertTrue(self.c_map.height, 500)
예제 #11
0
    def start(self, gid):

        # You must be the owner of a game to start it, so we should
        # check if they are loged on
        if not self.checkLogin(): return

        query = Game.query(Game.gid == gid)

        if query.count() != 1:
            self.stderr('Unknown Game')
        else:
            game = query.fetch(1)[0]

            if game.owner != self.user.uid:
                self.stderr('You are not authorised to start this game')
            else:
                game.running = True
                savedCMap    = None

                # Pick places for each of the players and set their
                # lastUpdated value to the start of the game so they can
                # load resources
                mapObj = Map(game.gmap)
                for user in User.query(User.gid == game.gid).fetch():
                    cMap               = Map.generateCityMap()
                    user.positionOnMap = mapObj.pickRandomTile(user)
                    user.lastUpdated   = datetime.datetime.now()
                    user.homeMap       = cMap.toString()
                    user.put()
                    if user.uid == self.user.uid:
                        savedCMap = cMap

                game.gmap = mapObj.toString()
                game.put()

                self.json['game'] = { }
                self.json['game']['data'] = {
                    "status" : 'started',
                    "token"  : game.gid
                }
                self.json['player'] = self.user.toDict()
                self.json['game']['maps']   = {
                    "world" : mapObj.toDict(),
                    "city"  : cMap.toDict()
                }
예제 #12
0
파일: mapa.py 프로젝트: dawidk089/albedo
class MainWindow(QtGui.QWidget):

    def __init__(self):
        super(MainWindow, self).__init__()

        self.map = Map(100, 100)
        self.map.init_pixels(0, 0, 0)
        self.map.set_pixels()

        self.label = QtGui.QLabel()
        self.label.setPixmap(QPixmap.fromImage(self.map.get()))

        hbox = QtGui.QHBoxLayout()
        vbox = QtGui.QVBoxLayout()
        hbox.addWidget(self.label)
        vbox.addLayout(hbox)
        self.setLayout(vbox)


    # definicja podpiec
    def slot_conn(self, slots={}):
        for key in slots:
            self.button[key].clicked.connect(slots[key])
            print(">checkpoint: slots plugging for key: ", key, 'in class: ', self.__class__.__name__)


    # pomocnicza metoda do budowania layout'u
    def box(self, el_type, elems):

        if el_type == 'vertical':
            box = QtGui.QVBoxLayout()

        elif el_type == 'horizontal':
            box = QtGui.QHBoxLayout()

        for elem in elems:
            if elem[0] == 'widget':
                box.addWidget(elem[1])
            elif elem[0] == 'layout':
                box.addLayout(elem[1])
            elif elem[0] == 'stretch':
                box.addStretch(1)

        return box
예제 #13
0
    def create(self):
        gMap            = Map.convertToWorldMap(self.request.POST['game_map'])
        game            = Game(gid = uuid.uuid4().hex)
        game.name       = self.getPOSTorRandom('game_name', Game)
        game.gmap       = gMap.toString()
        game.maxPlayers = gMap.countHabitable()
        game.private    = False if self.request.POST['game_type'] == 'public' else True
        game.owner      = self.join_game(game, self.getPOSTorRandom('game_user', User))
        game.put()

        self.json    = game.toDict()
예제 #14
0
        def reload():
            # Box on Map Handler
            box = self.canvas.getBox()
            self.currentFilter = DataHandler.EMPTY_FILTER
            if box is not None:
                self.currentFilter['box'] = box
            else:
                self.currentFilter['box'] = None

            if boxAroundVar.get() == 'Attacker':
                self.currentFilter['box_around'] = 'Attacker'
            else:
                self.currentFilter['box_around'] = 'Victim'

            # Map Selector
            self.canvas.setMap(Map(currentMap.get()))
            self.currentFilter['map'] = "'" + currentMap.get() + "'"

            # Attack Side Selector
            if attSideVar.get() == "Both":
                self.currentFilter['att_side'] = None
            else:
                self.currentFilter['att_side'] = "'" + attSideVar.get() + "'"

            # Victim Side Selector
            if vicSideVar.get() == "Both":
                self.currentFilter['vic_side'] = None
            else:
                self.currentFilter['vic_side'] = "'" + vicSideVar.get() + "'"

            # User ID Entry
            if idEntry.get() != 'None':
                self.currentFilter['att_id'] = int(idEntry.get())
            else:
                self.currentFilter['att_id'] = None

            # Weapon Selection
            if weaponVar.get() != 'All':
                self.currentFilter['wp'] = "'" + weaponVar.get() + "'"
            else:
                self.currentFilter['wp'] = None

            for key, data in enumerate(vicAndAttRankRange):
                if data.get() != '':
                    self.currentFilter['player_rank_range'][key] = int(
                        data.get())
                else:
                    # if key is an odd number set value to 18, else even set 0
                    self.currentFilter['player_rank_range'][key] = 18 * (key %
                                                                         2)

            self.canvas.addData(self.data.applyFilter(self.currentFilter))
            self.canvas.reloadImage()
예제 #15
0
    def __init__(self):
        # Bluetooth.
        connection = BluetoothConnection("00:00:12:06:56:83", 0x1001)

        # IP
        #connection = IPConnection("10.42.0.1", 50001)

        # USB Serial.
        #connection = SerialConnection("/dev/ttyACM1", 115200)

        self.proxy = Proxy(connection)
        self.proxy.listeners.append(self)

        self.robot = Robot(self.proxy)
        self.robot.x = 1.15
        self.robot.y = 1.15

        self.map = Map(self.robot, 2.3, 0.23)

        self.path_planner = GridNav(self.map)

        Thread.__init__(self)
예제 #16
0
파일: mapa.py 프로젝트: dawidk089/albedo
    def __init__(self):
        super(MainWindow, self).__init__()

        self.map = Map(100, 100)
        self.map.init_pixels(0, 0, 0)
        self.map.set_pixels()

        self.label = QtGui.QLabel()
        self.label.setPixmap(QPixmap.fromImage(self.map.get()))

        hbox = QtGui.QHBoxLayout()
        vbox = QtGui.QVBoxLayout()
        hbox.addWidget(self.label)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
예제 #17
0
    def createMap(self, game_id, map_name, team1_tr_rounds, team2_tr_rounds,
                  team1_ct_rounds, team2_ct_rounds, overtime_team1_rounds,
                  overtime_team2_rounds, team1_total_rounds,
                  team2_total_rounds):

        c1 = Map(game_id, map_name, team1_tr_rounds, team2_tr_rounds,
                 team1_ct_rounds, team2_ct_rounds, overtime_team1_rounds,
                 overtime_team2_rounds, team1_total_rounds, team2_total_rounds)

        try:
            self.session.add(c1)
            self.session.commit()
        except:
            self.session.rollback()
            raise
        return c1
예제 #18
0
    def open_map(self):
        infile = Path(self.map_file).open()

        # Do not bother with any validation for now.
        self.grid_size = float(infile.readline())
        self.cell_size = float(infile.readline())

        # Addition of the boundary.
        #self.grid_size += self.cell_size
        self.grid_size = int(self.grid_size / self.cell_size)

        self.robot.cell_size = self.cell_size
        self.map = Map(self.robot, self.grid_size * self.cell_size,
                       self.cell_size)

        y = self.grid_size - 1

        while y >= 0:
            line = infile.readline()

            for x in range(self.grid_size):
                if line[x] == "#":
                    self.map.grid[x][y].state = 2
                elif line[x] == "R":
                    self.robot.change_odometry(round(x * self.cell_size, 2),
                                               round(y * self.cell_size, 2),
                                               1.57)

                    #print("Waiting for odometry change...")

                    # Wait for odometry change to take affect.
                    #while self.robot.x != round(x * self.cell_size, 2) and self.robot.y != round(y * self.cell_size, 2):
                    #    continue

                    #print("Odometry change successful!")

                elif line[x] == "G":
                    self.map.goal_x = x
                    self.map.goal_y = y
                elif line[x] == " ":
                    self.map.grid[x][y].state = 1

            y -= 1

        infile.close()
    def pawn_capture_other_pawn_on_aisle(self):
        if self.__previous_map is None or self._move_vector.x == 0:
            return False

        last_move_vector = Map.get_last_move_vector(self.__previous_map,
                                                    self._current_map)
        enemy_piece = self._current_map.get(last_move_vector.end_cell)

        if enemy_piece.type is not \
                PieceType.PAWN or last_move_vector.length_in_cells != 2:
            return False

        if last_move_vector.end_cell == self._move_vector \
                .horizontal_ort.end_cell:
            self.notify_game_remove_piece(last_move_vector.end_cell)
            return True

        return False
예제 #20
0
	def __init__(self):
		# Bluetooth.
		connection = BluetoothConnection("00:00:12:06:56:83", 0x1001)

		# IP
		#connection = IPConnection("10.42.0.1", 50001)
		
		# USB Serial.
		#connection = SerialConnection("/dev/ttyACM1", 115200)

		self.proxy = Proxy(connection)
		self.proxy.listeners.append(self)
		
		self.robot = Robot(self.proxy)
		self.robot.x = 1.15
		self.robot.y = 1.15

		self.map = Map(self.robot, 2.3, 0.23)

		self.path_planner = GridNav(self.map)

		Thread.__init__(self)
예제 #21
0
from model.hero import *
from model.map import Map
from model.parameters import Parameters
from model.state import State
from model.abilites import AbilityType
from model.teams import Teams
import json
import random
import time

game = json.loads(input())
game_map = Map(game)  # карта игрового мира
game_params = Parameters(game)  # параметры игры
game_teams = Teams(game)  # моя команда

while True:
    try:
        """ Получение состояния игры """
        state = State(input(), game_teams, game_params)

        my_buildings = state.my_buildings()
        my_squads = state.my_squads()
        # сортируем по остаточному пути
        my_squads.sort(key=lambda c: c.way.left, reverse=False)

        enemy_buildings = state.enemy_buildings()
        enemy_squads = state.enemy_squads()

        neutral_buildings = state.neutral_buildings()

        forges_buildings = state.forges_buildings()
예제 #22
0
def connect():
    token = 1
    game[token] = Map()
    emit('result', {'token': token, 'data': game[token].to_json()})
예제 #23
0
class Main(threading.Thread):
    def __init__(self):
        # Bluetooth.
        connection = BluetoothConnection("00:00:12:06:56:83", 0x1001)

        # IP
        #connection = IPConnection("10.42.0.1", 50001)

        # USB Serial.
        #connection = SerialConnection("/dev/ttyACM1", 115200)

        self.proxy = Proxy(connection)
        self.proxy.listeners.append(self)

        self.robot = Robot(self.proxy)
        self.robot.x = 1.15
        self.robot.y = 1.15

        self.map = Map(self.robot, 2.3, 0.23)

        self.path_planner = GridNav(self.map)

        Thread.__init__(self)

    def run(self):

        while True:

            command = input()

            if len(command) < 1:
                continue

            if command[0] == "w":
                self.robot.go_forward()
            elif command[0] == "s":
                self.robot.go_backward()
            elif command[0] == "a":
                self.robot.rotate_left()
            elif command[0] == "d":
                self.robot.rotate_right()
            elif command[0] == "q":
                self.robot.halt()
            elif command[0] == "e":
                if command == "end":
                    break

                self.robot.scan()
            elif command[0] == "p":
                self.robot.ping()
            elif command[0] == "z":
                self.robot.reset()
            elif command[0] == "r":
                if len(command) < 5:
                    print("Invalid heading format rX.XX: " + command)
                    continue

                self.robot.rotate_to(float(command[1:5]))
            elif command[0] == "f":
                result = command.split(",", 3)

                if len(result) == 3:
                    self.robot.face(float(result[1]), float(result[2]))
            elif command[0] == "v":
                global verbose
                verbose = not verbose
            elif command[0] == "h":
                print("x: " + str(self.robot.x) + " y: " + str(self.robot.y) +
                      " heading: " + str(self.robot.heading))
            elif command[0] == "t":
                result = command.split(",", 3)

                if len(result) == 3:
                    self.robot.go_to(float(result[1]), float(result[2]))
            elif command[0] == "g":
                self.map.print_map()
            elif command[0] == "c":
                result = command.split(",", 4)

                if len(result) == 4:
                    self.robot.change_odometry(float(result[1]),
                                               float(result[2]),
                                               float(result[3]))
            else:
                print("Unknown command: " + command)

    def handle_event(self, event):
        if isinstance(event, OdometryReport):
            didChange = self.robot.update_odometry(event)
        elif isinstance(event, StateEvent):
            self.robot.state = event.state
        elif isinstance(event, StateEvent):
            self.robot.state = event.state

        if verbose:
            print(event)
예제 #24
0
class SelectionCanvas(Canvas):
    def __init__(self, loc, **args):
        Canvas.__init__(self, loc, args)

        self.minX = None
        self.minY = None
        self.maxX = None
        self.maxY = None
        self.box = None
        self.clickNum = 0

        self.currentImage = None
        self.canvasImage = None
        self.map = Map(Map.MAPS[2])

        self.bind('<Button-1>', self.click)

    def click(self, event):
        if self.clickNum == 0:
            self.minX = event.x
            self.minY = event.y
            self.maxX = event.x
            self.maxY = event.y
            self.clickNum += 1
            print("FIrst Click")
            self.create_rectangle(self.minX,
                                  self.minY,
                                  self.minX,
                                  self.minY,
                                  fill='',
                                  outline='red',
                                  tags='Box')

        elif self.clickNum == 1:
            print("Second Click")
            self.clickNum += 1
            self.maxX = event.x
            self.maxY = event.y
            self.delete('Box')
            self.create_rectangle(self.minX,
                                  self.minY,
                                  self.maxX,
                                  self.maxY,
                                  fill='',
                                  outline='red',
                                  tags='Box',
                                  width=3)
        else:
            print("Click 3")
            self.clickNum = 0
            self.delete('Box')
            self.minX = None

    def getBox(self):
        if self.minX != None:
            return self.map.convertBox(
                (self.minX, self.maxY, self.maxX, self.minY))
        return None

    def reloadImage(self):
        self.currentImage = self.map.getImageTk()
        if self.canvasImage == None:
            self.canvasImage = self.create_image(512,
                                                 512,
                                                 image=self.currentImage)
        else:
            self.itemconfig(self.canvasImage, image=self.currentImage)

    def clearMap(self):
        self.delete('Box')
        self.minX = None
        self.map.clear()

    def addData(self, data):
        self.map.addData(data)

    def setMap(self, newMap):
        self.map = newMap
예제 #25
0
 def __init__(self, setup):
     self.__setup = setup
     self.__status = STATUS.STOPPED
     self.__map = Map(setup.height, setup.width)
     self.__logs = []
예제 #26
0
 def __get_kings_cells(self):
     for color in PieceColor:
         sought_piece = Piece(PieceType.KING, color)
         yield Map.find(self.__current_map, sought_piece)
예제 #27
0
파일: game.py 프로젝트: DenprogIS/Chess
class Game:
    def __init__(self):
        self.__map = Map(is_auto_init=True)
        self.__color_current_move = PieceColor.WHITE
        self.__checked_king = CheckedKingGetter(self.map).get_checked_king()
        self.__game_is_finished = False
        self.__map_cvs = MapCVS()
        self.__map_cvs.add_map(self.map)

    def try_make_move(self, move_vector):
        piece = self.__map.get(move_vector.start_cell)
        if piece is None:
            return False

        self.__checked_king = None

        move_validator = MoveValidator(self.map, self.__map_cvs.previous_map(),
                                       move_vector, self.__color_current_move)

        move_validator.on_remove_piece_handler = self.on_remove_piece_handler

        if move_validator.is_valid():
            self.__checked_king = self.identify_checked_king(
                self.map, move_vector)
            if not self.self_color_king_checked_after_move():
                self.invert_color_current_move()
                self.__map.drag(move_vector)
                self.__map_cvs.add_map(self.map)
                return True

        # self.detect_end_game()

        return False

    @property
    def map(self):
        return copy(self.__map)

    @property
    def king_is_checked(self):
        return self.__checked_king is not None

    @property
    def is_finished(self):
        return self.__game_is_finished

    @property
    def undo_map_available(self):
        return self.__map_cvs.undo_map_available

    @property
    def redo_map_available(self):
        return self.__map_cvs.redo_map_available

    def on_remove_piece_handler(self, piece_cell):
        self.__map.remove(piece_cell)

    def invert_color_current_move(self):
        self.__color_current_move = PieceColor.invert(
            self.__color_current_move)

    def identify_checked_king(self, map, move_vector):
        map.drag(move_vector)
        return CheckedKingGetter(map).get_checked_king()

    def self_color_king_checked_after_move(self):
        if self.__checked_king is None:
            return False

        return self.__checked_king.color == self.__color_current_move

    def undo_map(self):
        self.invert_color_current_move()
        self.__map = self.__map_cvs.undo_map()

    def redo_map(self):
        self.invert_color_current_move()
        self.__map = self.__map_cvs.redo_map()
예제 #28
0
    parser.add_argument("-p",
                        '--palette',
                        type=str,
                        default='palette.json',
                        help='Palette config file')
    parser.add_argument('--encoding',
                        type=str,
                        default='utf8',
                        help='Encoding for files')
    parser.add_argument('-e',
                        '--editor',
                        action='store_true',
                        help='Run map editor')
    return parser.parse_args()


if __name__ == '__main__':
    parser = create_parser()
    app = QtWidgets.QApplication(sys.argv)
    if parser.editor:
        editor = EditorWindow()
    else:
        try:
            loaded_map = Map.from_file(parser.map, parser.encoding)
        except IOError as e:
            print("error loading {} file\n{}".format(parser.map, e))
            exit(1)
        viz = Visualizer(loaded_map, Palette.from_json(parser.palette))

    sys.exit(app.exec_())
예제 #29
0
from model.hero import *
from model.map import Map
from model.parameters import Parameters
from model.state import State
from model.abilites import AbilityType
from model.teams import Teams
from warrior import *
import json
import random
import time

game = json.loads(input())
game_map = Map(game)  # карта игрового мира
game_params = Parameters(game)  # параметры игры
game_teams = Teams(game)  # моя команда


def main():
    # state = State(input(), game_teams, game_params)
    # if game_teams.enemy_team[0].hero_type == HeroType.Warrior:
    warrior(game_map, game_params, game_teams)


main()
예제 #30
0
class Main(threading.Thread):
	def __init__(self):
		# Bluetooth.
		connection = BluetoothConnection("00:00:12:06:56:83", 0x1001)

		# IP
		#connection = IPConnection("10.42.0.1", 50001)
		
		# USB Serial.
		#connection = SerialConnection("/dev/ttyACM1", 115200)

		self.proxy = Proxy(connection)
		self.proxy.listeners.append(self)
		
		self.robot = Robot(self.proxy)
		self.robot.x = 1.15
		self.robot.y = 1.15

		self.map = Map(self.robot, 2.3, 0.23)

		self.path_planner = GridNav(self.map)

		Thread.__init__(self)

	def run(self):

		while True:

			command = input()

			if len(command) < 1:
				continue

			if command[0] == "w":
				self.robot.go_forward()
			elif command[0] == "s":
				self.robot.go_backward()
			elif command[0] == "a":
				self.robot.rotate_left()
			elif command[0] == "d":
				self.robot.rotate_right()
			elif command[0] == "q":
				self.robot.halt()
			elif command[0] == "e":
				if command == "end":
					break;

				self.robot.scan()
			elif command[0] == "p":
				self.robot.ping()
			elif command[0] == "z":
				self.robot.reset()
			elif command[0] == "r":
				if len(command) < 5:
					print("Invalid heading format rX.XX: " + command)
					continue

				self.robot.rotate_to(float(command[1:5]))
			elif command[0] == "f":
				result = command.split(",", 3)

				if len(result) == 3:
					self.robot.face(float(result[1]), float(result[2]))
			elif command[0] == "v":
				global verbose
				verbose = not verbose
			elif command[0] == "h":
				print("x: " + str(self.robot.x) + " y: " + str(self.robot.y) + " heading: " + str(self.robot.heading))
			elif command[0] == "t":
				result = command.split(",", 3)

				if len(result) == 3:
					self.robot.go_to(float(result[1]), float(result[2]))
			elif command[0] == "g":
					self.map.print_map()
			elif command[0] == "c":
				result = command.split(",", 4)

				if len(result) == 4:
					self.robot.change_odometry(float(result[1]), 
					float(result[2]), 
					float(result[3]))
			else:
				print("Unknown command: " + command)
				
	def handle_event(self, event):
		if isinstance(event, OdometryReport):
			didChange = self.robot.update_odometry(event)                 
		elif isinstance(event, StateEvent):
			self.robot.state = event.state
		elif isinstance(event, StateEvent):
			self.robot.state = event.state
		
		if verbose:	
			print(event)
예제 #31
0
def init_game(token):
    print token, "client", type(token)
    game[token] = Map()
    emit('result', {'token': token, 'data': game[token].to_json()})