From a86a6ca92d315dedf3ce4d5035a4c38178f8b531 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 13 Oct 2015 13:00:05 +0200 Subject: Remove backup files and add *~ to .gitignore --- robot/problems/introduction/circle20/common.py~ | 63 ------------ robot/problems/introduction/circle20/sl.py~ | 24 ----- robot/problems/introduction/countlines/common.py~ | 79 --------------- robot/problems/introduction/countlines/sl.py~ | 29 ------ robot/problems/introduction/followline/common.py~ | 85 ---------------- robot/problems/introduction/followline/sl.py~ | 35 ------- robot/problems/introduction/forward/common.py~ | 60 ----------- robot/problems/introduction/forward/en.py~ | 20 ---- robot/problems/introduction/forward/sl.py~ | 23 ----- robot/problems/introduction/forward1m/common.py~ | 61 ----------- robot/problems/introduction/forward1m/sl.py~ | 24 ----- robot/problems/introduction/gyro90/common.py~ | 80 --------------- .../introduction/gyro90/naloga07_gyro90.py~ | 34 ------- robot/problems/introduction/gyro90/sl.py~ | 32 ------ robot/problems/introduction/gyrosquare/common.py~ | 103 ------------------- robot/problems/introduction/gyrosquare/sl.py~ | 40 -------- robot/problems/introduction/printcolors/common.py~ | 80 --------------- robot/problems/introduction/printcolors/sl.py~ | 37 ------- robot/problems/introduction/rotateback/common.py~ | 111 --------------------- robot/problems/introduction/rotateback/sl.py~ | 36 ------- robot/problems/introduction/spotturn90/common.py~ | 61 ----------- robot/problems/introduction/spotturn90/sl.py~ | 24 ----- robot/problems/introduction/square20/common.py~ | 76 -------------- robot/problems/introduction/square20/sl.py~ | 27 ----- robot/problems/introduction/wall1m/common.py~ | 80 --------------- .../introduction/wall1m/naloga06_wall1m.py~ | 31 ------ robot/problems/introduction/wall1m/sl.py~ | 31 ------ 27 files changed, 1386 deletions(-) delete mode 100644 robot/problems/introduction/circle20/common.py~ delete mode 100644 robot/problems/introduction/circle20/sl.py~ delete mode 100644 robot/problems/introduction/countlines/common.py~ delete mode 100644 robot/problems/introduction/countlines/sl.py~ delete mode 100644 robot/problems/introduction/followline/common.py~ delete mode 100644 robot/problems/introduction/followline/sl.py~ delete mode 100644 robot/problems/introduction/forward/common.py~ delete mode 100644 robot/problems/introduction/forward/en.py~ delete mode 100644 robot/problems/introduction/forward/sl.py~ delete mode 100644 robot/problems/introduction/forward1m/common.py~ delete mode 100644 robot/problems/introduction/forward1m/sl.py~ delete mode 100644 robot/problems/introduction/gyro90/common.py~ delete mode 100644 robot/problems/introduction/gyro90/naloga07_gyro90.py~ delete mode 100644 robot/problems/introduction/gyro90/sl.py~ delete mode 100644 robot/problems/introduction/gyrosquare/common.py~ delete mode 100644 robot/problems/introduction/gyrosquare/sl.py~ delete mode 100644 robot/problems/introduction/printcolors/common.py~ delete mode 100644 robot/problems/introduction/printcolors/sl.py~ delete mode 100644 robot/problems/introduction/rotateback/common.py~ delete mode 100644 robot/problems/introduction/rotateback/sl.py~ delete mode 100644 robot/problems/introduction/spotturn90/common.py~ delete mode 100644 robot/problems/introduction/spotturn90/sl.py~ delete mode 100644 robot/problems/introduction/square20/common.py~ delete mode 100644 robot/problems/introduction/square20/sl.py~ delete mode 100644 robot/problems/introduction/wall1m/common.py~ delete mode 100644 robot/problems/introduction/wall1m/naloga06_wall1m.py~ delete mode 100644 robot/problems/introduction/wall1m/sl.py~ (limited to 'robot/problems') diff --git a/robot/problems/introduction/circle20/common.py~ b/robot/problems/introduction/circle20/common.py~ deleted file mode 100644 index eb171ae..0000000 --- a/robot/problems/introduction/circle20/common.py~ +++ /dev/null @@ -1,63 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 205 -group = 'introduction' -number = 5 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -fct = 9 # full circle time -rad = 20 # Direction to make a good radius for the circle -robot.move_steering( 'on_for_seconds', direction=rad, power=40, seconds=fct ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteering': Hint('moveSteering'), - 'onForSeconds': Hint('onForSeconds'), - 'direction': Hint('direction'), - 'seconds': Hint('seconds'), -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['move_steering']): - return [{'id': 'moveSteering'}] - - if not has_token_sequence(tokens, ['on_for_seconds']): - return [{'id': 'onForSeconds'}] - - if not has_token_sequence(tokens, ['direction']): - return [{'id': 'direction'}] - - if not has_token_sequence(tokens, ['seconds']): - return [{'id': 'seconds'}] - - return None diff --git a/robot/problems/introduction/circle20/sl.py~ b/robot/problems/introduction/circle20/sl.py~ deleted file mode 100644 index 656253d..0000000 --- a/robot/problems/introduction/circle20/sl.py~ +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 - -id = 205 -name = 'Krog 20 cm' -slug = 'Krog 20 cm' - -description = '''\ -

