Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tautology · May 19, 2016 at 05:18 PM · androidaithreadsrecursion

Threads don't work the same for pc and android?

I implemented a thread for my unity project and it works fine on pc but it is broken for the android. The thread is running a recursion and for some reason teh values returned are messed up. Can;t really explain what happens there yet though

What I do is create the thread on another script and run the method...is this the way to go for android apps?

this is my thread:

   public int GetPCNextTurn(int[][] board,int height,int width,int sequence)
         {
             
                 this.height = height;
                 this.width = width;
                 this.sequence = sequence;
              
             
             this.board = board;
            
             weights= GetWeights(sequence);
 
              CompPlayTurn(board,weights);
 
  Thread myThread = new Thread(() => CompPlayTurn(board, weights));
      myThread.Start();
 
 return col2play;
         }


The pc used to mess the board I sent it (the code ruins the board with teh recursion but for some reason the change becomes permanent when using threads ) so I send a copy of the board.

But the android not only messes the board still, but the value returned is always the same...

Basically I have a recursion AI that should return the move to take, and this is what I ;d like to put in a thread..

Any suggestions?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by FortisVenaliter · May 19, 2016 at 07:01 PM

Well, threads should work pretty much the exact same... the primary difference between the different architecture would be timing. You probably have a race condition that's not triggering on PC due to the way PCs (specifically their CPUs) are optimized for multithreading. That's one of the biggest pitfalls of theads, and one of the hardest to diagnose, but there are good articles online if you search for 'thread race condition'.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by UNDERHILL · Oct 31, 2016 at 12:55 AM

You might want to work with a promise library...

https://github.com/Real-Serious-Games/C-Sharp-Promise

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Ai continues to move after calling it to stop 1 Answer

what is the best way for make AI in android?navmesh or agent patrol between a set of points? 0 Answers

Help needed for a dialogue/speech System 1 Answer

Enemy AI acting strangely and only animating on the first placed in scene. 1 Answer

Background Networking Activity and Unity Run Loop 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges