亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? robot.cpp

?? 機器人的行為控制模擬程序。用于機器人的環境識別。A robot action decision simulation used for robot enviroment recognition.
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/* 
    Robot Simulator

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    (C) 2006 Jason Hunt
    nulluser@gmail.gom 
*/


#include <math.h>
#include <windows.h>
#include <stdio.h>


#include "utility.h"
#include "console.h"
#include "graphics.h"
#include "automode.h"
#include "robot.h"
#include "world.h"
#include "main.h"
#include "map.h"

extern world_type world;
extern bool mode_manual;

double max_animal_speed = 0.25;  // The animals cal move no faster than this


robot_type robot;


/* Draw line in world cords */
void draw_line(HDC dc, line l)
{   
    MoveToEx(dc, get_screen_x(l.x1), get_screen_y(l.y1), NULL);
    LineTo(dc, get_screen_x(l.x2), get_screen_y(l.y2));    
}
/* End of draw line */



/* Draw a sensor for an animal */
void draw_sensor(HDC dc, double x, double y, double dir, double dist, double size, COLORREF c)
{
    double sx = x + dist * cos(dir);
    double sy = y + dist * sin(dir);
    
    RECT r;
    
    r.left = get_screen_x(sx - size / 2.0);
    r.top = get_screen_y(sy - size / 2.0);
    r.right = get_screen_x(sx + size / 2.0);
    r.bottom = get_screen_y(sy + size / 2.0);
    
    HBRUSH b = CreateSolidBrush(c);

    HBRUSH hold = (HBRUSH) SelectObject(dc, b);

    Ellipse(dc, r.left, r.top, r.right, r.bottom);    
    
    SelectObject(dc, hold);    
        
    DeleteObject(b);
}
/* End of draw sensor */


/* Decode the sensor into a color */
COLORREF get_sensor_color( bool val )
{
    if (val) return(RGB(255, 0, 0));     // Red for well

    return(RGB(255, 255, 255));                 // No hit, return white
}
/* End of get_sensor_color */


/* Draw an animal to a device context */
void robot_draw(HDC dc)
{
    
    SelectObject(dc, (HPEN)world.black_pen);    
    RECT r;
    get_bounding_rect(robot.x, robot.y, robot.size, robot.size, r);

    SelectObject(dc, (HBRUSH)world.green_brush);

    // Draw robot body
    Ellipse(dc, r.left, r.top, r.right, r.bottom);

    SelectObject(dc, (HBRUSH)world.white_brush);

    // Get distance from center and size of the sensors
    double size = robot.sensor_size;
    double dist = robot.sensor_dist;

    // Draw the direction arrow
    draw_arrow(dc, robot.x, robot.y, robot.dir, size);
 
 
 
    // Draw each sensor
    // The sensor index increases in a clockwise direction

    double angle = - M_PI / 3.0;
    double delta = 2 * M_PI / 6.0;

    for (int i = 0; i < 6; i++, angle += delta)
        draw_sensor(dc,  robot.x, robot.y, robot.dir + angle, dist, size, 
                       get_sensor_color(robot.touch[i]));
                       
                       
  /*  for (int i = 0; i < robot.num_vision_points * 2; i++)
    {
        if (robot.vision[i/ 2].food > 0)
        {

            MoveToEx(dc, get_screen_x(robot.x),get_screen_y(robot.y),NULL);
            LineTo(dc, get_screen_x(robot.end_x[i]),get_screen_y(robot.end_y[i]));
        }
    }*/
        
        
    if (robot.draw_vision)
    // Draw vision lines
    for (int i = 0; i < 6; i++)
        if (robot.wall_found[i])
        {
            line l;
            l.x1 = robot.x;
            l.y1 = robot.y;
            l.x2 = robot.wall_points[i].x;
            l.y2 =robot.wall_points[i].y;
        
            SelectObject(dc, (HPEN)world.green_pen);
    
            draw_line(dc, l);
        }        
                
                
    /// Draw nav vector                
 
    double mag = robot.nav_mag;
    
    if (mag > 0.5) mag = 0.5;
 
   SelectObject(dc, (HPEN)world.blue_pen); 
    draw_arrow(dc, robot.x, robot.y, robot.nav_dir, 0.1);
                
                                
}
/* End of draw sensors */