Napiši program, s katerim bo robot enkrat prevozil krog s polmerom 20 cm in se nato ustavil.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - 'moveSteering':['''

Sinhroniziraj motorja in ju zaženi za 3 sekunde.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( ... ).

'''], - 'onForSeconds':['''

Prvi argument metode robot.move_steering naj pove, da bo delovanje motorjev časovno omejeno.

''', - '''

robot.move_steering('on_for_seconds', ... ).

'''], - 'direction':['''

Navedi smer premikanja motorjev; pozitivne vrednosti pomenijo zavoj v desno.

''', - '''

Določi vrednost parametra direction tako, da bo robot krožil po krogu s polmerom 20cm. Vrednost je odvisna od konstrukcije robota in podlage.

''', - '''

robot.move_steering( 'on_for_seconds', direction=20, ... ).

'''], - 'seconds':['''

Napiši časovno omejitev v sekundah.

''', - '''

Za dani polmer izmeri čas, ki ga robot potrebuje za en obhod.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], -} diff --git a/robot/problems/introduction/countlines/common.py~ b/robot/problems/introduction/countlines/common.py~ deleted file mode 100644 index 6e5d135..0000000 --- a/robot/problems/introduction/countlines/common.py~ +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 206 -group = 'introduction' -number = 10 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown'] - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'color' ) - -robot.move_steering( 'on' ) -start = time.time() -stevec = 0 -color = -1 -while time.time()-start < 2.1: - c = robot.color_sensor_measure( 'color' ) # values: 0-7 see the scale above - if c!=color: - if c!=6 and c!=0: - stevec += 1 - color = c -robot.move_steering( 'off' ) -print( "Stevilo crt:", stevec ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteeringOn': Hint('moveSteeringOn'), - 'moveSteeringOff': Hint('moveSteeringOff'), - 'connectColorSensor': Hint('connectColorSensor'), - 'colorSensorMeasure': Hint('colorSensorMeasure'), - 'while': Hint('while') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not (has_token_sequence(tokens, ['connect_sensor', '(' ]) and 'color' in code): - return [{'id': 'connectColorSensor'}] - - if not has_token_sequence(tokens, ['move_steering', '(', 'on', ')']): - return [{'id': 'moveSteeringOn'}] - - if not has_token_sequence(tokens, ['move_steering', '(', 'off', ')']): - return [{'id': 'moveSteeringOff'}] - - if not (has_token_sequence(tokens, ['color_sensor_measure', '(']) and 'color' in code): - return [{'id': 'colorSensorMeasure'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - return None diff --git a/robot/problems/introduction/countlines/sl.py~ b/robot/problems/introduction/countlines/sl.py~ deleted file mode 100644 index 6b759ad..0000000 --- a/robot/problems/introduction/countlines/sl.py~ +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 206 -name = 'Preštej črte' -slug = 'Preštej črte' - -description = '''\ -

Robot naj pelje naravnost, pravokotno na črte in naj jih prešteje.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu priključi levi motor

''', - '''

robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu priključi desni motor

''', - '''

robot.connect_motor( 'right' ).

'''], - 'moveSteeringOn':['''

Sinhroniziraj motorja in ju zaženi.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( 'on' ).

'''], - 'moveSteeringOff':['''

Ustavi motorja.

''', - '''

robot.move_steering( 'off' ).

'''], - 'connectColorSensor':['''

Robotu moramo priključiti barvni senzor.

''', - '''

robot.connect_sensor( 'color' ).

'''], - 'colorSensorMeasure':['''

Medtem ko se robot pomika naprej, naj uporabi barvni senzor v načinu 'color', s katerim pove, katero barvo trenutno vidi.

''', - '''

robot.color_sensor_measure( 'color' ).

'''], - 'while':['''

Uporabi zanko, znotraj katere robot odčitava barve in povečuje števec.

''', - '''

Zanka je lahko časovno omejena, npr. z uporabo metode time.time().

''', - '''

while time.time()-start < 1.1:.

'''], -} diff --git a/robot/problems/introduction/followline/common.py~ b/robot/problems/introduction/followline/common.py~ deleted file mode 100644 index 5a3db5b..0000000 --- a/robot/problems/introduction/followline/common.py~ +++ /dev/null @@ -1,85 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 207 -group = 'introduction' -number = 12 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'color' ) - -start = time.time() -while time.time()-start < 10: - if robot.color_sensor_measure('reflected_light_intensity') < 30: - L, R = 0, 20 - else: - L, R = 20, 0 - robot.move_tank( 'on', lr_power=[L,R]) -robot.move_tank( 'off' ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveTankOn': Hint('moveTankOn'), - 'lrPower': Hint('lr_power'), - 'moveTankOff': Hint('moveTankOff'), - 'connectColorSensor': Hint('connectColorSensor'), - 'colorSensorMeasureRLI': Hint('colorSensorMeasureRLI'), - 'while': Hint('while'), - 'time': Hint('time'), - 'if': Hint('if') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['connect_sensor', '(', 'color', ')' ]): - return [{'id': 'connectColorSensor'}] - - if not has_token_sequence(tokens, ['move_tank', '(', 'on', ')']): - return [{'id': 'moveTankOn'}] - - if not has_token_sequence(tokens, ['lr_power']): - return [{'id': 'lrPower'}] - - if not has_token_sequence(tokens, ['move_tank', '(', 'off', ')']): - return [{'id': 'moveTankOff'}] - - if not has_token_sequence(tokens, ['color_sensor_measure', '(', 'reflected_light_intensity', ')']): - return [{'id': 'colorSensorMeasureRLI'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - if not has_token_sequence(tokens, ['time']): - return [{'id': 'time'}] - - if not has_token_sequence(tokens, ['if']): - return [{'id': 'if'}] - - return None diff --git a/robot/problems/introduction/followline/sl.py~ b/robot/problems/introduction/followline/sl.py~ deleted file mode 100644 index 5d201fe..0000000 --- a/robot/problems/introduction/followline/sl.py~ +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 207 -name = 'Sledenje črti' -slug = 'Sledenje črti' - -description = '''\ -

Robot naj 10 sekund sledi črni črti na beli podlagi; pri tem naj si pomaga z barvnim senzorjem.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - - 'moveTankOn':['''

Uporabi metodo za ločen nadzor motorjev, s katero vsakemu od motorjev nastavljaš drugačno moč.

''', - '''

Za to je najbolj primerna metoda robot.move_tank( ... ).

''', - '''

robot.move_tank( 'on', ...)

'''], - 'lrPower': ['''

Nastavi parameter s katerim nastaviš moči levega in desnega motorja.

''', - '''

robot.move_tank( 'on', lr_power=[ ... ])

'''], - 'moveTankOff': ['''Ustavi robota.''', - '''

robot.move_tank( 'off' )

'''], - 'connectColorSensor':['''

Robotu moramo priključiti barvni senzor.

''', - '''

robot.connect_sensor( 'color' ).

'''], - 'colorSensorMeasureRLI':['''

Medtem ko se robot pomika naprej, naj uporabi barvni senzor v načinu 'reflected_light_intensity', za zaznavanje jakosti odbite svetlobe.

''', - '''

robot.color_sensor_measure( 'reflected_light_intensity' ).

'''], - 'while':['''

Uporabi zanko, znotraj katere robot sledi črti.

''', - '''

Zanka naj bo časovno omejena, npr. z uporabo metode time.time().

''', - '''

start = time.time()\nwhile time.time()-start < 10:.

'''], - 'time': ['''Uporabi metodo time() za merjenje časa.''', - '''

start = time.time()\nwhile time.time()-start < 10:

'''], - 'if': ['''

V zanki uporabi pogojni stavek...

''', - '''

Če robot vidi črto, naj zavije z nje; če vidi podlago, naj zavije proti črti.

'''] -} \ No newline at end of file diff --git a/robot/problems/introduction/forward/common.py~ b/robot/problems/introduction/forward/common.py~ deleted file mode 100644 index f6330fd..0000000 --- a/robot/problems/introduction/forward/common.py~ +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 202 -number = 1 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteering': Hint('moveSteering'), - 'onForSeconds': Hint('onForSeconds'), - 'direction': Hint('direction'), - 'seconds': Hint('seconds'), -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['move_steering']): - return [{'id': 'moveSteering'}] - - if not has_token_sequence(tokens, ['on_for_seconds']): - return [{'id': 'onForSeconds'}] - - if not has_token_sequence(tokens, ['direction']): - return [{'id': 'direction'}] - - if not has_token_sequence(tokens, ['seconds']): - return [{'id': 'seconds'}] - - return None diff --git a/robot/problems/introduction/forward/en.py~ b/robot/problems/introduction/forward/en.py~ deleted file mode 100644 index 4337ac5..0000000 --- a/robot/problems/introduction/forward/en.py~ +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'en') - -<<<<<<< HEAD -id = 202 -name = 'Forward 3s' -slug = 'Forward 3s' -======= -name = 'Forward' -slug = 'Forward' ->>>>>>> 5a01c2bb184152c6ccc3c536e9b857d247bc55ad - -description = '''\ -

