Skip to content
Snippets Groups Projects
Select Git revision
  • a2f7042a218691c4a23caf9f25b36cd5637a2b8c
  • master default protected
  • optimize-images
  • 5.0
  • 4.1
5 results

CustomClass.php

Blame
  • Forked from Digital Experience Group / UNL_Search
    Source project has a limited visibility.
    main.py 969 B
    from kivy.app import App
    from kivy.properties import BooleanProperty, ListProperty
    
    from functools import reduce
    from operator import xor
    
    __app_package__ = 'edu.unl.cse.soft161.nim'
    __app__ = 'Nim'
    __version__ = '0.1'
    __flags__ = ['--bootstrap=sdl2', '--requirements=python2,kivy', '--orientation=landscape']
    
    
    class NimApp(App):
        heaps = ListProperty([3, 5, 7])
        take_enabled = ListProperty([True, True, True])
        next_enabled = BooleanProperty(True)
    
        def make_computer_move(self):
            nimber = reduce(xor, self.heaps, 0)
            for index, heap in enumerate(self.heaps):
                if nimber ^ heap < heap:
                    self.heaps[index] = nimber ^ heap
                    break
            else:
                self.heaps[self.heaps.index(max(self.heaps))] -= 1
    
        def reset(self):
            self.heaps = [3, 5, 7]
        
        def take(self, index):
            pass
    
        def next(self):
            pass
    
    
    if __name__ == '__main__':
        nim = NimApp()
        nim.run()