# NullpoMino

Thread in 'Discussion' started by Caithness, 18 Aug 2009.

1. ### Poochy

Yup, it's supposed to work in 20G, but assumes availability of TI floorkicks. So far, it can usually get around an S4-ish grade in Grade Mania 3 mode, though it did get a crazy fluke M6 run once.

I plan on releasing the latest stable version by the end of May (I actually wasn't even planning on mentioning it until then, but the IRS trouble made me cave in and ask for help), so feel free to include it in the next version of the UE after that.

2. ### Zircean

Wow, that's really awesome! You should record a movie of the replay for that M6 game as a teaser trailer or something like that, hahaha.... I'd really like to see what you've got going on so far!

Also, since it seems like you're the premier authority on NullpoMino AI writing and it looks like the BasicAI class is rather complicated, maybe we could put together a comprehensive guide on modding all aspects of NullpoMino at some point? Maybe that would help get more collaborators for the UE...

In any case, if your AI can already play in 20G with a reasonable amount of skill, that's an impressive feat. I believe this is the first 20G-capable TGM AI (Mihys's DTET AI doesn't count, although it is quite impressive).

3. ### Poochy

I would, but I find any program that can record a screen capture video of NullpoMino without lagging it down to about 1/4th speed. Fraps is the closest I've gotten to a working video recorder, and it makes NullpoMino run at 15fps. Any help here?

But as an update, I just added some extra code to the movement/rotation execution algorithm to make it much less likely to get L and J pieces stuck in high gravity. Basically, I added maneuvers like the one Jin8 uses with the J piece at about 2:41 in the famous Arika video. A couple runs later and it's managed to get an M9 grade, level 999. (It failed the non-instant invisibility roll with about 22 seconds left.) And an M4-ish result is not too uncommon now.

[Edit: Make that MasterK, survived the full non-instant invisibility roll.]
[Edit 2: Holy frakkin' crap, it just manged to get a Grand Master run.]

And as for writing a comprehensive guide to modding the game, I've actually only bothered with the AI and whatever classes are relevant to making an AI, but I think I could write up some documentation about making AIs.

While I'm at it, a couple bugs I noticed:

- Hitting left from 1P in the Options menu will change it to 0P, then negative player numbers.
- Field.getHighestPieceY(int) will return 19 both for an empty column and a column with one block at the very bottom.
- Field.getValleyDepth(int) (and by extension, Field.getTotalValleyNeedIPiece) assumes it has hit the bottom of the valley if there is a hole on the immediate left or right of the valley it's trying to check. (Looking at the comments, this might have been intentional, but for my purposes, it forced me to write my own valley-checking algorithm.) In other words, the following counts as a valley of only depth 2, and does NOT count as a valley that needs an I piece:
Code:
[]  [][]
[]  [][]
[]    []
[]  [][]
[]  [][]
[]  [][]
[][][][]
I ended up writing new versions of both of these algorithms, located inside my AI player class.

Edit: One more (possible) bug: The high score list will rank any green-line grade over any no-line grade. For example, my AI had a green-line M6, which outranked its no-line M8. I'm not totally sure, but I think TI ranks grades first, with ties broken by line and then time.

Last edited: 29 Mar 2010

NullpoMino Version 6.5

Thanks everyone for supporting NullpoMino!
I released Version 6.5.

I finally added a sort of netplay feature.
Please note, it's still very alpha state, and it only has some basic features.

List of what you can do:
* Play against other players (up to 6 players can join)
* Create a new room
* Join an already existing room
* Talk with other players
* Spectate games

List of what you can't do & Known problems:
* Speed parameters and other options can't be changed
* Any players can use any ruleset, and may cause unfair game
* Game will not start until everyone is ready
* Replay can't be saved
* No rating system
* Does not keep track your amount of wins
* Does not display other players' statistics
* No piece preview for opponents
* No chat flooding protection
* No ignorelist/banlist
* No in-game player name display for Swing version
* It has bad lobby GUI
* It's buggy!
* Code is messy and chaos

Version 6.5 (2010/03/31)
+VS-BATTLE: Added "1-ATTACK" garbage pattern option. Less random than NORMAL but more random than ONE RISE. (In other words, it's T0J.)
+VS-BATTLE: Added "SE" option that can disable the sound effects. This may improve the performance of You VS AI games.
-GRADE MANIA 3: Probably fixed that infamous MM-exam bug. Sorry for late fix
-RETRO MANIA: Score no longer goes past 999999. Lines no longer goes past 999. Level no longer goes past 99.
-SDL/Slick: Fixed a bug that hitting left from 1P in the Options menu will change it to 0P (Thanks Poochy!)
-Core: Bugs on Field.getHighestPieceY(int) and Field.getValleyDepth(int) are probably fixed (Thanks again Poochy!)
*Slick: Changed Joystick config screen code, so more joysticks may work.
*Replaced native jinput library for Mac OS (lib/libjinput-osx.jnilib) to Snow Leopard compatible version
(http://ariejan.net/2009/09/01/jinput-mac-os-x-64-bit-natives/)

@Poochy: Thanks for bug reporting. I forget the high score list thing, but I'll fix it in next release. And, wow, your AI is so cool!

@rednefed: Unlike Linux version of LWJGL, Windows version doesn't detect 64bit version of DLL automatically. You need to manually copy "lwjgl64.dll" over "lwjgl.dll".

5. ### Burbruee

Wow, I'll definitely try this new release out later today!

Edit: I've put up a dedicated server on my CentOS linux box. It should be up at all times if anyone wants to try out the new alpha netplay.

Just put in 143.homelinux.com (default port 9200) and try to connect.

Last edited: 31 Mar 2010

8. ### Poochy

The MM-exam bug is fixed, but now there's another bug in its place: It gives exams WAY too often. As far as I know, TI will only give a promotion or demotion exam if 7 normal games have been played since the last exam of either type. Also, demotion exams in TI only deduct one grade from the qualified grade if failed.

PoochyBot (working title - tell me if you have any suggestions) had the following exams after I turned on exams:
1. Promotion Exam 2 (Passed)
2. Normal game
3. Normal game
4. Promotion Exam 1 (Passed)
5. Promotion Exam S3 (Passed)
6. Promotion Exam S4 (Passed - with a Grand Master run, no less)
7. Promotion Exam S5 (Passed)
8. Promotion Exam S7 (Failed)
9. Promotion Exam S7 (Passed)
10-15. Normal games
16. Demotion Exam (Not demoted)
17. Demotion Exam (Demoted to S3)
18. Promotion Exam S4 (Passed)
19. Demotion Exam (Not demoted)
20. Promotion Exam S5 (Passed)
21. Demotion Exam (Not demoted)
22. Demotion Exam (Not demoted)
23. Promotion Exam S7 (Passed - with a Grand Master run)
24. Promotion Exam S9 (Passed - with a MasterV)
25. Promotion Exam M2 (Failed)
26. Promotion Exam M2 (Failed)
27. Promotion Exam M2 (Failed)
28. Demotion Exam (Demoted to S3)
29. Demotion Exam (Not demoted)
30. Demotion Exam (Not demoted)
31. Demotion Exam (Not demoted)
31. Demotion Exam (Not demoted - with a Master)

Also, Demotion Exams show "Pass" and play the fanfare regardless of whether or not the player was demoted.

9. ### Zircean

Currently, the game gives you an exam if four out of your last seven games are above your current qualified rank, and then it will hand out a promotional exam for the lowest rank that at least four of your last seven games are at least equal to. There should probably be some randomness factor in there but I never got around to implementing it.

Not sure what the deal is with the S3 demotions and the saying "PASS" with the fanfare, though. To be honest, I'm not entirely sure I implemented demotions correctly, besides the whole "demotion points" aspect.

10. ### Zaphod77Resident Misinformer

i'm guessing you are forgetting to clear demotion points after the exam?

it shouldn't give so many in a row definitely.

11. ### Zircean

That might be part of it, but I still can't grasp why it would be demoting a player to S3... Was S3 the rank PoochyBot got in those games?

12. ### Poochy

From what I've seen of TI, the promotional exam behavior seems to adhere to a couple rules:
1. A history of the most recent up to 7 games' grades is kept, and a "promotional exam on next game" flag is also stored with it. At user registration, the history is empty and the flag is initialized to false.
2. After each game:
If the game was an exam:
Clear the history, and set the "promotional exam on next game" flag to false.
Otherwise:
Add this game's grade to history, deleting the oldest one if it's full. Then, if the history is full and the 4th best grade in history is greater than the current qualified grade (and possibly some other condition(s) are also required, such as a random roll), set the "promotional exam on next game" to true. In all other situations, set it to false.
3. At the start of each game:
Check for the "promotional exam on next game" flag. If it's true, a normal game occurs. Otherwise, check for a demotion exam.

I don't know about the exact mechanics of a demotion exam, but I imagine it's something similar to that, only the criteria to trigger it is different (possibly 4th best grade in history is less than the current qualified grade).

Also, I'm pretty sure TI decides at the end of each game whether or not the NEXT game will be an exam. It occasionally flashes a shooting star at the results screen, and that appears to mean that the next game will be a promotional exam. Not that it's mechanically important.

NullpoMino Version 6.5.0.1

Okey, I updated some of NetLobby GUI and probably fixed some of Grade Mania 3 exam weirdness.
This is a minor version update; NetPlay feature is still compatible with 6.5 server.

Version 6.5.0.1 (2010/04/02)
#This version is minor fix release. NetPlay feature is still compatible with 6.5 netplay server.
+NetLobby: Some minor GUI tweaks.
Player list boxes have a popup menu, which you can copy the user name (along with some extra things which is annoying...) to the clipboard.
You can now double click the server name to connect the server.
+NetPlay: Game screen displays the following informations:
Number of current players (includes you if you are joined as a player)
Number of spectators (includes you if you are joined as a spectator)
Number of multiplayer games played (resets when you leave the room)
Number of all players that currently connected into the server (includes you)
Number of rooms (includes your current room)
+Swing/NetPlay: Added in-game player name display for Swing version
-Slick: Mysterious "test.png" no longer loaded into the memory (I forgot to remove it...)
*GRADE MANIA 3: Some workaround fixes for exam.
Exam will happen at the probability of 0.33% (1/3). I know that probability is not accurate, but at least it's better than always-happening.
The demotion point will be reset in zero when the demotional exam starts, or when the player passes the promotional exam.
Probably fixed the multi-demotion bug. (The demotion code was executed more than once in the gameover routine)
Probably fixed the demotional exam fake-pass bug.

Thanks everyone for supporting!

14. ### Muf

Almost correct. The flag is always set to true when the conditions are met, and the random roll occurs at game start. At game start, the flag is checked, and if the flag is true, a random roll decides whether the game will be a normal game or a promotional exam.

17. ### Poochy

Whoa, that was a fast bug-fix. And thanks for setting the record straight, mufunyo.

A series of tests (read: running an AutoHotKey script to automatically start the next game after each one ends, and leaving the computer alone to run while I ate dinner, then checking the replays afterwards) seems to show that the promotion/demotion exams seem to be fixed now, although I did see two promotion exams about 3 games apart. Not sure about the demotion exam fake-pass, since there was only one demotion exam in the batch (the very first game, probably a holdover from the old version) and it was passed.

And if anybody's interested, PoochyBot now has a qualified S9. Also, I'm setting the release date at June 10, 2010.

18. ### Zaphod77Resident Misinformer

WHen poochybot is qualified GM, then release it.

19. ### Poochy

My current goal is precisely to do that by the release date.
For now, though, here's a teaser:
[Edit: Old picture removed. See below for new one.]

Currently, it's got some consistency issues, primarily with trying to cope with a drought without an I piece. It's smart enough to edge clear when necessary, but it's not smart enough to maintain the stack in a way to keep edge clears feasible. I also just fixed a bug that was making it fail to consider twists and sliding under overhangs in certain situations, so hopefully it'll start doing better.

Update:
I found a couple more bugs in PoochyBot, and now it's suddenly doing a LOT better. Which has also revealed a new bug in the exam system: Upon passing an exam, the grade didn't update.

Last edited: 2 Apr 2010
20. ### m:)

when it comes to keeping records shouldn't the lower time take precedence over the level?