Write a program that would make the robot drive straight forward for 3 seconds and stop

-''' - -hint = { - -} diff --git a/robot/problems/introduction/forward/sl.py~ b/robot/problems/introduction/forward/sl.py~ deleted file mode 100644 index a6f7e86..0000000 --- a/robot/problems/introduction/forward/sl.py~ +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 - -name = 'Naprej 3s' -slug = 'Naprej 3s' - -description = '''\ -

Napiši program, da bo robot peljal naravnost naprej 3 sekunde in se nato ustavil.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu priključi levi motor

''', - '''

robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu priključi desni motor

''', - '''

robot.connect_motor( 'right' ).

'''], - 'moveSteering':['''

Sinhroniziraj motorja in ju zaženi za 3 sekunde.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( ... ).

'''], - 'onForSeconds':['''

Prvi argument metode robot.move_steering naj pove, da bo delovanje motorjev časovno omejeno.

''', - '''

robot.move_steering('on_for_seconds', ... ).

'''], - 'direction':['''

Navedi smer premikanja motorjev, naravnost = 0.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, ... ).

'''], - 'seconds':['''

Napiši časovno omejitev v sekundah.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], -} diff --git a/robot/problems/introduction/forward1m/common.py~ b/robot/problems/introduction/forward1m/common.py~ deleted file mode 100644 index 809fe9d..0000000 --- a/robot/problems/introduction/forward1m/common.py~ +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 208 -group = 'introduction' -number = 2 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -robot.move_steering( 'on_for_rotations', direction=0, rotations=5.71 ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteering': Hint('moveSteering'), - 'onForRotations': Hint('onForRotations'), - 'direction': Hint('direction'), - 'rotations': Hint('rotations'), -} - -def hint(code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['move_steering']): - return [{'id': 'moveSteering'}] - - if not has_token_sequence(tokens, ['on_for_rotations']): - return [{'id': 'onForRotations'}] - - if not has_token_sequence(tokens, ['direction']): - return [{'id': 'direction'}] - - if not has_token_sequence(tokens, ['rotations']): - return [{'id': 'rotations'}] - - return None diff --git a/robot/problems/introduction/forward1m/sl.py~ b/robot/problems/introduction/forward1m/sl.py~ deleted file mode 100644 index e8071ee..0000000 --- a/robot/problems/introduction/forward1m/sl.py~ +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 208 -name = 'Naprej 1m' -slug = 'Naprej 1m' - -description = '''\ -

Napiši program, da bo robot peljal naravnost naprej 3 sekunde in se nato ustavil.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - 'moveSteering':['''

Sinhroniziraj motorja in ju zaženi za 3 sekunde.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( ... ).

'''], - 'onForRotations':['''

Prvi argument metode robot.move_steering naj pove, da bo delovanje motorjev določeno s številom obratov.

''', - '''

robot.move_steering('on_for_rotations', ... ).

'''], - 'direction':['''

Navedi smer premikanja motorjev, naravnost = 0.

''', - '''

robot.move_steering( 'on_for_rotations', direction=0, ... ).

'''], - 'rotations':['''

Določi število obratov; za koliko obratov naj se zavrtita motorja? Izmeri dolžino 1m, izpisuj obrate print(robot.motor['left'].count_per_rot, robot.motor['right'].count_per_rot) in tako določi ustrezno število obratov.

''', - '''

robot.move_steering( 'on_for_rotations', direction=0, rotations=5 ).

'''], -} diff --git a/robot/problems/introduction/gyro90/common.py~ b/robot/problems/introduction/gyro90/common.py~ deleted file mode 100644 index c02a2c4..0000000 --- a/robot/problems/introduction/gyro90/common.py~ +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 209 -group = 'introduction' -number = 7 -visible = True - -solution = '''\ -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'gyro' ) - -robot.gyro_set_mode( 'angle' ) -robot.reset_gyro() - -power = 15 -robot.move_tank( 'on', lr_power=[power,-power] ) -while robot.gyro_sensor_measure() < 90: - pass -robot.move_tank( 'off' ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'connectGyro': Hint('connectGyro'), - 'resetGyro': Hint('resetGyro'), - 'setGyroMode': Hint('setGyroMode'), - 'gyroMeasure': Hint('gyroMeasure'), - 'moveTank': Hint('moveTank'), - 'lrPower': Hint('lrPower'), - 'while': Hint('while') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['connect_gyro','(', 'gyro', ')']): - return [{'id': 'connectGyro'}] - - if not has_token_sequence(tokens, ['reset_gyro()']): - return [{'id': 'resetGyro'}] - - if not has_token_sequence(tokens, ['gyro_set_mode']): - return [{'id': 'setGyroMode'}] - - if not has_token_sequence(tokens, ['gyro_sensor_measure()']): - return [{'id': 'gyroMeasure'}] - - if not has_token_sequence(tokens, ['move_tank']): - return [{'id': 'moveTank'}] - - if not has_token_sequence(tokens, ['lr_power']): - return [{'id': 'lrPower'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - return None diff --git a/robot/problems/introduction/gyro90/naloga07_gyro90.py~ b/robot/problems/introduction/gyro90/naloga07_gyro90.py~ deleted file mode 100644 index 97e42ee..0000000 --- a/robot/problems/introduction/gyro90/naloga07_gyro90.py~ +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python -# coding=utf-8 - -print """ -Naloga 7: - Robot naj se na mestu obrne za 90 stopinj v desno; pri tem naj si pomaga z ziroskopom. -""" - -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -gs = gyro_sensor(); -assert gs.connected -gs.mode = 'GYRO-ANG' # Angle (degrees), value: (-32768 to 32767) - -# for m in us.modes: -# print "\t",m -#exit() -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -power = 15 -robot.move_tank( 'on', lr_power=[power,-power] ) -while gs.value()<90: - pass -robot.move_tank( 'off', brake_at_end=True ) -# print gs.value() -# gs = gyro_sensor(); -# assert gs.connected -# gs.mode = 'GYRO-ANG' -# -# print "--->",gs.value() \ No newline at end of file diff --git a/robot/problems/introduction/gyro90/sl.py~ b/robot/problems/introduction/gyro90/sl.py~ deleted file mode 100644 index 76939f7..0000000 --- a/robot/problems/introduction/gyro90/sl.py~ +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 209 -name = 'Žiroskop 90' -slug = 'Žiroskop 90' - -description = '''\ -

