main.qml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of NeuralNetwork project https://git.semlanik.org/semlanik/NeuralNetwork
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. import QtQuick 2.11
  26. import QtQuick.Window 2.11
  27. import QtQuick.Controls 1.4
  28. ApplicationWindow {
  29. id: root
  30. visible: true
  31. property int tileSize: 20
  32. width: field.width*tileSize
  33. height: field.height*tileSize
  34. Rectangle {
  35. color: "#000000"
  36. anchors.fill: parent
  37. }
  38. Repeater {
  39. model: snake.pointsData.length
  40. Rectangle {
  41. color: "#ffffff"
  42. x: snake.pointsData[model.index].x*tileSize
  43. y: snake.pointsData[model.index].y*tileSize
  44. width: tileSize
  45. height: tileSize
  46. }
  47. }
  48. Rectangle {
  49. color: "#eeffee"
  50. x: field.food.x*tileSize
  51. y: field.food.y*tileSize
  52. width: tileSize
  53. height: tileSize
  54. }
  55. Column {
  56. anchors {
  57. right: parent.right
  58. top: parent.top
  59. margins: 10
  60. }
  61. Text {
  62. color: "#ddffee"
  63. text: "Generation: " + stats.generation
  64. }
  65. Text {
  66. color: "#ddffee"
  67. text: "Individual: " + stats.individual
  68. }
  69. Text {
  70. color: "#ddffee"
  71. text: "Move: " + stats.move
  72. }
  73. }
  74. Connections {
  75. target: field
  76. onWidthChanged: {
  77. console.log("New width: " + field.width)
  78. }
  79. }
  80. }