diff options
Diffstat (limited to 'Kod/bilbana')
| -rw-r--r-- | Kod/bilbana/yc4/get_new_v.m | 18 | ||||
| -rw-r--r-- | Kod/bilbana/yc4/main.m | 14 |
2 files changed, 15 insertions, 17 deletions
diff --git a/Kod/bilbana/yc4/get_new_v.m b/Kod/bilbana/yc4/get_new_v.m index 273be4d..8c7d736 100644 --- a/Kod/bilbana/yc4/get_new_v.m +++ b/Kod/bilbana/yc4/get_new_v.m @@ -1,20 +1,20 @@ -function [ new_v ] = get_new_v( old_v, speed_constant, target_diff, car_position_diff, agressiveness ) +function [ new_v ] = get_new_v( position, list) %GET_NEW_V Hastigheten som bilen ska få nästa cykel. %{ Utgår ifrån position och ger motsvarande hårdkodade värde på v för nuvarande sub_segment. %} -position = old_v*100; %temp input för position -list = speed_constant; %temp input för listan Bana1 +position = position*100; %temp input för position + + + for i = 1:length(list) - if position > 1960 - new_v = list(length(list),4); - - elseif list(i,1) > position + if list(i,1) > position new_v = list((i-1),4); break end - -end + elseif i == 80 + new_v = list(80,4); +end end diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 6fd0172..01691ae 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -144,14 +144,12 @@ while 1 %% CHECK LAP AND CHECKPOINT (CAR 2) if car2.running == true - %% CALC POSITION (CAR 2) - if car2.lap ~= 0 - if car2.lap > 1 - last_seg_times2 = car2.seg_times(car2.lap - 1, 1:9); - aprox_v = get_aprox_v(car2.segment, last_seg_times2); - car2.position = get_position(aprox_v, car2.position, t); - end - end + %% CALC POSITION (CAR 2 + if car2.lap > 1 + last_seg_times2 = car2.seg_times(car2.lap - 1, 1:9); + aprox_v = get_aprox_v(car2.segment, last_seg_times2); + car2.position = get_position(aprox_v, car2.position, t); + end if car2.new_check_point == true % beep; if car2.lap ~= 0 |