Robot naj se na mestu obrne za 90 stopinj v desno; pri tem naj si pomaga z žiroskopom.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu priključi levi motor.

''', - '''

robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu priključi desni motor.

''', - '''

robot.connect_motor( 'right' ).

'''], - 'connectGyro':['''

Robotu priključi žiroskop.

''', - '''

robot.connect_sensor( 'gyro' ).

'''], - 'resetGyro':['''

Žiroskop na začetku resetiraj.

''', - '''

robot.reset_gyro().

'''], - 'setGyroMode':['''

Žiroskopu nastavi način delovanja na merjenje kotov.

''', - '''

robot.gyro_set_mode('angle').

'''], - 'gyroMeasure':['''

Preberi vrednost žiroskopa.

''', - '''

robot.gyro_sensor_measure().

'''], - 'lrPower':['''

Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.

''', - '''

robot.move_tank( 'on', lr_power=[hitrost, -hitrost], ... ).

'''], - 'moveTank':['''

Robot naj se obrne na mestu.

''', - '''

Najprimernejša metoda za to je move_tank

'''], - 'while':['''

Program naj teče dokler je kot zasuka manjši od 90 stopinj.

''', - '''

robot.gyro_sensor_measure() < 90:

'''], -} \ No newline at end of file diff --git a/robot/problems/introduction/gyrosquare/common.py~ b/robot/problems/introduction/gyrosquare/common.py~ deleted file mode 100644 index 1c31f92..0000000 --- a/robot/problems/introduction/gyrosquare/common.py~ +++ /dev/null @@ -1,103 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 210 -group = 'introduction' -number = 8 -visible = True - -solution = '''\ -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'gyro' ) - -robot.gyro_set_mode( 'angle' ) -robot.reset_gyro() - -power = 20 -def forward_and_turnRight(power, angle): - robot.move_steering( 'on_for_seconds', direction=0, power=power, seconds=2 ) - robot.move_tank( 'on', lr_power=[power,-power] ) - while robot.gyro_sensor_measure( 'angle' ) < angle: - pass - robot.move_tank( 'off' ) - -forward_and_turnRight(power, 89) -forward_and_turnRight(power, 179) -forward_and_turnRight(power, 269) -forward_and_turnRight(power, 359) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteering': Hint('moveSteering'), - 'onForSeconds': Hint('onForSeconds'), - 'direction': Hint('direction'), - 'seconds': Hint('seconds'), - 'connectGyro': Hint('connectGyro'), - 'resetGyro': Hint('resetGyro'), - 'setGyroMode': Hint('setGyroMode'), - 'gyroMeasure': Hint('gyroMeasure'), - 'moveTank': Hint('moveTank'), - 'lrPower': Hint('lrPower'), - 'while': Hint('while') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['connect_gyro','(', 'gyro', ')']): - return [{'id': 'connectGyro'}] - - if not has_token_sequence(tokens, ['reset_gyro()']): - return [{'id': 'resetGyro'}] - - if not has_token_sequence(tokens, ['gyro_set_mode']): - return [{'id': 'setGyroMode'}] - - if not has_token_sequence(tokens, ['gyro_sensor_measure()']): - return [{'id': 'gyroMeasure'}] - - if not has_token_sequence(tokens, ['move_tank']): - return [{'id': 'moveTank'}] - - if not has_token_sequence(tokens, ['move_steering']): - return [{'id': 'moveSteering'}] - - if not 'on_for_seconds' in code: - return [{'id': 'onForSeconds'}] - - if not 'direction' in code: - return [{'id': 'direction'}] - - if not 'seconds' in code: - return [{'id': 'seconds'}] - - if not 'lr_power' in code: - return [{'id': 'lrPower'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - return None diff --git a/robot/problems/introduction/gyrosquare/sl.py~ b/robot/problems/introduction/gyrosquare/sl.py~ deleted file mode 100644 index 00171e8..0000000 --- a/robot/problems/introduction/gyrosquare/sl.py~ +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 210 -name = 'Kvadrat z žiroskopom' -slug = 'Kvadrat z žiroskopom' - -description = '''\ -

