Warning: Illegal string offset 'name' in [path]/includes/functions.php on line 6845
Giải Bích Quế Viên Bôi lần thứ 8 năm 2019 (Trịnh Duy Đồng vô địch P38)
Close
Login to Your Account
Kết quả 1 đến 10 của 530

Hybrid View

  1. #1
    Ngày tham gia
    Oct 2016
    Bài viết
    499
    Post Thanks / Like

    Mặc định

    Trích dẫn Gửi bởi taipscode Xem bài viết
    Dạ em chào bác ,em học K96 BKHCM không biết bác học ở núi nào , intella ,cyclone ,ggchess viết bằng Visual C++ đấy ...; bạn tui nó đạt giải 3 robot đánh cờ tướng đó , bác có hứng thú thì liên hệ với nó ,còn chém gió chơi thì thui ...

    Sourcecode cờ vua có sẵn trong planetsourcecode.com đấy còn sourcecode về cờ tướng cũng có nhưng chạy khá yếu và đánh không hay lắm ...
    Thuật toán cũ lạc hậu, ko hứng thú lắm. Mình học ở đâu như thế nào mời giở vài trang trước sẽ thấy.

  2. #2
    Ngày tham gia
    Feb 2012
    Bài viết
    1,265
    Post Thanks / Like

    Mặc định

    Trích dẫn Gửi bởi imagination Xem bài viết
    Thuật toán cũ lạc hậu, ko hứng thú lắm. Mình học ở đâu như thế nào mời giở vài trang trước sẽ thấy.


    #include <EEPROM.h>

    // these values are saved in EEPROM
    const byte EEPROM_ID = 0x99; // used to identify if valid data in EEPROM
    byte ledPin = 13; // the number of the LED pin
    int interval = 1000; // interval at which to blink (milliseconds)

    // variables that do not need to be saved
    int ledState = LOW; // ledState used to set the LED
    long previousMillis = 0; // will store last time LED was updated

    //constants used to identify EEPROM addresses
    const int ID_ADDR = 0; // the EEPROM address used to store the ID
    const int PIN_ADDR = 1; // the EEPROM address used to store the pin
    const int INTERVAL_ADDR = 2; // the EEPROM address used to store the interval

    void setup()
    {
    Serial.begin(9600);
    byte id = EEPROM.read(ID_ADDR); // read the first byte from the EEPROM
    if( id == EEPROM_ID)
    {
    // here if the id value read matches the value saved when writing eeprom
    Serial.println("Using data from EEPROM");
    ledPin = EEPROM.read(PIN_ADDR);
    byte hiByte = EEPROM.read(INTERVAL_ADDR);
    byte lowByte = EEPROM.read(INTERVAL_ADDR+1);
    interval = word(hiByte, lowByte); // see word function in Recipe 3.15
    }
    else
    {
    // here if the ID is not found, so write the default data
    Serial.println("Writing default data to EEPROM");
    EEPROM.write(ID_ADDR,EEPROM_ID); // write the ID to indicate valid data
    EEPROM.write(PIN_ADDR, ledPin); // save the pin in eeprom
    byte hiByte = highByte(interval);
    byte loByte = lowByte(interval);
    EEPROM.write(INTERVAL_ADDR, hiByte);
    EEPROM.write(INTERVAL_ADDR+1, loByte);

    }
    Serial.print("Setting pin to ");
    Serial.println(ledPin,DEC);
    Serial.print("Setting interval to ");
    Serial.println(interval);

    pinMode(ledPin, OUTPUT);
    }

    void loop()
    {
    // this is the same code as the BlinkWithoutDelay example sketch
    if (millis() - previousMillis > interval)
    {
    previousMillis = millis(); // save the last time you blinked the LED
    // if the LED is off turn it on and vice versa:
    if (ledState == LOW)
    ledState = HIGH;
    else
    ledState = LOW;
    digitalWrite(ledPin, ledState); // set LED using value of ledState
    }
    processSerial();
    }

    // function to get duration or pin values from Serial Monitor
    // value followed by i is interval, p is pin number
    int value = 0;

    void processSerial()
    {
    if( Serial.available())
    {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
    value = (value * 10) + (ch - '0'); // yes, accumulate the value
    }
    else if (ch == 'i') // is this the interval
    {
    interval = value;
    Serial.print("Setting interval to ");
    Serial.println(interval);
    byte hiByte = highByte(interval);
    byte loByte = lowByte(interval);
    EEPROM.write(INTERVAL_ADDR, hiByte);
    EEPROM.write(INTERVAL_ADDR+1, loByte);
    value = 0; // reset to 0 ready for the next sequence of digits
    }
    else if (ch == 'p') // is this the pin number
    {
    ledPin = value;
    Serial.print("Setting pin to ");
    Serial.println(ledPin,DEC);
    pinMode(ledPin, OUTPUT);
    EEPROM.write(PIN_ADDR, ledPin); // save the pin in eeprom
    value = 0; // reset to 0 ready for the next sequence of digits
    }
    }
    }


    Bác có biết code này là gì hem ,biết thì bàn tiếp ,còn không thì tui không tiếp bác nữa ...

    (Lập trình robot mừ bác chê là lạc hậu thì tui chả biết cái gì là mới nữa ...)
    Lần sửa cuối bởi taipscode, ngày 09-12-2019 lúc 10:07 PM.

  3. #3
    Ngày tham gia
    Oct 2016
    Bài viết
    499
    Post Thanks / Like

    Mặc định

    Trích dẫn Gửi bởi taipscode Xem bài viết
    #include <EEPROM.h>

    // these values are saved in EEPROM
    const byte EEPROM_ID = 0x99; // used to identify if valid data in EEPROM
    byte ledPin = 13; // the number of the LED pin
    int interval = 1000; // interval at which to blink (milliseconds)

    // variables that do not need to be saved
    int ledState = LOW; // ledState used to set the LED
    long previousMillis = 0; // will store last time LED was updated

    //constants used to identify EEPROM addresses
    const int ID_ADDR = 0; // the EEPROM address used to store the ID
    const int PIN_ADDR = 1; // the EEPROM address used to store the pin
    const int INTERVAL_ADDR = 2; // the EEPROM address used to store the interval

    void setup()
    {
    Serial.begin(9600);
    byte id = EEPROM.read(ID_ADDR); // read the first byte from the EEPROM
    if( id == EEPROM_ID)
    {
    // here if the id value read matches the value saved when writing eeprom
    Serial.println("Using data from EEPROM");
    ledPin = EEPROM.read(PIN_ADDR);
    byte hiByte = EEPROM.read(INTERVAL_ADDR);
    byte lowByte = EEPROM.read(INTERVAL_ADDR+1);
    interval = word(hiByte, lowByte); // see word function in Recipe 3.15
    }
    else
    {
    // here if the ID is not found, so write the default data
    Serial.println("Writing default data to EEPROM");
    EEPROM.write(ID_ADDR,EEPROM_ID); // write the ID to indicate valid data
    EEPROM.write(PIN_ADDR, ledPin); // save the pin in eeprom
    byte hiByte = highByte(interval);
    byte loByte = lowByte(interval);
    EEPROM.write(INTERVAL_ADDR, hiByte);
    EEPROM.write(INTERVAL_ADDR+1, loByte);

    }
    Serial.print("Setting pin to ");
    Serial.println(ledPin,DEC);
    Serial.print("Setting interval to ");
    Serial.println(interval);

    pinMode(ledPin, OUTPUT);
    }

    void loop()
    {
    // this is the same code as the BlinkWithoutDelay example sketch
    if (millis() - previousMillis > interval)
    {
    previousMillis = millis(); // save the last time you blinked the LED
    // if the LED is off turn it on and vice versa:
    if (ledState == LOW)
    ledState = HIGH;
    else
    ledState = LOW;
    digitalWrite(ledPin, ledState); // set LED using value of ledState
    }
    processSerial();
    }

    // function to get duration or pin values from Serial Monitor
    // value followed by i is interval, p is pin number
    int value = 0;

    void processSerial()
    {
    if( Serial.available())
    {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
    value = (value * 10) + (ch - '0'); // yes, accumulate the value
    }
    else if (ch == 'i') // is this the interval
    {
    interval = value;
    Serial.print("Setting interval to ");
    Serial.println(interval);
    byte hiByte = highByte(interval);
    byte loByte = lowByte(interval);
    EEPROM.write(INTERVAL_ADDR, hiByte);
    EEPROM.write(INTERVAL_ADDR+1, loByte);
    value = 0; // reset to 0 ready for the next sequence of digits
    }
    else if (ch == 'p') // is this the pin number
    {
    ledPin = value;
    Serial.print("Setting pin to ");
    Serial.println(ledPin,DEC);
    pinMode(ledPin, OUTPUT);
    EEPROM.write(PIN_ADDR, ledPin); // save the pin in eeprom
    value = 0; // reset to 0 ready for the next sequence of digits
    }
    }
    }


    Bác có biết code này là gì hem ,biết thì bàn tiếp ,còn không thì tui không tiếp bác nữa ...
    Tôi ko tiếp người như anh. Anh cần thì liên hệ tôi, tôi có profile công khai, thi thố các cuộc thi Kaggle tầm thế giới đc 3 gold medal trong 1 năm. Anh chỉ đem toán, code, copy paste vào đây. Anh cũng chỉ là múa rìu qua mắt thợ. Mấy hôm trước anh đem ba bài toán phổ thông lên diễn đàn. Tôi thấy hơi ngứa mắt rồi. Anh giỏi bằng ai? Nói hơi khó nghe, xin lỗi, chứ trình độ anh chưa tới, mà còn bất lịch sự. tôi mới là người miễn tiếp chuyện anh. Anh lên kaggle.com/khahuras coi profile của tôi. Từ đó, anh lục ra biết bao nhiêu code tôi đã viết, biết bao thành tích tôi đã đạt đc. Thân.

  4. #4
    Ngày tham gia
    Feb 2012
    Bài viết
    1,265
    Post Thanks / Like

    Mặc định

    Ở đây là diễn đàn cờ tướng , bàn nhiều quá lạc đề, bác thực sự giỏi về công nghệ thông tin thì add zalo của tui 0377388871 để trao đổi học hỏi lẫn nhau ,có thể nhiều cái mới ra tui thì cũng không thể biết hết...
    Lần sửa cuối bởi taipscode, ngày 09-12-2019 lúc 10:19 PM.

Giải Bích Quế Viên Bôi lần thứ 8 năm 2019 (Trịnh Duy Đồng vô địch P38)

Đánh dấu

Đánh dấu

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •  
.::Thăng Long Kỳ Đạo::.
  • Liên hệ quảng cáo: trung_cadan@yahoo.com - DĐ: 098 989 66 68