/* Check the spac that the sensor tip occupies, and set values to match */
bool check_sensor(double x, double y, double dir, double dist) 
{
    // Determine location of sensor tip
    double sx = x + dist * cos(dir);
    double sy = y + dist * sin(dir);
    
    if (world_check_wall_point(sx, sy)) 
    {
        //world_add_impact(sx, sy);
        return(true);        
    }

    if (sx < 0 || sx > world.x_size) 
    {
      //  world_add_impact(sx, sy);
        return(true);
    }

    if (sy < 0 || sy > world.y_size)
    { 
      // world_add_impact(sx, sy);
        return(true);
    }
    
    return(false);
}
/* End of check sensor */





/* compute intersection between two lines */
bool check_intersect(line line1, line line2, point &i)
{
    // Constants for line 1
    // a1*x + b1*y + c1 = 0 
    double a1 = line1.y2 - line1.y1;
    double b1 = line1.x1 - line1.x2;
    double c1 = line1.x2*line1.y1 - line1.x1*line1.y2;  

    // Constants for line 2
    // a2*x + b2*y + c2 = 0 
    double a2 = line2.y2 - line2.y1;
    double b2 = line2.x1 - line2.x2;
    double c2 = line2.x2*line2.y1 - line2.x1*line2.y2;  

    // Descriment
    double  d = a1*b2 - a2*b1;
    
    if (d == 0) return(false);

    i.x = (b1*c2 - b2*c1)/d;
    i.y = (a2*c1 - a1*c2)/d;

    if (line1.x1 != line1.x2 && i.x < line1.x1 && i.x < line1.x2) return(false);
    if (line1.x1 != line1.x2 && i.x > line1.x1 && i.x > line1.x2) return(false);

    if (line1.y1 != line1.y2 && i.y < line1.y1 && i.y < line1.y2) return(false);
    if (line1.y1 != line1.y2 && i.y > line1.y1 && i.y > line1.y2) return(false);

    if (line2.x1 != line2.x2 && i.x < line2.x1 && i.x < line2.x2) return(false);
    if (line2.x1 != line2.x2 && i.x > line2.x1 && i.x > line2.x2) return(false);

    if (line2.y1 != line2.y2 && i.y < line2.y1 && i.y < line2.y2) return(false);
    if (line2.y1 != line2.y2 && i.y > line2.y1 && i.y > line2.y2) return(false);

    return(true);    
}
/* End of check_intersect */


/* Check intersection between line and box */
double check_box_intersect(line main, line box, point &intersect)
{
    line test_line;
    
    bool hit[4] = {false};
    point points[4];
    double dist[4] = {MAX_IR_DIST, MAX_IR_DIST, MAX_IR_DIST, MAX_IR_DIST};
        
    // Check upper line
    test_line.x1 = box.x1;   test_line.y1 = box.y1;
    test_line.x2 = box.x2;   test_line.y2 = box.y1;

    if (check_intersect(main, test_line, points[0]))
    {
        dist[0] = sqrt((points[0].x - main.x1) * (points[0].x - main.x1)+   
                       (points[0].y - main.y1) * (points[0].y - main.y1)); 

    }

    // Check lower line
    test_line.x1 = box.x1;   test_line.y1 = box.y2;
    test_line.x2 = box.x2;   test_line.y2 = box.y2;

    if (check_intersect(main, test_line, points[1]))
        dist[1] = sqrt((points[1].x - main.x1) * (points[1].x - main.x1)+   
                       (points[1].y - main.y1) * (points[1].y - main.y1));   

    // Check left line
    test_line.x1 = box.x1;   test_line.y1 = box.y1;
    test_line.x2 = box.x1;   test_line.y2 = box.y2;

    if (check_intersect(main, test_line, points[2]))
        dist[2] = sqrt((points[2].x - main.x1) * (points[2].x - main.x1)+   
                       (points[2].y - main.y1) * (points[2].y - main.y1));   
    // Check right line
    test_line.x1 = box.x2;   test_line.y1 = box.y1;
    test_line.x2 = box.x2;   test_line.y2 = box.y2;

    if (check_intersect(main, test_line, points[3]))
        dist[3] = sqrt((points[3].x - main.x1) * (points[3].x - main.x1)+   
                       (points[3].y - main.y1) * (points[3].y - main.y1));   


    // Calculate and return distance to closest line in box
    double smallest_dist = world.x_size + world.y_size;
    int smallest_index = 0;
    
    char b[400];
    
    for (int i = 0; i < 4; i++)
    {
        if (dist[i] > 0 && dist[i] <= smallest_dist)
        {
            smallest_dist = dist[i];
            smallest_index = i;
        }
    }
   
    if (dist[smallest_index] < 1)
   {
        
            world_add_impact(points[smallest_index].x, points[smallest_index].y);
    }
   
    intersect = points[smallest_index];    
    


    return(dist[smallest_index]);
}