Robot naj prevozi kvadrat s stranico 20 cm; pri tem naj si pomaga z žiroskopom.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - - 'connectGyro':['''

Robotu priključi žiroskop.

''', - '''

robot.connect_sensor( 'gyro' ).

'''], - 'resetGyro':['''

Žiroskop na začetku resetiraj.

''', - '''

robot.reset_gyro().

'''], - 'setGyroMode':['''

Žiroskopu nastavi način delovanja na merjenje kotov.

''', - '''

robot.gyro_set_mode('angle').

'''], - 'gyroMeasure':['''

Preberi vrednost žiroskopa.

''', - '''

robot.gyro_sensor_measure().

'''], - 'lrPower':['''

Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.

''', - '''

robot.move_tank( 'on', lr_power=[hitrost, -hitrost], ... ).

'''], - 'moveTank':['''

Robot naj se obrne na mestu.

''', - '''

Najprimernejša metoda za to je move_tank

'''], - 'while':['''

Program naj čaka dokler je kot zasuka manjši od 90 stopinj.

''', - '''

robot.gyro_sensor_measure() < 90:

'''], - - 'moveSteering':['''

Sinhroniziraj motorja in ju zaženi.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( ... ).

'''], - 'onForSeconds':['''

Prvi argument metode robot.move_steering naj pove, da bo delovanje motorjev časovno omejeno.

''', - '''

robot.move_steering('on_for_seconds', ... ).

'''], - 'direction':['''

Navedi smer premikanja motorjev, naravnost = 0.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, ... ).

'''], - 'seconds':['''

Napiši časovno omejitev v sekundah.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], -} diff --git a/robot/problems/introduction/printcolors/common.py~ b/robot/problems/introduction/printcolors/common.py~ deleted file mode 100644 index 04ca0d6..0000000 --- a/robot/problems/introduction/printcolors/common.py~ +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 211 -group = 'introduction' -number = 9 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown'] - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'color' ) - -robot.move_steering( 'on') -start = time.time() -color = -1 -while time.time()-start < 2.1: - c = robot.color_sensor_measure('color') - if c!=color: - print( c, color_table[c]) - color = c -robot.move_steering( 'off' ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteeringOn': Hint('moveSteeringOn'), - 'moveSteeringOff': Hint('moveSteeringOff'), - 'connectColorSensor': Hint('connectColorSensor'), - 'colorSensorMeasure': Hint('colorSensorMeasure'), - 'while': Hint('while'), - 'print': Hint('print') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['connect_sensor', '(', 'color', ')' ]): - return [{'id': 'connectColorSensor'}] - - if not has_token_sequence(tokens, ['move_steering', '(', 'on', ')']): - return [{'id': 'moveSteeringOn'}] - - if not has_token_sequence(tokens, ['move_steering', '(', 'off', ')']): - return [{'id': 'moveSteeringOff'}] - - if not has_token_sequence(tokens, ['color_sensor_measure', '(', 'color', ')']): - return [{'id': 'colorSensorMeasure'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - if not has_token_sequence(tokens, ['print', '(']): - return [{'id': 'print'}] - - return None \ No newline at end of file diff --git a/robot/problems/introduction/printcolors/sl.py~ b/robot/problems/introduction/printcolors/sl.py~ deleted file mode 100644 index 9d5ec21..0000000 --- a/robot/problems/introduction/printcolors/sl.py~ +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 211 -name = 'Zaznavanje barv' -slug = 'Zaznavanje barv' - -description = '''\ -

Robot naj se pelje čez barvne črte in na zaslon izpiše barvo, ki jo zazna s svetlobnim senzorjem. - Value Color - 0 none - 1 black - 2 blue - 3 green - 4 yellow - 5 red - 6 white - 7 brown

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - 'moveSteeringOn':['''

Sinhroniziraj motorja in ju zaženi.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( 'on' ).

'''], - 'moveSteeringOff':['''

Ustavi motorja.

''', - '''

robot.move_steering( 'off' ).

'''], - 'connectColorSensor':['''

Robotu moramo priključiti barvni senzor.

''', - '''

robot.connect_sensor( 'color' ).

'''], - 'colorSensorMeasure':['''

Medtem ko se robot pomika naprej, naj uporabi barvni senzor v načinu 'color', s katerim pove, katero barvo trenutno vidi.

''', - '''

robot.color_sensor_measure( 'color' ).

'''], - 'while':['''

Uporabi zanko, znotraj katere robot odčitava barve in povečuje števec.

''', - '''

Zanka je lahko časovno omejena, npr. z uporabo metode time.time().

''', - '''

while time.time()-start < 1.1:.

'''], - 'print':['''

V zanki na zaslon izpisuj barvo, ki jo zazna robot.

'''] -} \ No newline at end of file diff --git a/robot/problems/introduction/rotateback/common.py~ b/robot/problems/introduction/rotateback/common.py~ deleted file mode 100644 index c7c199c..0000000 --- a/robot/problems/introduction/rotateback/common.py~ +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 212 -group = 'introduction' -number = 11 -visible = True - -solution = '''\ -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -def sgn(x): - return -1 if x<0 else (1 if x>0 else 0) - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'gyro' ) -robot.connect_sensor( 'touch' ) - -smer = hitrost = 0 -robot.reset_gyro() -robot.gyro_set_mode( 'angle' ) -prev_smer = -1 -while 1: - smer = robot.gyro_sensor_measure() - if smer!=prev_smer: - print ("Kot:", smer) - prev_smer = smer - - if robot.touch_sensor_measure(): - robot.reset_gyro() - print ( robot.gyro_sensor_measure() ) - - if abs(smer) < 10: - hitrost = 10*sgn(smer) - else: - if abs(smer) > 100: - hitrost = 100*sgn(smer) - else: - hitrost = smer - - if abs(smer) > 1: - L, R = -hitrost, hitrost - else: - L = R = 0 - robot.move_tank('on', lr_power=[L,R]) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'connectGyro': Hint('connectGyro'), - 'connectTouch': Hint('connectTouch'), - 'resetGyro': Hint('resetGyro'), - 'setGyroMode': Hint('setGyroMode'), - 'gyroMeasure': Hint('gyroMeasure'), - 'ifTouch': Hint('ifTouch'), - 'moveTank': Hint('moveTank'), - 'lrPower': Hint('lrPower'), - 'while': Hint('while') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['connect_gyro','(', 'gyro', ')']): - return [{'id': 'connectGyro'}] - - if not has_token_sequence(tokens, ['connect_sensor','(', 'touch', ')']): - return [{'id': 'connectTouch'}] - - if not has_token_sequence(tokens, ['reset_gyro()']): - return [{'id': 'resetGyro'}] - - if not has_token_sequence(tokens, ['gyro_set_mode']): - return [{'id': 'setGyroMode'}] - - if not has_token_sequence(tokens, ['gyro_sensor_measure()']): - return [{'id': 'gyroMeasure'}] - - if not has_token_sequence(tokens, ['if','touch_sensor_measure','(',')']): - return [{'id': 'ifTouch'}] - - if not has_token_sequence(tokens, ['move_tank']): - return [{'id': 'moveTank'}] - - if not has_token_sequence(tokens, ['lr_power']): - return [{'id': 'lrPower'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - return None diff --git a/robot/problems/introduction/rotateback/sl.py~ b/robot/problems/introduction/rotateback/sl.py~ deleted file mode 100644 index 0b91379..0000000 --- a/robot/problems/introduction/rotateback/sl.py~ +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 212 -name = 'Drži smer' -slug = 'Drži smer' - -description = '''\ -

