Browse Source

Migrate to new dependencies

- Migrate to go mod
- Migrate to qtprotobif 0.2.0
Alexey Edelev 4 years ago
parent
commit
b91c42882b
8 changed files with 85 additions and 24 deletions
  1. 3 4
      build.sh
  2. 13 0
      go.mod
  3. 60 0
      go.sum
  4. 1 1
      main.go
  5. 1 11
      snakesimulator/snakesimulator.go
  6. 6 5
      snakesimulatorui/CMakeLists.txt
  7. 0 2
      snakesimulatorui/main.cpp
  8. 1 1
      snakesimulatorui/qtprotobuf

+ 3 - 4
build.sh

@@ -1,13 +1,12 @@
-export GOPATH=$PWD
 export PATH=$PATH:$PWD/bin
 export GOBIN=$PWD/bin
+export GO111MODULES=on
 
-go get github.com/golang/protobuf/protoc-gen-go
-go install ./src/github.com/golang/protobuf/protoc-gen-go
+go get -u github.com/golang/protobuf/protoc-gen-go@v1.3.3
 
 export SNAKE_RPC_PATH=$PWD/snakesimulator
 mkdir -p $SNAKE_RPC_PATH
 rm -f $SNAKE_RPC_PATH/*.pb.go
 protoc -I$SNAKE_RPC_PATH --go_out=plugins=grpc:$SNAKE_RPC_PATH $SNAKE_RPC_PATH/snakesimulator.proto
-go get -v
+
 go build -o $GOBIN/snakesimulator

+ 13 - 0
go.mod

@@ -0,0 +1,13 @@
+module git.semlanik.org/semlanik/SnakeSimulator
+
+go 1.12
+
+require (
+	git.semlanik.org/semlanik/NeuralNetwork v0.0.0-20200226210944-c5821214694e
+	github.com/golang/protobuf v1.3.3
+	golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
+	golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
+	gonum.org/v1/gonum v0.6.2
+	google.golang.org/grpc v1.27.1
+	honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
+)

+ 60 - 0
go.sum

@@ -0,0 +1,60 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+git.semlanik.org/semlanik/NeuralNetwork v0.0.0-20200226210944-c5821214694e h1:UW5E+B7Ab5aPOycCzFRPwieVt7XYXRmRDwkzaB8jbAY=
+git.semlanik.org/semlanik/NeuralNetwork v0.0.0-20200226210944-c5821214694e/go.mod h1:pRtawD4cwTdV0fL60l2gmL5Sxe6/WE0K87cIm+ziHK4=
+git.semlanik.org/semlanik/NeuralNetworkVisualization v0.0.0-20200226211826-8536dc080f23 h1:hhZE6XOYdWlPxrx3/xi91qlzf9YjBihgaJAJ4t2bFwI=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
+gonum.org/v1/gonum v0.6.2/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
+gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
+gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 1 - 1
main.go

@@ -28,7 +28,7 @@ package main
 import (
 	genetic "git.semlanik.org/semlanik/NeuralNetwork/genetic"
 	mutagens "git.semlanik.org/semlanik/NeuralNetwork/genetic/mutagens"
-	snakesimulator "./snakesimulator"
+	snakesimulator "git.semlanik.org/semlanik/SnakeSimulator/snakesimulator"
 )
 
 func main() {

+ 1 - 11
snakesimulator/snakesimulator.go

@@ -39,7 +39,6 @@ import (
 
 	genetic "git.semlanik.org/semlanik/NeuralNetwork/genetic"
 	neuralnetwork "git.semlanik.org/semlanik/NeuralNetwork/neuralnetwork"
-	remotecontrol "git.semlanik.org/semlanik/NeuralNetwork/remotecontrol"
 	grpc "google.golang.org/grpc"
 )
 
@@ -48,7 +47,6 @@ type SnakeSimulator struct {
 	snake                *Snake
 	maxVerificationSteps int
 	stats                *Stats
-	remoteControl        *remotecontrol.RemoteControl
 
 	//GUI interface part
 	speed                uint32
@@ -87,7 +85,6 @@ func NewSnakeSimulator(maxVerificationSteps int) (s *SnakeSimulator) {
 		isPlayingUpdateQueue: make(chan bool, 1),
 		speedQueue:           make(chan uint32, 1),
 		speed:                10,
-		remoteControl:        remotecontrol.NewRemoteControl(),
 	}
 	return
 }
@@ -95,7 +92,6 @@ func NewSnakeSimulator(maxVerificationSteps int) (s *SnakeSimulator) {
 // Population test method
 // Verifies population and returns unsorted finteses for each individual
 func (s *SnakeSimulator) Verify(population *genetic.Population) (fitnesses []*genetic.IndividalFitness) {
-	s.remoteControl.Init(population.Networks[0])
 	s.stats.Generation++
 	s.statsUpdateQueue <- true
 
@@ -133,12 +129,10 @@ func (s *SnakeSimulator) Verify(population *genetic.Population) (fitnesses []*ge
 		// Play best of the best
 		s.isPlaying = false
 		s.isPlayingUpdateQueue <- s.isPlaying
-		population.GetBestNetwork().SetStateWatcher(s.remoteControl)
 		s.runSnake(population.GetBestNetwork(), false)
 		population.GetBestNetwork().SetStateWatcher(nil)
 	} else {
-		// Pley best from generation
-		population.Networks[fitnesses[0].Index].SetStateWatcher(s.remoteControl)
+		// Play best from generation
 		s.runSnake(population.Networks[fitnesses[0].Index], false)
 		population.Networks[fitnesses[0].Index].SetStateWatcher(nil)
 	}
@@ -149,7 +143,6 @@ func (s *SnakeSimulator) Verify(population *genetic.Population) (fitnesses []*ge
 func (s *SnakeSimulator) PlayBestNetwork(network *neuralnetwork.NeuralNetwork) {
 
 	for s.repeatInLoop {
-		s.remoteControl.Init(network)
 		s.stats.Generation++
 		s.statsUpdateQueue <- true
 
@@ -167,7 +160,6 @@ func (s *SnakeSimulator) PlayBestNetwork(network *neuralnetwork.NeuralNetwork) {
 		s.isPlayingUpdateQueue <- s.isPlaying
 		prevSpeed := s.speed
 		s.speed = 5
-		network.SetStateWatcher(s.remoteControl)
 		s.runSnake(network, false)
 		network.SetStateWatcher(nil)
 		s.speed = prevSpeed
@@ -434,8 +426,6 @@ func (s *SnakeSimulator) StartServer() {
 			fmt.Printf("Failed to serve: %v\n", err)
 		}
 	}()
-
-	go s.remoteControl.Run()
 }
 
 // Steaming of Field updates

+ 6 - 5
snakesimulatorui/CMakeLists.txt

@@ -4,8 +4,8 @@ project(SnakeSimulatorkUi LANGUAGES CXX)
 
 find_package(Qt5 COMPONENTS Quick Gui Core Qml REQUIRED)
 
-set(QTPROTOBUF_MAKE_TESTS false)
-set(QTPROTOBUF_MAKE_EXAMPLES false)
+set(QT_PROTOBUF_MAKE_TESTS OFF)
+set(QT_PROTOBUF_MAKE_EXAMPLES OFF)
 add_subdirectory("qtprotobuf")
 find_package(QtProtobufProject CONFIG COMPONENTS QtProtobuf QtGrpc REQUIRED)
 if(Qt5_POSITION_INDEPENDENT_CODE)
@@ -14,10 +14,11 @@ endif()
 
 file(GLOB PROTO_FILES ABSOLUTE "${CMAKE_CURRENT_SOURCE_DIR}/../snakesimulator/snakesimulator.proto")
 
-generate_qtprotobuf(TARGET SnakeSimulatorkUi PROTO_FILES ${PROTO_FILES} QML TRUE)
-
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
 add_executable(SnakeSimulatorkUi main.cpp qml.qrc clientwrapper.cpp)
-target_link_libraries(SnakeSimulatorkUi Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick QtProtobufProject::QtProtobuf QtProtobufProject::QtGrpc ${QtProtobuf_GENERATED})
+
+qtprotobuf_generate(TARGET SnakeSimulatorkUi PROTO_FILES ${PROTO_FILES} QML)
+
+target_link_libraries(SnakeSimulatorkUi PRIVATE Qt5::Gui QtProtobufProject::QtProtobuf QtProtobufProject::QtGrpc)

+ 0 - 2
snakesimulatorui/main.cpp

@@ -31,7 +31,6 @@
 
 #include <QGrpcHttp2Channel>
 #include <QGrpcInsecureCredentials>
-#include "qtprotobuf_global.qpb.h"
 #include "snakesimulator_grpc.qpb.h"
 
 #include "clientwrapper.h"
@@ -40,7 +39,6 @@ int main(int argc, char *argv[])
 {
     QGuiApplication app(argc, argv);
     QtProtobuf::qRegisterProtobufTypes();
-    snakesimulator::qRegisterProtobufTypes();
 
     qmlRegisterUncreatableType<QtProtobuf::QGrpcAsyncReply>("snakesimulator", 1, 0, "QGrpcAsyncReply", "");
     std::shared_ptr<snakesimulator::SnakeSimulatorClient> client(new snakesimulator::SnakeSimulatorClient);

+ 1 - 1
snakesimulatorui/qtprotobuf

@@ -1 +1 @@
-Subproject commit 8cd7bdd128a64f9b60cc335306c49e6dab6ed1c7
+Subproject commit 6a8f5622b9f5e22870443933322bfc49b9bc8305