/* Check the space that the sensor tip occupies, and set values to match */
double check_vision(double x, double y, double dir, bool &found, point &p) 
{
    // Determine location of sensor tip
    double max_size = world.x_size * world.y_size;

    line main_line;
    
    main_line.x1 = x;
    main_line.y1 = y;
    
    main_line.x2 = x + max_size * cos(dir);
    main_line.y2 = y + max_size * sin(dir);
        
    wall_type *w = world.walls;    
   
    found = false;
   
    point points[world.num_walls];
    double dist[world.num_walls];

    
    point intersect;
    line box;    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
eeuss鲁片一区二区三区在线看| 另类人妖一区二区av| 久久综合狠狠综合久久综合88 | 欧美成人一区二区三区片免费| 91视视频在线直接观看在线看网页在线看 | 爽好多水快深点欧美视频| 一区二区在线观看不卡| 亚洲欧洲精品一区二区三区不卡 | 99精品视频在线免费观看| 成人午夜碰碰视频| 97精品国产露脸对白| 91啪亚洲精品| 欧美亚洲动漫精品| 91精品国产福利在线观看 | 国产成人一区在线| av资源网一区| 欧美日韩国产123区| 日韩一区二区三区三四区视频在线观看| 欧美精品日韩综合在线| 精品999久久久| 国产精品伦一区| 亚洲国产视频在线| 免费美女久久99| 成人黄色电影在线 | 久久福利视频一区二区| 国产高清成人在线| 在线中文字幕不卡| 日韩情涩欧美日韩视频| 中文字幕国产一区二区| 亚洲一区在线视频| 极品美女销魂一区二区三区免费| 成人午夜av电影| 欧洲av一区二区嗯嗯嗯啊| 日韩精品在线一区| 一区二区在线观看av| 国内精品视频一区二区三区八戒| 97se亚洲国产综合自在线观| 欧美伦理视频网站| 自拍偷在线精品自拍偷无码专区| 日韩电影网1区2区| 成人高清伦理免费影院在线观看| 欧美性感一区二区三区| 国产日本亚洲高清| 日本强好片久久久久久aaa| 国产91精品精华液一区二区三区| 99国产精品视频免费观看| 欧美一区二区精品| 亚洲永久免费av| 国产成人av在线影院| 欧美一级xxx| 亚洲一卡二卡三卡四卡| 高清日韩电视剧大全免费| 欧美精品三级日韩久久| 中文字幕永久在线不卡| 国产乱人伦精品一区二区在线观看 | 国产天堂亚洲国产碰碰| 日韩精品乱码av一区二区| 色又黄又爽网站www久久| 国产免费成人在线视频| 九九九精品视频| 日韩欧美美女一区二区三区| 亚洲精品高清视频在线观看| 成人激情免费视频| 中文字幕av资源一区| 狠狠色丁香久久婷婷综合丁香| 日韩一区二区在线观看视频播放| 亚洲国产你懂的| 在线免费观看日本欧美| 亚洲另类春色校园小说| 99精品黄色片免费大全| 国产精品污www在线观看| 国产黑丝在线一区二区三区| 精品国产91乱码一区二区三区 | 色94色欧美sute亚洲13| 国产精品福利一区| 99久久精品一区二区| 国产精品久久二区二区| eeuss鲁片一区二区三区在线看| 国产精品网站在线| 国产99久久久精品| 亚洲婷婷在线视频| 色94色欧美sute亚洲线路二| 亚洲福利一二三区| 欧美成人vr18sexvr| 国产乱子伦视频一区二区三区 | 肉肉av福利一精品导航| 51精品视频一区二区三区| 日韩精品欧美精品| 久久久美女艺术照精彩视频福利播放| 国内精品免费在线观看| 国产精品色在线| 日韩女优av电影| 国产麻豆视频一区二区| 国产精品久久久久久久久久免费看 | 国产精品色哟哟网站| 色综合天天性综合| 亚洲国产精品久久人人爱| 欧美一区二区三区四区高清| 国产一区二区在线观看免费| 中文字幕在线不卡一区| 777色狠狠一区二区三区| 国产精品自在在线| 一区二区三区四区蜜桃| 欧美一卡二卡在线| 懂色av一区二区夜夜嗨| 亚洲影院在线观看| 久久久久久久久免费| 在线免费观看日本欧美| 韩国av一区二区三区四区 | 视频一区在线播放| 国产午夜精品一区二区三区视频 | 韩国成人在线视频| 伊人一区二区三区| 26uuu亚洲综合色欧美| 97国产精品videossex| 精品一区二区三区视频 | 91精品欧美福利在线观看| 国产69精品久久99不卡| 日日夜夜免费精品视频| 国产精品高潮久久久久无| 51午夜精品国产| 91官网在线免费观看| 国产乱淫av一区二区三区| 日韩成人av影视| 最好看的中文字幕久久| 精品1区2区在线观看| 欧美另类高清zo欧美| 91免费视频观看| 成人午夜免费电影| 久久国产夜色精品鲁鲁99| 亚洲国产va精品久久久不卡综合| 国产精品卡一卡二| www激情久久| 欧美一区二区三区免费大片| 欧美一区二区三区视频| 99久久亚洲一区二区三区青草| 日本免费新一区视频| 亚洲一区自拍偷拍| 亚洲日本乱码在线观看| 欧美国产成人精品| 久久欧美一区二区| 欧美电视剧在线观看完整版| 在线电影国产精品| 欧美猛男男办公室激情| 欧美视频在线一区| 欧美在线制服丝袜| 色av一区二区| 在线日韩av片| 欧美性色黄大片手机版| 在线免费观看视频一区| 色狠狠一区二区三区香蕉| 91免费在线播放| 欧美在线你懂得| 欧美日韩一区二区电影| 精品视频在线视频| 欧美一区二区三区在| 欧美不卡一区二区| 日韩欧美电影一区| 26uuu国产在线精品一区二区| wwwwxxxxx欧美| 中文av字幕一区| 亚洲精品免费在线观看| 亚洲国产欧美另类丝袜| 日本成人在线电影网| 九九九精品视频| 国产成人av电影在线| 99久久精品国产网站| 欧美在线一区二区三区| 91精品国产欧美一区二区| 日韩欧美一区二区不卡| 国产欧美日韩在线| 一区二区免费看| 蜜桃在线一区二区三区| 国产91在线观看| 91黄色免费版| 日韩一卡二卡三卡| 中文字幕欧美日韩一区| 一级女性全黄久久生活片免费| 视频精品一区二区| 国产91精品在线观看| 欧美亚洲一区二区在线| 精品久久人人做人人爱| 成人免费一区二区三区视频 | 日韩精品成人一区二区三区| 狠狠色伊人亚洲综合成人| 色综合视频一区二区三区高清| 56国语精品自产拍在线观看| 国产欧美日本一区二区三区| 一区二区三区丝袜| 久久国产福利国产秒拍| 色婷婷激情一区二区三区| 精品久久久久久综合日本欧美| 中文字幕一区二区三区四区不卡 | 99精品久久免费看蜜臀剧情介绍| 欧美日韩大陆在线| 日本一区二区视频在线观看| 亚洲午夜精品久久久久久久久| 国产在线视频一区二区| 欧美色图12p| 国产精品素人视频|