Robot naj drži smer - če ga obrnemo iz začetne smeri, naj se zasuka nazaj v prvotno smer. Ob pritisku na stikalo, naj se resetira (smer nastavi na 0).

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu priključi levi motor

''', - '''

robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu priključi desni motor

''', - '''

robot.connect_motor( 'right' ).

'''], - 'connectGyro':['''

Robotu priključi žiroskop

''', - '''

robot.connect_sensor( 'gyro' ).

'''], - 'connectTouch':['''

Robotu priključi stikalo

''', - '''

robot.connect_sensor( 'touch' ).

'''], - 'resetGyro':['''

Žiroskop na začetku in ob pritisku na stikalo resetiraj.

''', - '''

robot.reset_gyro().

'''], - 'setGyroMode':['''

Žiroskopu nastavi način delovanja na merjenje kotov.

''', - '''

robot.gyro_set_mode('angle').

'''], - 'gyroMeasure':['''

Preberi vrednost žiroskopa.

''', - '''

robot.gyro_sensor_measure().

'''], - 'ifTouch':['''

Preveri, če je stikalo pritisnjeno.

''', - '''

if robot.touch_sensor_measure():.

'''], - 'lrPower':['''

Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.

''', - '''

robot.move_tank( 'on_for_seconds', lr_power=[hitrost, -hitrost], ... ).

'''], - 'moveTank':['''

Robot naj se obrne na mestu.

''', - '''

Najprimernejša metoda za to je move_tank

'''], - 'while':['''

Program naj teče v neskončni zanki.

''', - '''

while 1:

'''], -} diff --git a/robot/problems/introduction/spotturn90/common.py~ b/robot/problems/introduction/spotturn90/common.py~ deleted file mode 100644 index d024bd4..0000000 --- a/robot/problems/introduction/spotturn90/common.py~ +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 214 -group = 'introduction' -number = 3 -visible = True - -solution = '''\ -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=.9 ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveTank': Hint('moveTank'), - 'onForSeconds': Hint('onForSeconds'), - 'lrPower': Hint('lrPower'), - 'seconds': Hint('seconds'), -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['move_tank']): - return [{'id': 'moveTank'}] - - if not has_token_sequence(tokens, ['on_for_seconds']): - return [{'id': 'onForSeconds'}] - - if not has_token_sequence(tokens, ['lr_power']): - return [{'id': 'lrPower'}] - - if not has_token_sequence(tokens, ['seconds']): - return [{'id': 'seconds'}] - - return None diff --git a/robot/problems/introduction/spotturn90/sl.py~ b/robot/problems/introduction/spotturn90/sl.py~ deleted file mode 100644 index bc0978c..0000000 --- a/robot/problems/introduction/spotturn90/sl.py~ +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -import server -mod = server.problems.load_language('python', 'sl') - -id = 214 -name = 'Obrat na mestu 90' -slug = 'Obrat na mestu 90' - -description = '''\ -

Robot naj se na mestu obrne za 90 stopinj v desno.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - 'moveTank':['''

Robot naj se obrne na mestu.

''', - '''

Najprimernejša metoda za to je move_tank

'''], - 'onForSeconds':['''

Prvi argument metode robot.move_tank naj pove, da bo delovanje motorjev časovno omejeno.

''', - '''

robot.move_tank('on_for_seconds', ... ).

'''], - 'lrPower':['''

Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.

''', - '''

robot.move_tank( 'on_for_seconds', lr_power=[hitrost, -hitrost], ... ).

'''], - 'seconds':['''

Napiši časovno omejitev v sekundah.

''', - '''

robot.move_tank( 'on_for_seconds', ..., seconds=... ).

'''], -} \ No newline at end of file diff --git a/robot/problems/introduction/square20/common.py~ b/robot/problems/introduction/square20/common.py~ deleted file mode 100644 index f868a1c..0000000 --- a/robot/problems/introduction/square20/common.py~ +++ /dev/null @@ -1,76 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 213 -group = 'introduction' -number = 4 -visible = True - -solution = '''\ -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -turntime = .95 -robot.move_steering( 'on_for_seconds', direction=0, power=20, seconds=2 ) -robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=turntime ) -robot.move_steering( 'on_for_seconds', direction=0, power=20, seconds=2 ) -robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=turntime ) -robot.move_steering( 'on_for_seconds', direction=0, power=20, seconds=2 ) -robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=turntime ) -robot.move_steering( 'on_for_seconds', direction=0, power=20, seconds=2 ) -robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=turntime ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteering': Hint('moveSteering'), - 'onForSeconds': Hint('onForSeconds'), - 'direction': Hint('direction'), - 'seconds': Hint('seconds'), - 'moveTank': Hint('moveTank'), - 'lrPower': Hint('lrPower') -} - -def hint( code): - tokens = get_tokens(code) - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not has_token_sequence(tokens, ['move_steering']): - return [{'id': 'moveSteering'}] - - if not 'on_for_seconds' in code: - return [{'id': 'onForSeconds'}] - - if not 'direction' in code: - return [{'id': 'direction'}] - - if not 'seconds' in code: - return [{'id': 'seconds'}] - - if not has_token_sequence(tokens, ['move_tank']): - return [{'id': 'moveTank'}] - - if not 'lr_power' in code: - return [{'id': 'lrPower'}] - - return None diff --git a/robot/problems/introduction/square20/sl.py~ b/robot/problems/introduction/square20/sl.py~ deleted file mode 100644 index aa5137e..0000000 --- a/robot/problems/introduction/square20/sl.py~ +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 - -name = 'Kvadrat 20 cm' -slug = 'Kvadrat 20 cm' - -description = '''\ -

Robot naj enkrat prevozi kvadrat s stranico 20 cm.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu moramo priključiti levi motor: robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu moramo priključiti desni motor: robot.connect_motor( 'right' ).

'''], - 'moveSteering':['''

Sinhroniziraj motorja in ju zaženi.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( ... ).

'''], - 'onForSeconds':['''

Prvi argument metode robot.move_steering naj pove, da bo delovanje motorjev časovno omejeno.

''', - '''

robot.move_steering('on_for_seconds', ... ).

'''], - 'direction':['''

Navedi smer premikanja motorjev, naravnost = 0.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, ... ).

'''], - 'seconds':['''

Napiši časovno omejitev v sekundah.

''', - '''

robot.move_steering( 'on_for_seconds', direction=0, seconds=... ).

''', - '''

robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=.95 ).

''',], - 'moveTank': ['''

Robot naj se obrne na mestu.

''', - '''

Najprimernejša metoda za to je move_tank

''', - '''

robot.move_tank( 'on_for_seconds', ... ).

'''], - 'lrPower': ['''

Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.

''', - '''

robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=.95 ).

'''], -} diff --git a/robot/problems/introduction/wall1m/common.py~ b/robot/problems/introduction/wall1m/common.py~ deleted file mode 100644 index 319cea2..0000000 --- a/robot/problems/introduction/wall1m/common.py~ +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 - -from python.util import has_token_sequence, string_almost_equal, \ - string_contains_number, get_tokens, get_numbers, get_exception_desc -from server.hints import Hint, HintSequence - -id = 215 -group = 'introduction' -number = 6 -visible = True - -solution = '''\ -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) -robot.connect_sensor( 'ultrasonic' ) -robot.move_steering( 'on', power=80 ) -while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 500: - pass -robot.move_steering( 'on', power=20 ) -while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 200: - pass -robot.move_steering( 'off' ) -''' - -hint_type = { - 'mW_init': Hint('mW_init'), - 'connectMotorLeft': Hint('connectMotorLeft'), - 'connectMotorRight': Hint('connectMotorRight'), - 'moveSteeringOn': Hint('moveSteeringOn'), - 'moveSteeringOff': Hint('moveSteeringOff'), - 'connectUltrasonicSensor': Hint('connectUltrasonicSensor'), - 'ultrasonicSensorMeasure': Hint('ultrasonicSensorMeasure'), - 'power80': Hint('power80'), - 'power20': Hint('power20'), - 'while': Hint('while') -} - -def hint( code ): - tokens = get_tokens(code) - lines = code.split('\n') - - # if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program - if not has_token_sequence(tokens, ['mindstorms_widgets', '(',')']): - return [{'id': 'mW_init'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['left']): - return [{'id': 'connectMotorLeft'}] - - # if code does not include connect_motor statement, a student needs to learn about how to connect the motors - if not has_token_sequence(tokens, ['connect_motor']) and not has_token_sequence(tokens, ['right']): - return [{'id': 'connectMotorRight'}] - - if not (has_token_sequence(tokens, ['connect_sensor', '(']) and 'ultrasonic' in code) : - return [{'id': 'connectUltrasonicSensor'}] - - if not (has_token_sequence(tokens, ['move_steering', '(']) and 'on' in code): - return [{'id': 'moveSteeringOn'}] - - if not (has_token_sequence(tokens, ['move_steering', '(']) and 'off' in code): - return [{'id': 'moveSteeringOff'}] - - #if not (has_token_sequence(tokens, ['ultrasonic_sensor_measure', '(']) and 'distance-cm' in code): - if not any(('ultrasonic_sensor_measure' in s and '(' in s and 'distance-cm' in s) for s in lines) - return [{'id': 'ultrasonicSensorMeasure'}] - - if not any(('power' in s and '80' in s and '=' in s) for s in lines): - return [{'id': 'power80'}] - - if not any(('power' in s and '20' in s and '=' in s) for s in lines): - return [{'id': 'power20'}] - - if not has_token_sequence(tokens, ['while']): - return [{'id': 'while'}] - - return None diff --git a/robot/problems/introduction/wall1m/naloga06_wall1m.py~ b/robot/problems/introduction/wall1m/naloga06_wall1m.py~ deleted file mode 100644 index f7e6bad..0000000 --- a/robot/problems/introduction/wall1m/naloga06_wall1m.py~ +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python -# coding=utf-8 - -print """ -Naloga 6: - Robota postavi pred zid, tako da bo od njega oddaljen vsaj 1 m; vmes naj ne bo ovir. - Napisi program, s katerim bo robot vozil naravnost proti zidu z 80% mocjo. - Na razdalji 50 cm od zida naj robot zmanjsa hitrost na 20%, na razdalji 20 cm od zida pa naj se ustavi. -""" - -import time -from ev3dev import * -from mindstorms_widgets import mindstorms_widgets - -us = ultrasonic_sensor(); assert us.connected -us.mode = 'US-DIST-CM' # Continuous measurement of distance (0-2550 mm) - -# for m in us.modes: -# print "\t",m -#exit() -robot = mindstorms_widgets() -robot.connect_motor( 'left' ) -robot.connect_motor( 'right' ) - -robot.move_steering( 'on', power=80 ) -while us.value()>500: - pass -robot.move_steering( 'on', power=20 ) -while us.value()>200: - pass -robot.move_steering( 'off' ) diff --git a/robot/problems/introduction/wall1m/sl.py~ b/robot/problems/introduction/wall1m/sl.py~ deleted file mode 100644 index 8455bab..0000000 --- a/robot/problems/introduction/wall1m/sl.py~ +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 - -name = 'Pelji do zida' -slug = 'Pelji do zida' - -description = '''\ -

Robota postavi pred zid, tako da bo od njega oddaljen vsaj 1 m; vmes naj ne bo ovir. - Napisi program, s katerim bo robot vozil naravnost proti zidu z 80% mocjo. - Na razdalji 50 cm od zida naj robot zmanjsa hitrost na 20%, na razdalji 20 cm od zida pa naj se ustavi.

''' - -hint = { - 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], - 'connectMotorLeft':['''

Robotu priključi levi motor

''', - '''

robot.connect_motor( 'left' ).

'''], - 'connectMotorRight':['''

Robotu priključi desni motor

''', - '''

robot.connect_motor( 'right' ).

'''], - 'moveSteeringOn':['''

Sinhroniziraj motorja in ju zaženi.

''', - '''

Za sinhronizirano vožnjo je najbolj primerna metoda robot.move_steering( 'on' ).

'''], - 'moveSteeringOff':['''

Ustavi motorja.

''', - '''

robot.move_steering( 'off' ).

'''], - 'power80': ['''

Nastavi moč motorjev na 80%.

''', - '''

robot.move_steering( 'on', power=80 ).

'''], - 'power20': ['''

Nastavi moč motorjev na 20%.

''', - '''

robot.move_steering( 'on', power=20 ).

'''], - 'connectUltrasonicSensor':['''

Robotu moramo priključiti ultrazvočni senzor.

''', - '''

robot.connect_sensor( 'ultrasonic' ).

'''], - 'ultrasonicSensorMeasure':['''

Medtem ko se robot pomika naprej, naj uporabi ultrazvočni senzor v načinu 'distance-cm', s katerim meri razdaljo v cm.

''', - '''

robot.ultrasonic_sensor_measure( 'distance-cm' ).

'''], - 'while':['''

Uporabi zanko: robot naj se pelje naprej, dokler ne pride do razdalje 50 cm od zida.

''', - '''

Uporabi še eno zanko: robot naj se pelje naprej z 20% močjo, dokler ne pride do razdalje 20 cm od zida.

'''], -} -- cgit v1.2.1